rust/src/test/ui/unnecessary-extern-crate.rs

82 lines
1.7 KiB
Rust
Raw Normal View History

2018-05-04 13:25:31 -05:00
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// edition:2018
#![deny(unused_extern_crates)]
#![feature(alloc, test, libc, crate_visibility_modifier)]
2018-05-04 13:25:31 -05:00
extern crate libc;
//~^ ERROR unused extern crate
2018-05-04 13:25:31 -05:00
//~| HELP remove
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove
2018-05-04 13:25:31 -05:00
extern crate proc_macro;
2018-05-04 13:25:31 -05:00
#[macro_use]
extern crate test;
2018-05-04 13:25:31 -05:00
pub extern crate test as y;
pub extern crate alloc;
pub(crate) extern crate alloc as a;
2018-05-04 13:25:31 -05:00
crate extern crate alloc as b;
2018-05-04 13:25:31 -05:00
mod foo {
pub(in crate::foo) extern crate alloc as c;
pub(super) extern crate alloc as d;
extern crate libc;
//~^ ERROR unused extern crate
//~| HELP remove
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove
2018-05-04 13:25:31 -05:00
pub extern crate test;
2018-05-04 13:25:31 -05:00
pub extern crate test as y;
2018-05-04 13:25:31 -05:00
mod bar {
extern crate libc;
//~^ ERROR unused extern crate
//~| HELP remove
extern crate libc as x;
//~^ ERROR unused extern crate
//~| HELP remove
pub(in crate::foo::bar) extern crate alloc as e;
fn dummy() {
e::string::String::new();
}
}
fn dummy() {
c::string::String::new();
d::string::String::new();
2018-05-04 13:25:31 -05:00
}
}
fn main() {
a::string::String::new();
b::string::String::new();
proc_macro::TokenStream::new();
}