diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 7fdf26bf3af99..29de63d6d39dd 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -952,8 +952,9 @@ lint_unused_doc_comment = unused doc comment .label = rustdoc does not generate documentation for macro invocations .help = to document an item produced by a macro, the macro must produce the documentation as part of its expansion -lint_unused_extern_crate = unused extern crate - .suggestion = remove it +lint_unused_extern_crate = unused `extern crate` + .label = unused + .suggestion = remove the unused `extern crate` lint_unused_import_braces = braces around {$node} is unnecessary diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 40ca9e05d95d6..279f452a305e5 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -292,8 +292,8 @@ pub(super) fn decorate_lint( BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => { lints::ByteSliceInPackedStructWithDerive { ty }.decorate_lint(diag); } - BuiltinLintDiag::UnusedExternCrate { removal_span } => { - lints::UnusedExternCrate { removal_span }.decorate_lint(diag); + BuiltinLintDiag::UnusedExternCrate { span, removal_span } => { + lints::UnusedExternCrate { span, removal_span }.decorate_lint(diag); } BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => { let suggestion_span = vis_span.between(ident_span); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index af8fa8ffa1fa7..16f11c45eb95d 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3051,7 +3051,9 @@ pub(crate) struct ByteSliceInPackedStructWithDerive { #[derive(LintDiagnostic)] #[diag(lint_unused_extern_crate)] pub(crate) struct UnusedExternCrate { - #[suggestion(code = "", applicability = "machine-applicable")] + #[label] + pub span: Span, + #[suggestion(code = "", applicability = "machine-applicable", style = "verbose")] pub removal_span: Span, } diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index b4069b317bfa1..dc30532ba1a6f 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -736,6 +736,7 @@ pub enum BuiltinLintDiag { ty: String, }, UnusedExternCrate { + span: Span, removal_span: Span, }, ExternCrateNotIdiomatic { diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index e97233e97ce55..0579e91c0d6ec 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -154,6 +154,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> { extern_crate.id, span, BuiltinLintDiag::UnusedExternCrate { + span: extern_crate.span, removal_span: extern_crate.span_with_attributes, }, ); diff --git a/tests/ui/editions/edition-extern-crate-allowed.rs b/tests/ui/editions/edition-extern-crate-allowed.rs index 5e07417e5aa1b..7798928a7c426 100644 --- a/tests/ui/editions/edition-extern-crate-allowed.rs +++ b/tests/ui/editions/edition-extern-crate-allowed.rs @@ -5,6 +5,6 @@ #![warn(rust_2018_idioms)] extern crate edition_extern_crate_allowed; -//~^ WARNING unused extern crate +//~^ WARNING unused `extern crate` fn main() {} diff --git a/tests/ui/editions/edition-extern-crate-allowed.stderr b/tests/ui/editions/edition-extern-crate-allowed.stderr index dde774c520d71..f816f172311c0 100644 --- a/tests/ui/editions/edition-extern-crate-allowed.stderr +++ b/tests/ui/editions/edition-extern-crate-allowed.stderr @@ -1,8 +1,8 @@ -warning: unused extern crate +warning: unused `extern crate` --> $DIR/edition-extern-crate-allowed.rs:7:1 | LL | extern crate edition_extern_crate_allowed; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/edition-extern-crate-allowed.rs:5:9 @@ -10,6 +10,10 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate edition_extern_crate_allowed; + | warning: 1 warning emitted diff --git a/tests/ui/imports/extern-crate-used.rs b/tests/ui/imports/extern-crate-used.rs index b57dd02cd80c7..9e2e1ca340f84 100644 --- a/tests/ui/imports/extern-crate-used.rs +++ b/tests/ui/imports/extern-crate-used.rs @@ -15,7 +15,7 @@ extern crate core as iso3; extern crate core as iso4; // Doesn't introduce its extern prelude entry, so it's still considered unused. -extern crate core; //~ ERROR unused extern crate +extern crate core; //~ ERROR unused `extern crate` mod m { use iso1::any as are_you_okay1; diff --git a/tests/ui/imports/extern-crate-used.stderr b/tests/ui/imports/extern-crate-used.stderr index 982da0c913ed8..fcca4a4e1a7f7 100644 --- a/tests/ui/imports/extern-crate-used.stderr +++ b/tests/ui/imports/extern-crate-used.stderr @@ -1,14 +1,19 @@ -error: unused extern crate +error: unused `extern crate` --> $DIR/extern-crate-used.rs:18:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/extern-crate-used.rs:6:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | error: aborting due to 1 previous error diff --git a/tests/ui/lint/unnecessary-extern-crate.rs b/tests/ui/lint/unnecessary-extern-crate.rs index 7f97a4c469ed8..fb4edee029ecb 100644 --- a/tests/ui/lint/unnecessary-extern-crate.rs +++ b/tests/ui/lint/unnecessary-extern-crate.rs @@ -4,10 +4,10 @@ #![feature(test)] extern crate core; -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` //~| HELP remove extern crate core as x; -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` //~| HELP remove extern crate proc_macro; @@ -29,11 +29,11 @@ mod foo { pub(super) extern crate alloc as d; extern crate core; - //~^ ERROR unused extern crate + //~^ ERROR unused `extern crate` //~| HELP remove extern crate core as x; - //~^ ERROR unused extern crate + //~^ ERROR unused `extern crate` //~| HELP remove pub extern crate test; @@ -42,11 +42,11 @@ mod foo { mod bar { extern crate core; - //~^ ERROR unused extern crate + //~^ ERROR unused `extern crate` //~| HELP remove extern crate core as x; - //~^ ERROR unused extern crate + //~^ ERROR unused `extern crate` //~| HELP remove pub(in crate::foo::bar) extern crate alloc as e; diff --git a/tests/ui/lint/unnecessary-extern-crate.stderr b/tests/ui/lint/unnecessary-extern-crate.stderr index 1fa4aa9c9a9cf..1049476fa83b2 100644 --- a/tests/ui/lint/unnecessary-extern-crate.stderr +++ b/tests/ui/lint/unnecessary-extern-crate.stderr @@ -1,44 +1,73 @@ -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:6:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/unnecessary-extern-crate.rs:3:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate core; + | -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:9:1 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:31:5 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; + | -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:35:5 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:44:9 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; + | -error: unused extern crate +error: unused `extern crate` --> $DIR/unnecessary-extern-crate.rs:48:9 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unused/lint-unused-extern-crate.rs b/tests/ui/lint/unused/lint-unused-extern-crate.rs index 58ce3a4f55c7d..be506d85caf6f 100644 --- a/tests/ui/lint/unused/lint-unused-extern-crate.rs +++ b/tests/ui/lint/unused/lint-unused-extern-crate.rs @@ -8,7 +8,7 @@ #![allow(unused_variables)] #![allow(deprecated)] -extern crate lint_unused_extern_crate5; //~ ERROR: unused extern crate +extern crate lint_unused_extern_crate5; //~ ERROR: unused `extern crate` pub extern crate lint_unused_extern_crate4; // no error, it is re-exported @@ -26,7 +26,7 @@ use other::*; mod foo { // Test that this is unused even though an earlier `extern crate` is used. - extern crate lint_unused_extern_crate2; //~ ERROR unused extern crate + extern crate lint_unused_extern_crate2; //~ ERROR unused `extern crate` } fn main() { diff --git a/tests/ui/lint/unused/lint-unused-extern-crate.stderr b/tests/ui/lint/unused/lint-unused-extern-crate.stderr index 46d8f3beeab42..c4ee8ed1d944c 100644 --- a/tests/ui/lint/unused/lint-unused-extern-crate.stderr +++ b/tests/ui/lint/unused/lint-unused-extern-crate.stderr @@ -1,20 +1,31 @@ -error: unused extern crate +error: unused `extern crate` --> $DIR/lint-unused-extern-crate.rs:11:1 | LL | extern crate lint_unused_extern_crate5; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/lint-unused-extern-crate.rs:7:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate lint_unused_extern_crate5; +LL + + | -error: unused extern crate +error: unused `extern crate` --> $DIR/lint-unused-extern-crate.rs:29:5 | LL | extern crate lint_unused_extern_crate2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate lint_unused_extern_crate2; +LL + + | error: aborting due to 2 previous errors diff --git a/tests/ui/proc-macro/no-macro-use-attr.rs b/tests/ui/proc-macro/no-macro-use-attr.rs index 2520037813118..463e64da97f61 100644 --- a/tests/ui/proc-macro/no-macro-use-attr.rs +++ b/tests/ui/proc-macro/no-macro-use-attr.rs @@ -4,6 +4,6 @@ #![warn(unused_extern_crates)] extern crate test_macros; -//~^ WARN unused extern crate +//~^ WARN unused `extern crate` fn main() {} diff --git a/tests/ui/proc-macro/no-macro-use-attr.stderr b/tests/ui/proc-macro/no-macro-use-attr.stderr index 4913672450ab9..27da5f42eaa09 100644 --- a/tests/ui/proc-macro/no-macro-use-attr.stderr +++ b/tests/ui/proc-macro/no-macro-use-attr.stderr @@ -1,14 +1,18 @@ -warning: unused extern crate +warning: unused `extern crate` --> $DIR/no-macro-use-attr.rs:6:1 | LL | extern crate test_macros; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/no-macro-use-attr.rs:4:9 | LL | #![warn(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate test_macros; + | warning: 1 warning emitted diff --git a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.fixed b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.fixed index ca8422c03a3a2..3eeacbb2c0580 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.fixed +++ b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.fixed @@ -9,7 +9,7 @@ #![deny(rust_2018_idioms)] #![allow(dead_code)] -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` // Shouldn't suggest changing to `use`, as `bar` // would no longer be added to the prelude which could cause diff --git a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.rs b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.rs index 717e1a039825c..b962bc8fdefe3 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.rs +++ b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.rs @@ -10,7 +10,7 @@ #![allow(dead_code)] extern crate edition_lint_paths; -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` // Shouldn't suggest changing to `use`, as `bar` // would no longer be added to the prelude which could cause diff --git a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr index a68d99c14cead..6561b49e60193 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr +++ b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr @@ -1,8 +1,8 @@ -error: unused extern crate +error: unused `extern crate` --> $DIR/extern-crate-idiomatic-in-2018.rs:12:1 | LL | extern crate edition_lint_paths; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/extern-crate-idiomatic-in-2018.rs:9:9 @@ -10,6 +10,10 @@ note: the lint level is defined here LL | #![deny(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(unused_extern_crates)]` implied by `#[deny(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate edition_lint_paths; + | error: aborting due to 1 previous error diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed index 878d1dc72ccb1..e82422be5ccc5 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed @@ -8,6 +8,6 @@ // The suggestion span should include the attribute. -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` fn main() {} diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs index 573942bd09552..57a05631cc8fc 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs @@ -8,8 +8,8 @@ // The suggestion span should include the attribute. -#[cfg(not(FALSE))] //~ HELP remove it +#[cfg(not(FALSE))] //~ HELP remove extern crate edition_lint_paths; -//~^ ERROR unused extern crate +//~^ ERROR unused `extern crate` fn main() {} diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr index 038a9dd967b73..817ed89bc89b3 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr @@ -1,11 +1,8 @@ -error: unused extern crate +error: unused `extern crate` --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:12:1 | -LL | / #[cfg(not(FALSE))] -LL | | extern crate edition_lint_paths; - | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | |________________________________| - | help: remove it +LL | extern crate edition_lint_paths; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:6:9 @@ -13,6 +10,11 @@ note: the lint level is defined here LL | #![deny(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(unused_extern_crates)]` implied by `#[deny(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - #[cfg(not(FALSE))] +LL - extern crate edition_lint_paths; + | error: aborting due to 1 previous error diff --git a/tests/ui/rust-2018/remove-extern-crate.fixed b/tests/ui/rust-2018/remove-extern-crate.fixed index 19b1dc6fb0130..0952c3b2aa9e7 100644 --- a/tests/ui/rust-2018/remove-extern-crate.fixed +++ b/tests/ui/rust-2018/remove-extern-crate.fixed @@ -8,7 +8,7 @@ #![allow(dropping_copy_types)] #![allow(unused_imports)] - //~ WARNING unused extern crate + //~ WARNING unused `extern crate` // Shouldn't suggest changing to `use`, as `another_name` // would no longer be added to the prelude which could cause // compilation errors for imports that use `another_name` in other diff --git a/tests/ui/rust-2018/remove-extern-crate.rs b/tests/ui/rust-2018/remove-extern-crate.rs index 88ef858da147f..59a3d4343c897 100644 --- a/tests/ui/rust-2018/remove-extern-crate.rs +++ b/tests/ui/rust-2018/remove-extern-crate.rs @@ -8,7 +8,7 @@ #![allow(dropping_copy_types)] #![allow(unused_imports)] -extern crate core; //~ WARNING unused extern crate +extern crate core; //~ WARNING unused `extern crate` // Shouldn't suggest changing to `use`, as `another_name` // would no longer be added to the prelude which could cause // compilation errors for imports that use `another_name` in other diff --git a/tests/ui/rust-2018/remove-extern-crate.stderr b/tests/ui/rust-2018/remove-extern-crate.stderr index cb090c621e9f9..4c8fa017cf837 100644 --- a/tests/ui/rust-2018/remove-extern-crate.stderr +++ b/tests/ui/rust-2018/remove-extern-crate.stderr @@ -1,8 +1,8 @@ -warning: unused extern crate +warning: unused `extern crate` --> $DIR/remove-extern-crate.rs:11:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/remove-extern-crate.rs:7:9 @@ -10,6 +10,11 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | warning: `extern crate` is not idiomatic in the new edition --> $DIR/remove-extern-crate.rs:35:5 diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed new file mode 100644 index 0000000000000..d3d4880ecb4f6 --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed @@ -0,0 +1,15 @@ +//@ edition:2018 +//@ aux-build:../removing-extern-crate.rs +//@ run-rustfix + +#![warn(rust_2018_idioms)] + + //~ WARNING unused `extern crate` + //~ WARNING unused `extern crate` + +mod another { + //~ WARNING unused `extern crate` + //~ WARNING unused `extern crate` +} + +fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs new file mode 100644 index 0000000000000..9578a1041bd91 --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs @@ -0,0 +1,17 @@ +//@ edition:2018 +//@ aux-build:../removing-extern-crate.rs +//@ run-rustfix + +#![warn(rust_2018_idioms)] + +#[cfg_attr(test, "macro_use")] //~ ERROR expected +extern crate removing_extern_crate as foo; //~ WARNING unused `extern crate` +extern crate core; //~ WARNING unused `extern crate` + +mod another { + #[cfg_attr(test)] //~ ERROR expected + extern crate removing_extern_crate as foo; //~ WARNING unused `extern crate` + extern crate core; //~ WARNING unused `extern crate` +} + +fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr new file mode 100644 index 0000000000000..4ab02ef8fc1e5 --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr @@ -0,0 +1,76 @@ +error: expected identifier, found `"macro_use"` + --> $DIR/removing-extern-crate-malformed-cfg.rs:7:18 + | +LL | #[cfg_attr(test, "macro_use")] + | ^^^^^^^^^^^ expected identifier + | + = help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]` + = note: for more information, visit + +error: expected one of `(`, `,`, `::`, or `=`, found `` + --> $DIR/removing-extern-crate-malformed-cfg.rs:12:16 + | +LL | #[cfg_attr(test)] + | ^^^^ expected one of `(`, `,`, `::`, or `=` + | + = help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]` + = note: for more information, visit + +warning: unused `extern crate` + --> $DIR/removing-extern-crate-malformed-cfg.rs:8:1 + | +LL | extern crate removing_extern_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +note: the lint level is defined here + --> $DIR/removing-extern-crate-malformed-cfg.rs:5:9 + | +LL | #![warn(rust_2018_idioms)] + | ^^^^^^^^^^^^^^^^ + = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - #[cfg_attr(test, "macro_use")] +LL - extern crate removing_extern_crate as foo; +LL + + | + +warning: unused `extern crate` + --> $DIR/removing-extern-crate-malformed-cfg.rs:9:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | + +warning: unused `extern crate` + --> $DIR/removing-extern-crate-malformed-cfg.rs:13:5 + | +LL | extern crate removing_extern_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - #[cfg_attr(test)] +LL - extern crate removing_extern_crate as foo; +LL + + | + +warning: unused `extern crate` + --> $DIR/removing-extern-crate-malformed-cfg.rs:14:5 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | + +error: aborting due to 2 previous errors; 4 warnings emitted + diff --git a/tests/ui/rust-2018/removing-extern-crate.fixed b/tests/ui/rust-2018/removing-extern-crate.fixed index e88a84cc93e2a..e0062e884246c 100644 --- a/tests/ui/rust-2018/removing-extern-crate.fixed +++ b/tests/ui/rust-2018/removing-extern-crate.fixed @@ -5,12 +5,12 @@ #![warn(rust_2018_idioms)] - //~ WARNING unused extern crate - //~ WARNING unused extern crate + //~ WARNING unused `extern crate` + //~ WARNING unused `extern crate` mod another { - //~ WARNING unused extern crate - //~ WARNING unused extern crate + //~ WARNING unused `extern crate` + //~ WARNING unused `extern crate` } fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate.rs b/tests/ui/rust-2018/removing-extern-crate.rs index 844377945e02f..5cde36eba5108 100644 --- a/tests/ui/rust-2018/removing-extern-crate.rs +++ b/tests/ui/rust-2018/removing-extern-crate.rs @@ -5,12 +5,12 @@ #![warn(rust_2018_idioms)] -extern crate dummy_crate as foo; //~ WARNING unused extern crate -extern crate core; //~ WARNING unused extern crate +extern crate dummy_crate as foo; //~ WARNING unused `extern crate` +extern crate core; //~ WARNING unused `extern crate` mod another { - extern crate dummy_crate as foo; //~ WARNING unused extern crate - extern crate core; //~ WARNING unused extern crate + extern crate dummy_crate as foo; //~ WARNING unused `extern crate` + extern crate core; //~ WARNING unused `extern crate` } fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate.stderr b/tests/ui/rust-2018/removing-extern-crate.stderr index 573125426404d..78f90599be60c 100644 --- a/tests/ui/rust-2018/removing-extern-crate.stderr +++ b/tests/ui/rust-2018/removing-extern-crate.stderr @@ -1,8 +1,8 @@ -warning: unused extern crate +warning: unused `extern crate` --> $DIR/removing-extern-crate.rs:8:1 | LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/removing-extern-crate.rs:6:9 @@ -10,24 +10,47 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate dummy_crate as foo; +LL + + | -warning: unused extern crate +warning: unused `extern crate` --> $DIR/removing-extern-crate.rs:9:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | -warning: unused extern crate +warning: unused `extern crate` --> $DIR/removing-extern-crate.rs:12:5 | LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate dummy_crate as foo; +LL + + | -warning: unused extern crate +warning: unused `extern crate` --> $DIR/removing-extern-crate.rs:13:5 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | warning: 4 warnings emitted