From 810288eb3c6d1ccaa1691689408d6d5448b81363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 11:25:13 +0200 Subject: [PATCH 1/3] ICE when applying test to crate root --- tests/crashes/114920.rs | 2 -- tests/ui/macros/test-on-crate-root.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 tests/crashes/114920.rs create mode 100644 tests/ui/macros/test-on-crate-root.rs diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs deleted file mode 100644 index 9aa7598e10fc3..0000000000000 --- a/tests/crashes/114920.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ known-bug: #114920 -#![core::prelude::v1::test] diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs new file mode 100644 index 0000000000000..80635a458902d --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.rs @@ -0,0 +1,8 @@ +// ICE when applying `#![test]` to the crate root, +// though only when specified with a full path. `#![test]` is not enough. +// Fixes #114920 +#![core::prelude::v1::test] + + + +fn main() {} // not important to reproduce the issue From 0885bd68792805e0842ce1a564f271f4db679068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 12:10:21 +0200 Subject: [PATCH 2/3] only discard items with `#[test]` on it when target is valid --- compiler/rustc_builtin_macros/src/test.rs | 18 +- .../ui/feature-gates/gating-of-test-attrs.rs | 48 +++ .../feature-gates/gating-of-test-attrs.stderr | 181 +++++++++++ .../issue-43106-gating-of-builtin-attrs.rs | 32 -- ...issue-43106-gating-of-builtin-attrs.stderr | 294 +++++++++--------- tests/ui/macros/attr-empty-expr.rs | 11 - tests/ui/macros/attr-empty-expr.stderr | 20 -- tests/ui/macros/issue-111749.rs | 4 +- tests/ui/macros/issue-111749.stderr | 16 +- tests/ui/macros/test-on-crate-root.rs | 3 +- tests/ui/macros/test-on-crate-root.stderr | 25 ++ 11 files changed, 425 insertions(+), 227 deletions(-) create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.rs create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.stderr delete mode 100644 tests/ui/macros/attr-empty-expr.rs delete mode 100644 tests/ui/macros/attr-empty-expr.stderr create mode 100644 tests/ui/macros/test-on-crate-root.stderr diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 7a189ee1f4d05..149e1b64d7703 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -34,10 +34,6 @@ pub(crate) fn expand_test_case( check_builtin_macro_attribute(ecx, meta_item, sym::test_case); warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case); - if !ecx.ecfg.should_test { - return vec![]; - } - let sp = ecx.with_def_site_ctxt(attr_sp); let (mut item, is_stmt) = match anno_item { Annotatable::Item(item) => (item, false), @@ -54,6 +50,10 @@ pub(crate) fn expand_test_case( } }; + if !ecx.ecfg.should_test { + return vec![]; + } + // `#[test_case]` is valid on functions, consts, and statics. Only modify // the item in those cases. match &mut item.kind { @@ -113,11 +113,6 @@ pub(crate) fn expand_test_or_bench( item: Annotatable, is_bench: bool, ) -> Vec { - // If we're not in test configuration, remove the annotated item - if !cx.ecfg.should_test { - return vec![]; - } - let (item, is_stmt) = match item { Annotatable::Item(i) => (i, false), Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true), @@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench( }; }; + // If we're not in test configuration, remove the annotated item + if !cx.ecfg.should_test { + return vec![]; + } + if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) { cx.dcx().emit_err(errors::NakedFunctionTestingAttribute { testing_span: attr_sp, diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs new file mode 100644 index 0000000000000..22b0454e17410 --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -0,0 +1,48 @@ +#![feature(test)] + +// test is a built-in macro, not a built-in attribute, but it kind of acts like both. +// check its target checking anyway here +#[test] +//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +mod test { + mod inner { #![test] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[test]` attribute may only be used on a non-associated function + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + struct S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + type T = S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + impl S { } +} + +// At time of unit test authorship, if compiling without `--test` then +// non-crate-level #[bench] attributes seem to be ignored. + +#[bench] +//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +mod bench { + mod inner { #![bench] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[test]` attribute may only be used on a non-associated function + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + struct S; + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + type T = S; + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + impl S { } +} + +fn main() {} diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr new file mode 100644 index 0000000000000..339a68f5d5e48 --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -0,0 +1,181 @@ +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:5:1 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod test { +LL | | mod inner { #![test] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:8:20 + | +LL | mod inner { #![test] } + | ^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:8:17 + | +LL | mod inner { #![test] } + | ------------^^^^^^^^-- + | | | + | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - mod inner { #![test] } +LL + mod inner { #[cfg(test)] } + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:12:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:16:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:20:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:28:1 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod bench { +LL | | mod inner { #![bench] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:31:20 + | +LL | mod inner { #![bench] } + | ^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:31:17 + | +LL | mod inner { #![bench] } + | ------------^^^^^^^^^-- + | | | + | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - mod inner { #![bench] } +LL + mod inner { #[cfg(test)] } + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:35:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:39:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:43:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index a0d3ed97142cb..48f828f876977 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -250,38 +250,6 @@ mod macro_export { //~| HELP remove the attribute } -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[test] attributes seem to be ignored. - -#[test] -mod test { mod inner { #![test] } - - fn f() { } - - struct S; - - type T = S; - - impl S { } -} - -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[bench] attributes seem to be ignored. - -#[bench] -mod bench { - mod inner { #![bench] } - - #[bench] - struct S; - - #[bench] - type T = S; - - #[bench] - impl S { } -} - #[path = "3800"] mod path { mod inner { #![path="3800"] } diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 29044f1212c21..0b0565b450183 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL | #[deny(x5100)] impl S { } | ^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | #![reexport_test_harness_main = "2900"] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:739:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1 | LL | #[link(name = "x")] | ^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ LL | #![windows_subsystem = "windows"] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:865:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | #![crate_type = "0800"] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ @@ -252,7 +252,7 @@ LL | #![feature(x0600)] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:914:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:882:1 | LL | #[no_main] | ^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | #![no_main] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:938:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ @@ -290,13 +290,13 @@ LL | #![feature(rust1)] = note: `#[warn(stable_features)]` on by default warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:505:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:508:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:516:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -340,7 +340,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { } | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:17 | LL | mod inner { #![link(name = "x")] } | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block @@ -348,7 +348,7 @@ LL | mod inner { #![link(name = "x")] } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 | LL | #[link(name = "x")] fn f() { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -356,7 +356,7 @@ LL | #[link(name = "x")] fn f() { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5 | LL | #[link(name = "x")] struct S; | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block @@ -364,7 +364,7 @@ LL | #[link(name = "x")] struct S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 | LL | #[link(name = "x")] type T = S; | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block @@ -372,7 +372,7 @@ LL | #[link(name = "x")] type T = S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5 | LL | #[link(name = "x")] impl S { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -380,7 +380,7 @@ LL | #[link(name = "x")] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:5 | LL | #[link(name = "x")] extern "Rust" {} | ^^^^^^^^^^^^^^^^^^^ @@ -388,13 +388,13 @@ LL | #[link(name = "x")] extern "Rust" {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:787:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL | #![windows_subsystem = "windows"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,7 @@ LL | #![windows_subsystem = "windows"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -427,7 +427,7 @@ LL | #![windows_subsystem = "windows"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -438,13 +438,13 @@ LL | #![windows_subsystem = "windows"] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:869:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:837:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL | #![crate_type = "0800"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL | #![crate_type = "0800"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:880:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -477,7 +477,7 @@ LL | #![crate_type = "0800"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:884:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -488,13 +488,13 @@ LL | #![crate_type = "0800"] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:861:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:896:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ @@ -505,7 +505,7 @@ LL | #![feature(x0600)] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ @@ -516,7 +516,7 @@ LL | #![feature(x0600)] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:904:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ @@ -527,7 +527,7 @@ LL | #![feature(x0600)] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:908:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ @@ -538,13 +538,13 @@ LL | #![feature(x0600)] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:918:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:886:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | #![no_main] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ @@ -566,7 +566,7 @@ LL | #![no_main] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:897:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ @@ -577,7 +577,7 @@ LL | #![no_main] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:901:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ @@ -588,13 +588,13 @@ LL | #![no_main] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:942:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:910:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ @@ -605,7 +605,7 @@ LL | #![no_builtins] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:917:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ @@ -616,7 +616,7 @@ LL | #![no_builtins] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ @@ -627,7 +627,7 @@ LL | #![no_builtins] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ @@ -728,7 +728,7 @@ LL | #[macro_export] impl S { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[path]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:289:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:257:5 | LL | #[path = "3800"] fn f() { } | ^^^^^^^^^^^^^^^^ @@ -737,7 +737,7 @@ LL | #[path = "3800"] fn f() { } = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:263:5 | LL | #[path = "3800"] struct S; | ^^^^^^^^^^^^^^^^ @@ -746,7 +746,7 @@ LL | #[path = "3800"] struct S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:301:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5 | LL | #[path = "3800"] type T = S; | ^^^^^^^^^^^^^^^^ @@ -755,7 +755,7 @@ LL | #[path = "3800"] type T = S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:307:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:275:5 | LL | #[path = "3800"] impl S { } | ^^^^^^^^^^^^^^^^ @@ -764,7 +764,7 @@ LL | #[path = "3800"] impl S { } = help: `#[path]` can only be applied to modules warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:314:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:282:1 | LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -773,7 +773,7 @@ LL | #[automatically_derived] = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:320:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:288:17 | LL | mod inner { #![automatically_derived] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -782,7 +782,7 @@ LL | mod inner { #![automatically_derived] } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:294:5 | LL | #[automatically_derived] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -791,7 +791,7 @@ LL | #[automatically_derived] fn f() { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5 | LL | #[automatically_derived] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -800,7 +800,7 @@ LL | #[automatically_derived] struct S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:338:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:306:5 | LL | #[automatically_derived] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -809,7 +809,7 @@ LL | #[automatically_derived] type T = S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:312:5 | LL | #[automatically_derived] trait W { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -818,7 +818,7 @@ LL | #[automatically_derived] trait W { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:5 | LL | #[automatically_derived] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -827,7 +827,7 @@ LL | #[automatically_derived] impl S { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:359:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:327:1 | LL | #[no_mangle] | ^^^^^^^^^^^^ @@ -836,7 +836,7 @@ LL | #[no_mangle] = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:333:17 | LL | mod inner { #![no_mangle] } | ^^^^^^^^^^^^^ @@ -845,7 +845,7 @@ LL | mod inner { #![no_mangle] } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:341:5 | LL | #[no_mangle] struct S; | ^^^^^^^^^^^^ @@ -854,7 +854,7 @@ LL | #[no_mangle] struct S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:347:5 | LL | #[no_mangle] type T = S; | ^^^^^^^^^^^^ @@ -863,7 +863,7 @@ LL | #[no_mangle] type T = S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:385:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:353:5 | LL | #[no_mangle] impl S { } | ^^^^^^^^^^^^ @@ -872,7 +872,7 @@ LL | #[no_mangle] impl S { } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:360:9 | LL | #[no_mangle] fn foo(); | ^^^^^^^^^^^^ @@ -881,7 +881,7 @@ LL | #[no_mangle] fn foo(); = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[no_mangle]` attribute cannot be used on provided trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:366:9 | LL | #[no_mangle] fn bar() {} | ^^^^^^^^^^^^ @@ -890,7 +890,7 @@ LL | #[no_mangle] fn bar() {} = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:374:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ @@ -899,7 +899,7 @@ LL | #[should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:17 | LL | mod inner { #![should_panic] } | ^^^^^^^^^^^^^^^^ @@ -908,7 +908,7 @@ LL | mod inner { #![should_panic] } = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:388:5 | LL | #[should_panic] struct S; | ^^^^^^^^^^^^^^^ @@ -917,7 +917,7 @@ LL | #[should_panic] struct S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:394:5 | LL | #[should_panic] type T = S; | ^^^^^^^^^^^^^^^ @@ -926,7 +926,7 @@ LL | #[should_panic] type T = S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:400:5 | LL | #[should_panic] impl S { } | ^^^^^^^^^^^^^^^ @@ -935,7 +935,7 @@ LL | #[should_panic] impl S { } = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:1 | LL | #[ignore] | ^^^^^^^^^ @@ -944,7 +944,7 @@ LL | #[ignore] = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:413:17 | LL | mod inner { #![ignore] } | ^^^^^^^^^^ @@ -953,7 +953,7 @@ LL | mod inner { #![ignore] } = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:453:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:421:5 | LL | #[ignore] struct S; | ^^^^^^^^^ @@ -962,7 +962,7 @@ LL | #[ignore] struct S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:5 | LL | #[ignore] type T = S; | ^^^^^^^^^ @@ -971,7 +971,7 @@ LL | #[ignore] type T = S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 | LL | #[ignore] impl S { } | ^^^^^^^^^ @@ -980,7 +980,7 @@ LL | #[ignore] impl S { } = help: `#[ignore]` can only be applied to functions warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:444:5 | LL | #[no_implicit_prelude] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -989,7 +989,7 @@ LL | #[no_implicit_prelude] fn f() { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:482:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:450:5 | LL | #[no_implicit_prelude] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -998,7 +998,7 @@ LL | #[no_implicit_prelude] struct S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:456:5 | LL | #[no_implicit_prelude] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -1007,7 +1007,7 @@ LL | #[no_implicit_prelude] type T = S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:5 | LL | #[no_implicit_prelude] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -1016,7 +1016,7 @@ LL | #[no_implicit_prelude] impl S { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[macro_escape]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ @@ -1025,7 +1025,7 @@ LL | #[macro_escape] fn f() { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ @@ -1034,7 +1034,7 @@ LL | #[macro_escape] struct S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:513:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ @@ -1043,7 +1043,7 @@ LL | #[macro_escape] type T = S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ @@ -1052,13 +1052,13 @@ LL | #[macro_escape] impl S { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:558:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 | LL | #[no_std] | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:560:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:1 | LL | / mod no_std { LL | | @@ -1068,61 +1068,61 @@ LL | | } | |_^ warning: the `#![no_std]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:562:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:530:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:15 | LL | #[no_std] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:5 | LL | #[no_std] struct S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:15 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:15 | LL | #[no_std] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:15 | LL | #[no_std] impl S { } | ^^^^^^^^^^ warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:599:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:567:1 | LL | #[cold] | ^^^^^^^ @@ -1131,7 +1131,7 @@ LL | #[cold] = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:574:17 | LL | mod inner { #![cold] } | ^^^^^^^^ @@ -1140,7 +1140,7 @@ LL | mod inner { #![cold] } = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:582:5 | LL | #[cold] struct S; | ^^^^^^^ @@ -1149,7 +1149,7 @@ LL | #[cold] struct S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:588:5 | LL | #[cold] type T = S; | ^^^^^^^ @@ -1158,7 +1158,7 @@ LL | #[cold] type T = S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:594:5 | LL | #[cold] impl S { } | ^^^^^^^ @@ -1167,7 +1167,7 @@ LL | #[cold] impl S { } = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:1 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1176,7 +1176,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on foreign modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:607:5 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1185,7 +1185,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:17 | LL | mod inner { #![link_name="1900"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1194,7 +1194,7 @@ LL | mod inner { #![link_name="1900"] } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 | LL | #[link_name = "1900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1203,7 +1203,7 @@ LL | #[link_name = "1900"] fn f() { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 | LL | #[link_name = "1900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1212,7 +1212,7 @@ LL | #[link_name = "1900"] struct S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:5 | LL | #[link_name = "1900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1221,7 +1221,7 @@ LL | #[link_name = "1900"] type T = S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:5 | LL | #[link_name = "1900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1230,7 +1230,7 @@ LL | #[link_name = "1900"] impl S { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:645:1 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1239,7 +1239,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:17 | LL | mod inner { #![link_section="1800"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1248,7 +1248,7 @@ LL | mod inner { #![link_section="1800"] } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:659:5 | LL | #[link_section = "1800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1257,7 +1257,7 @@ LL | #[link_section = "1800"] struct S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5 | LL | #[link_section = "1800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1266,7 +1266,7 @@ LL | #[link_section = "1800"] type T = S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5 | LL | #[link_section = "1800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1275,7 +1275,7 @@ LL | #[link_section = "1800"] impl S { } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1284,7 +1284,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:1 | LL | #[must_use] | ^^^^^^^^^^^ @@ -1293,7 +1293,7 @@ LL | #[must_use] = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ @@ -1302,7 +1302,7 @@ LL | mod inner { #![must_use] } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:772:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ @@ -1311,7 +1311,7 @@ LL | #[must_use] type T = S; = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:777:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ @@ -1320,13 +1320,13 @@ LL | #[must_use] impl S { } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:841:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:811:1 | LL | / mod crate_name { LL | | @@ -1336,67 +1336,67 @@ LL | | } | |_^ warning: the `#![crate_name]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:845:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:28 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:28 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:28 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:28 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:962:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:930:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:932:1 | LL | / mod recursion_limit { LL | | @@ -1406,67 +1406,67 @@ LL | | } | |_^ warning: the `#![recursion_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:966:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:934:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:31 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:31 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:31 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:31 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:986:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:954:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:988:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:956:1 | LL | / mod type_length_limit { LL | | @@ -1476,55 +1476,55 @@ LL | | } | |_^ warning: the `#![type_length_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:990:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:958:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:33 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:33 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:33 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:33 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^ diff --git a/tests/ui/macros/attr-empty-expr.rs b/tests/ui/macros/attr-empty-expr.rs deleted file mode 100644 index d4d1a3ee71e67..0000000000000 --- a/tests/ui/macros/attr-empty-expr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// AST-based macro attributes expanding to an empty expression produce an error and not ICE. - -#![feature(custom_test_frameworks)] -#![feature(stmt_expr_attributes)] -#![feature(test)] - -fn main() { - let _ = #[test] 0; //~ ERROR removing an expression is not supported in this position - let _ = #[bench] 1; //~ ERROR removing an expression is not supported in this position - let _ = #[test_case] 2; //~ ERROR removing an expression is not supported in this position -} diff --git a/tests/ui/macros/attr-empty-expr.stderr b/tests/ui/macros/attr-empty-expr.stderr deleted file mode 100644 index 53721053bcc08..0000000000000 --- a/tests/ui/macros/attr-empty-expr.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:8:13 - | -LL | let _ = #[test] 0; - | ^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:9:13 - | -LL | let _ = #[bench] 1; - | ^^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:10:13 - | -LL | let _ = #[test_case] 2; - | ^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/macros/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 6c45e4e8cd719..779a854ea5824 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -5,8 +5,8 @@ macro_rules! cbor_map { } fn main() { - cbor_map! { #[test(test)] 4}; - //~^ ERROR removing an expression is not supported in this position + cbor_map! { #[test(test)] 4i32}; + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function //~| ERROR attribute must be of the form `#[test]` //~| WARNING this was previously accepted by the compiler but is being phased out } diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr index ae953e042e094..3afdd0ad4baff 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,13 +1,19 @@ -error: removing an expression is not supported in this position +error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; - | ^^^^^^^^^^^^^ +LL | cbor_map! { #[test(test)] 4i32}; + | ^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - cbor_map! { #[test(test)] 4i32}; +LL + cbor_map! { #[cfg(test)] 4i32}; + | error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -20,7 +26,7 @@ Future incompatibility report: Future breakage diagnostic: error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index 80635a458902d..abe08536b1d68 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -2,7 +2,8 @@ // though only when specified with a full path. `#![test]` is not enough. // Fixes #114920 #![core::prelude::v1::test] - +//~^ ERROR inner macro attributes are unstable +//~| ERROR the `#[test]` attribute may only be used on a non-associated function fn main() {} // not important to reproduce the issue diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr new file mode 100644 index 0000000000000..5a5e0597284d3 --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -0,0 +1,25 @@ +error[E0658]: inner macro attributes are unstable + --> $DIR/test-on-crate-root.rs:3:4 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/test-on-crate-root.rs:3:1 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #![core::prelude::v1::test] +LL + #[cfg(test)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. From a9e463091f798602907ba552c96d911655bb1872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 12:13:39 +0200 Subject: [PATCH 3/3] fixup name in diagnostics --- compiler/rustc_builtin_macros/src/test.rs | 21 +++++--- .../ui/feature-gates/gating-of-test-attrs.rs | 10 ++-- .../feature-gates/gating-of-test-attrs.stderr | 50 ++++--------------- tests/ui/macros/test-on-crate-root.stderr | 4 +- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 149e1b64d7703..af69e68d8e131 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -117,13 +117,13 @@ pub(crate) fn expand_test_or_bench( Annotatable::Item(i) => (i, false), Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true), other => { - not_testable_error(cx, attr_sp, None); + not_testable_error(cx, is_bench, attr_sp, None); return vec![other]; } }; let ast::ItemKind::Fn(fn_) = &item.kind else { - not_testable_error(cx, attr_sp, Some(&item)); + not_testable_error(cx, is_bench, attr_sp, Some(&item)); return if is_stmt { vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))] } else { @@ -405,9 +405,10 @@ pub(crate) fn expand_test_or_bench( } } -fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) { +fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Option<&ast::Item>) { let dcx = cx.dcx(); - let msg = "the `#[test]` attribute may only be used on a non-associated function"; + let name = if is_bench { "bench" } else { "test" }; + let msg = format!("the `#[{name}]` attribute may only be used on a non-associated function",); let level = match item.map(|i| &i.kind) { // These were a warning before #92959 and need to continue being that to avoid breaking // stable user code (#94508). @@ -426,12 +427,16 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) ), ); } - err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions") - .with_span_suggestion(attr_sp, + err.span_label(attr_sp, format!("the `#[{name}]` macro causes a function to be run as a test and has no effect on non-functions")); + + if !is_bench { + err.with_span_suggestion(attr_sp, "replace with conditional compilation to make the item only exist when tests are being run", "#[cfg(test)]", - Applicability::MaybeIncorrect) - .emit(); + Applicability::MaybeIncorrect).emit(); + } else { + err.emit(); + } } fn get_location_info(cx: &ExtCtxt<'_>, fn_: &ast::Fn) -> (Symbol, usize, usize, usize, usize) { diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs index 22b0454e17410..0f2d33e9d9390 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.rs +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -26,22 +26,22 @@ mod test { // non-crate-level #[bench] attributes seem to be ignored. #[bench] -//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +//~^ ERROR the `#[bench]` attribute may only be used on a non-associated function mod bench { mod inner { #![bench] } //~^ ERROR inner macro attributes are unstable - //~| ERROR the `#[test]` attribute may only be used on a non-associated function + //~| ERROR the `#[bench]` attribute may only be used on a non-associated function #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a non-associated function struct S; #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a non-associated function type T = S; #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a non-associated function impl S { } } diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr index 339a68f5d5e48..2e14dfcb0eefa 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.stderr +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -87,11 +87,11 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a non-associated function --> $DIR/gating-of-test-attrs.rs:28:1 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | / mod bench { LL | | mod inner { #![bench] } @@ -99,12 +99,6 @@ LL | | mod inner { #![bench] } LL | | impl S { } LL | | } | |_- expected a non-associated function, found a module - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | error[E0658]: inner macro attributes are unstable --> $DIR/gating-of-test-attrs.rs:31:20 @@ -116,65 +110,41 @@ LL | mod inner { #![bench] } = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a non-associated function --> $DIR/gating-of-test-attrs.rs:31:17 | LL | mod inner { #![bench] } | ------------^^^^^^^^^-- | | | - | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | | the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions | expected a non-associated function, found a module - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - mod inner { #![bench] } -LL + mod inner { #[cfg(test)] } - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a non-associated function --> $DIR/gating-of-test-attrs.rs:35:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | struct S; | --------- expected a non-associated function, found a struct - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a non-associated function --> $DIR/gating-of-test-attrs.rs:39:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | type T = S; | ----------- expected a non-associated function, found a type alias - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a non-associated function --> $DIR/gating-of-test-attrs.rs:43:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | impl S { } | ---------- expected a non-associated function, found an implementation - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | error: aborting due to 12 previous errors diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr index 5a5e0597284d3..bf24dc8cb11a8 100644 --- a/tests/ui/macros/test-on-crate-root.stderr +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -1,5 +1,5 @@ error[E0658]: inner macro attributes are unstable - --> $DIR/test-on-crate-root.rs:3:4 + --> $DIR/test-on-crate-root.rs:4:4 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![core::prelude::v1::test] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: the `#[test]` attribute may only be used on a non-associated function - --> $DIR/test-on-crate-root.rs:3:1 + --> $DIR/test-on-crate-root.rs:4:1 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions