Auto merge of #54650 - eddyb:no-extern's-land, r=alexcrichton
Don't lint non-extern-prelude extern crate's in Rust 2018. Fixes #54381 by silencing the lint telling users to remove `extern crate` when `use` doesn't work. r? @alexcrichton cc @petrochenkov @nikomatsakis @Centril
This commit is contained in:
commit
93efd533a3
10 changed files with 59 additions and 110 deletions
|
|
@ -20,33 +20,23 @@ extern crate alloc as x;
|
|||
//~^ ERROR unused extern crate
|
||||
//~| HELP remove
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
#[macro_use]
|
||||
extern crate test;
|
||||
|
||||
pub extern crate test as y;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub use`
|
||||
|
||||
pub extern crate libc;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub use`
|
||||
|
||||
pub(crate) extern crate libc as a;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub(crate) use`
|
||||
|
||||
crate extern crate libc as b;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `crate use`
|
||||
|
||||
mod foo {
|
||||
pub(in crate::foo) extern crate libc as c;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub(in crate::foo) use`
|
||||
|
||||
pub(super) extern crate libc as d;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub(super) use`
|
||||
|
||||
extern crate alloc;
|
||||
//~^ ERROR unused extern crate
|
||||
|
|
@ -57,12 +47,8 @@ mod foo {
|
|||
//~| HELP remove
|
||||
|
||||
pub extern crate test;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it
|
||||
|
||||
pub extern crate test as y;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it
|
||||
|
||||
mod bar {
|
||||
extern crate alloc;
|
||||
|
|
@ -74,8 +60,6 @@ mod foo {
|
|||
//~| HELP remove
|
||||
|
||||
pub(in crate::foo::bar) extern crate libc as e;
|
||||
//~^ ERROR `extern crate` is not idiomatic in the new edition
|
||||
//~| HELP convert it to a `pub(in crate::foo::bar) use`
|
||||
|
||||
fn dummy() {
|
||||
unsafe {
|
||||
|
|
@ -96,4 +80,6 @@ mod foo {
|
|||
fn main() {
|
||||
unsafe { a::getpid(); }
|
||||
unsafe { b::getpid(); }
|
||||
|
||||
proc_macro::TokenStream::new();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,83 +16,29 @@ error: unused extern crate
|
|||
LL | extern crate alloc as x;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:26:1
|
||||
|
|
||||
LL | pub extern crate test as y;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:30:1
|
||||
|
|
||||
LL | pub extern crate libc;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:34:1
|
||||
|
|
||||
LL | pub(crate) extern crate libc as a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(crate) use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:38:1
|
||||
|
|
||||
LL | crate extern crate libc as b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `crate use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:43:5
|
||||
|
|
||||
LL | pub(in crate::foo) extern crate libc as c;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(in crate::foo) use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:47:5
|
||||
|
|
||||
LL | pub(super) extern crate libc as d;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(super) use`
|
||||
|
||||
error: unused extern crate
|
||||
--> $DIR/unnecessary-extern-crate.rs:51:5
|
||||
--> $DIR/unnecessary-extern-crate.rs:41:5
|
||||
|
|
||||
LL | extern crate alloc;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
||||
error: unused extern crate
|
||||
--> $DIR/unnecessary-extern-crate.rs:55:5
|
||||
--> $DIR/unnecessary-extern-crate.rs:45:5
|
||||
|
|
||||
LL | extern crate alloc as x;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:59:5
|
||||
|
|
||||
LL | pub extern crate test;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use`
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:63:5
|
||||
|
|
||||
LL | pub extern crate test as y;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use`
|
||||
|
||||
error: unused extern crate
|
||||
--> $DIR/unnecessary-extern-crate.rs:68:9
|
||||
--> $DIR/unnecessary-extern-crate.rs:54:9
|
||||
|
|
||||
LL | extern crate alloc;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
||||
error: unused extern crate
|
||||
--> $DIR/unnecessary-extern-crate.rs:72:9
|
||||
--> $DIR/unnecessary-extern-crate.rs:58:9
|
||||
|
|
||||
LL | extern crate alloc as x;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
||||
error: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/unnecessary-extern-crate.rs:76:9
|
||||
|
|
||||
LL | pub(in crate::foo::bar) extern crate libc as e;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(in crate::foo::bar) use`
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
// aux-build:remove-extern-crate.rs
|
||||
// compile-flags:--extern remove_extern_crate
|
||||
|
||||
#![feature(alloc)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
|
||||
|
|
@ -22,11 +23,16 @@ use remove_extern_crate;
|
|||
#[macro_use]
|
||||
extern crate remove_extern_crate as something_else;
|
||||
|
||||
// Shouldn't suggest changing to `use`, as the `alloc`
|
||||
// crate is not in the extern prelude - see #54381.
|
||||
extern crate alloc;
|
||||
|
||||
fn main() {
|
||||
another_name::mem::drop(3);
|
||||
another::foo();
|
||||
remove_extern_crate::foo!();
|
||||
bar!();
|
||||
alloc::vec![5];
|
||||
}
|
||||
|
||||
mod another {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
// aux-build:remove-extern-crate.rs
|
||||
// compile-flags:--extern remove_extern_crate
|
||||
|
||||
#![feature(alloc)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
extern crate core;
|
||||
|
|
@ -22,11 +23,16 @@ use remove_extern_crate;
|
|||
#[macro_use]
|
||||
extern crate remove_extern_crate as something_else;
|
||||
|
||||
// Shouldn't suggest changing to `use`, as the `alloc`
|
||||
// crate is not in the extern prelude - see #54381.
|
||||
extern crate alloc;
|
||||
|
||||
fn main() {
|
||||
another_name::mem::drop(3);
|
||||
another::foo();
|
||||
remove_extern_crate::foo!();
|
||||
bar!();
|
||||
alloc::vec![5];
|
||||
}
|
||||
|
||||
mod another {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
warning: unused extern crate
|
||||
--> $DIR/remove-extern-crate.rs:19:1
|
||||
--> $DIR/remove-extern-crate.rs:20:1
|
||||
|
|
||||
LL | extern crate core;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: remove it
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/remove-extern-crate.rs:17:9
|
||||
--> $DIR/remove-extern-crate.rs:18:9
|
||||
|
|
||||
LL | #![warn(rust_2018_idioms)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
= note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
|
||||
|
||||
warning: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/remove-extern-crate.rs:20:1
|
||||
--> $DIR/remove-extern-crate.rs:21:1
|
||||
|
|
||||
LL | extern crate core as another_name;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
|
||||
|
||||
warning: `extern crate` is not idiomatic in the new edition
|
||||
--> $DIR/remove-extern-crate.rs:33:5
|
||||
--> $DIR/remove-extern-crate.rs:39:5
|
||||
|
|
||||
LL | extern crate core;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue