Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled diff
생성일
7개월 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
2 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
657 행
복사
2 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
657 행
복사
복사
복사됨
복사
복사됨
From
552d971ea849519a743457cc52a16f8d11e57539
Mon Sep 17 00:00:00 2001
From
1864bf6a510a7e9df23777591f3389b6feb27e90
Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl>
From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl>
Date: Sat, 18 Oct 2025 11:25:13 +0200
Date: Sat, 18 Oct 2025 11:25:13 +0200
Subject: [PATCH 1/3] ICE when applying test to crate root
Subject: [PATCH 1/3] ICE when applying test to crate root
---
---
tests/crashes/114920.rs | 2 --
tests/crashes/114920.rs | 2 --
tests/ui/macros/test-on-crate-root.rs | 8 ++++++++
tests/ui/macros/test-on-crate-root.rs | 8 ++++++++
2 files changed, 8 insertions(+), 2 deletions(-)
2 files changed, 8 insertions(+), 2 deletions(-)
delete mode 100644 tests/crashes/114920.rs
delete mode 100644 tests/crashes/114920.rs
create mode 100644 tests/ui/macros/test-on-crate-root.rs
create mode 100644 tests/ui/macros/test-on-crate-root.rs
diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs
diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs
deleted file mode 100644
deleted file mode 100644
index 9aa7598e10fc3..0000000000000
index 9aa7598e10fc3..0000000000000
--- a/tests/crashes/114920.rs
--- a/tests/crashes/114920.rs
+++ /dev/null
+++ /dev/null
@@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
-//@ known-bug: #114920
-//@ known-bug: #114920
-#![core::prelude::v1::test]
-#![core::prelude::v1::test]
diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs
diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs
new file mode 100644
new file mode 100644
index 0000000000000..80635a458902d
index 0000000000000..80635a458902d
--- /dev/null
--- /dev/null
+++ b/tests/ui/macros/test-on-crate-root.rs
+++ b/tests/ui/macros/test-on-crate-root.rs
@@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
+// ICE when applying `#![test]` to the crate root,
+// ICE when applying `#![test]` to the crate root,
+// though only when specified with a full path. `#![test]` is not enough.
+// though only when specified with a full path. `#![test]` is not enough.
+// Fixes #114920
+// Fixes #114920
+#![core::prelude::v1::test]
+#![core::prelude::v1::test]
+
+
+
+
+
+
+fn main() {} // not important to reproduce the issue
+fn main() {} // not important to reproduce the issue
복사
복사됨
복사
복사됨
From
00b0d26f447d7c62a05414267984f7086a6df5f5
Mon Sep 17 00:00:00 2001
From
9dd3caeebefbb36f90ea13e5ec4b37048067ca59
Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl>
From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl>
Date: Sat, 18 Oct 2025 12:10:21 +0200
Date: Sat, 18 Oct 2025 12:10:21 +0200
Subject: [PATCH 2/3] only discard items with `#[test]` on it when target is
Subject: [PATCH 2/3] only discard items with `#[test]` on it when target is
valid
valid
---
---
compiler/rustc_builtin_macros/src/test.rs | 20 +-
compiler/rustc_builtin_macros/src/test.rs | 20 +-
.../ui/feature-gates/gating-of-test-attrs.rs | 48 +++
.../ui/feature-gates/gating-of-test-attrs.rs | 48 +++
.../feature-gates/gating-of-test-attrs.stderr | 181 +++++++++++
.../feature-gates/gating-of-test-attrs.stderr | 181 +++++++++++
.../issue-43106-gating-of-builtin-attrs.rs | 32 --
.../issue-43106-gating-of-builtin-attrs.rs | 32 --
...issue-43106-gating-of-builtin-attrs.stderr | 304 +++++++++---------
...issue-43106-gating-of-builtin-attrs.stderr | 304 +++++++++---------
tests/ui/macros/attr-empty-expr.rs | 11 -
tests/ui/macros/attr-empty-expr.rs | 11 -
tests/ui/macros/attr-empty-expr.stderr | 20 --
tests/ui/macros/attr-empty-expr.stderr | 20 --
tests/ui/macros/issue-111749.rs | 4 +-
tests/ui/macros/issue-111749.rs | 4 +-
tests/ui/macros/issue-111749.stderr | 16 +-
tests/ui/macros/issue-111749.stderr | 16 +-
tests/ui/macros/test-on-crate-root.rs | 3 +-
tests/ui/macros/test-on-crate-root.rs | 3 +-
tests/ui/macros/test-on-crate-root.stderr | 25 ++
tests/ui/macros/test-on-crate-root.stderr | 25 ++
11 files changed, 431 insertions(+), 233 deletions(-)
11 files changed, 431 insertions(+), 233 deletions(-)
create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.rs
create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.rs
create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.stderr
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.rs
delete mode 100644 tests/ui/macros/attr-empty-expr.stderr
delete mode 100644 tests/ui/macros/attr-empty-expr.stderr
create mode 100644 tests/ui/macros/test-on-crate-root.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
diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs
index 532539f893aed..8f6244e418fdb 100644
index 532539f893aed..8f6244e418fdb 100644
--- a/compiler/rustc_builtin_macros/src/test.rs
--- a/compiler/rustc_builtin_macros/src/test.rs
+++ b/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(
@@ -34,10 +34,6 @@ pub(crate) fn expand_test_case(
check_builtin_macro_attribute(ecx, meta_item, sym::test_case);
check_builtin_macro_attribute(ecx, meta_item, sym::test_case);
warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case);
warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case);
- if !ecx.ecfg.should_test {
- if !ecx.ecfg.should_test {
- return vec![];
- return vec![];
- }
- }
-
-
let sp = ecx.with_def_site_ctxt(attr_sp);
let sp = ecx.with_def_site_ctxt(attr_sp);
let (mut item, is_stmt) = match anno_item {
let (mut item, is_stmt) = match anno_item {
Annotatable::Item(item) => (item, false),
Annotatable::Item(item) => (item, false),
@@ -54,6 +50,10 @@ pub(crate) fn expand_test_case(
@@ -54,6 +50,10 @@ pub(crate) fn expand_test_case(
}
}
};
};
+ if !ecx.ecfg.should_test {
+ if !ecx.ecfg.should_test {
+ return vec![];
+ return vec![];
+ }
+ }
+
+
// `#[test_case]` is valid on functions, consts, and statics. Only modify
// `#[test_case]` is valid on functions, consts, and statics. Only modify
// the item in those cases.
// the item in those cases.
match &mut item.kind {
match &mut item.kind {
@@ -113,11 +113,6 @@ pub(crate) fn expand_test_or_bench(
@@ -113,11 +113,6 @@ pub(crate) fn expand_test_or_bench(
item: Annotatable,
item: Annotatable,
is_bench: bool,
is_bench: bool,
) -> Vec<Annotatable> {
) -> Vec<Annotatable> {
- // If we're not in test configuration, remove the annotated item
- // If we're not in test configuration, remove the annotated item
- if !cx.ecfg.should_test {
- if !cx.ecfg.should_test {
- return vec![];
- return vec![];
- }
- }
-
-
let (item, is_stmt) = match item {
let (item, is_stmt) = match item {
Annotatable::Item(i) => (i, false),
Annotatable::Item(i) => (i, false),
Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true),
Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true),
@@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench(
@@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench(
};
};
};
};
+ // If we're not in test configuration, remove the annotated item
+ // If we're not in test configuration, remove the annotated item
+ if !cx.ecfg.should_test {
+ if !cx.ecfg.should_test {
+ return vec![];
+ return vec![];
+ }
+ }
+
+
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
testing_span: attr_sp,
testing_span: attr_sp,
@@ -407,7 +407,7 @@ pub(crate) fn expand_test_or_bench(
@@ -407,7 +407,7 @@ 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<'_>, attr_sp: Span, item: Option<&ast::Item>) {
let dcx = cx.dcx();
let dcx = cx.dcx();
- let msg = "the `#[test]` attribute may only be used on a non-associated function";
- let msg = "the `#[test]` attribute may only be used on a non-associated function";
+ let msg = "the `#[test]` attribute may only be used on a free function";
+ let msg = "the `#[test]` attribute may only be used on a free function";
let level = match item.map(|i| &i.kind) {
let level = match item.map(|i| &i.kind) {
// These were a warning before #92959 and need to continue being that to avoid breaking
// These were a warning before #92959 and need to continue being that to avoid breaking
// stable user code (#94508).
// stable user code (#94508).
diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs
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
new file mode 100644
index 0000000000000..22b0454e17410
index 0000000000000..22b0454e17410
--- /dev/null
--- /dev/null
+++ b/tests/ui/feature-gates/gating-of-test-attrs.rs
+++ b/tests/ui/feature-gates/gating-of-test-attrs.rs
@@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
+#![feature(test)]
+#![feature(test)]
+
+
+// test is a built-in macro, not a built-in attribute, but it kind of acts like both.
+// test is a built-in macro, not a built-in attribute, but it kind of acts like both.
+// check its target checking anyway here
+// check its target checking anyway here
+#[test]
+#[test]
+//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+mod test {
+mod test {
+ mod inner { #![test] }
+ mod inner { #![test] }
+ //~^ ERROR inner macro attributes are unstable
+ //~^ ERROR inner macro attributes are unstable
+ //~| ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~| ERROR the `#[test]` attribute may only be used on a non-associated function
+
+
+ #[test]
+ #[test]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ struct S;
+ struct S;
+
+
+ #[test]
+ #[test]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ type T = S;
+ type T = S;
+
+
+ #[test]
+ #[test]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ impl S { }
+ impl S { }
+}
+}
+
+
+// At time of unit test authorship, if compiling without `--test` then
+// At time of unit test authorship, if compiling without `--test` then
+// non-crate-level #[bench] attributes seem to be ignored.
+// non-crate-level #[bench] attributes seem to be ignored.
+
+
+#[bench]
+#[bench]
+//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+mod bench {
+mod bench {
+ mod inner { #![bench] }
+ mod inner { #![bench] }
+ //~^ ERROR inner macro attributes are unstable
+ //~^ ERROR inner macro attributes are unstable
+ //~| ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~| ERROR the `#[test]` attribute may only be used on a non-associated function
+
+
+ #[bench]
+ #[bench]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ struct S;
+ struct S;
+
+
+ #[bench]
+ #[bench]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ type T = S;
+ type T = S;
+
+
+ #[bench]
+ #[bench]
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ //~^ ERROR the `#[test]` attribute may only be used on a non-associated function
+ impl S { }
+ impl S { }
+}
+}
+
+
+fn main() {}
+fn main() {}
diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr
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
new file mode 100644
index 0000000000000..339a68f5d5e48
index 0000000000000..339a68f5d5e48
--- /dev/null
--- /dev/null
+++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr
+++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr
@@ -0,0 +1,181 @@
@@ -0,0 +1,181 @@
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:5:1
+ --> $DIR/gating-of-test-attrs.rs:5:1
+ |
+ |
+LL | #[test]
+LL | #[test]
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | / mod test {
+LL | / mod test {
+LL | | mod inner { #![test] }
+LL | | mod inner { #![test] }
+... |
+... |
+LL | | impl S { }
+LL | | impl S { }
+LL | | }
+LL | | }
+ | |_- expected a non-associated function, found a module
+ | |_- expected a non-associated function, found a module
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[test]
+LL - #[test]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error[E0658]: inner macro attributes are unstable
+error[E0658]: inner macro attributes are unstable
+ --> $DIR/gating-of-test-attrs.rs:8:20
+ --> $DIR/gating-of-test-attrs.rs:8:20
+ |
+ |
+LL | mod inner { #![test] }
+LL | mod inner { #![test] }
+ | ^^^^
+ | ^^^^
+ |
+ |
+ = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
+ = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
+ = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
+ = 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
+ = 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 `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:8:17
+ --> $DIR/gating-of-test-attrs.rs:8:17
+ |
+ |
+LL | mod inner { #![test] }
+LL | mod inner { #![test] }
+ | ------------^^^^^^^^--
+ | ------------^^^^^^^^--
+ | | |
+ | | |
+ | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | | 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
+ | expected a non-associated function, found a module
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - mod inner { #![test] }
+LL - mod inner { #![test] }
+LL + mod inner { #[cfg(test)] }
+LL + mod inner { #[cfg(test)] }
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:12:5
+ --> $DIR/gating-of-test-attrs.rs:12:5
+ |
+ |
+LL | #[test]
+LL | #[test]
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | struct S;
+LL | struct S;
+ | --------- expected a non-associated function, found a struct
+ | --------- expected a non-associated function, found a struct
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[test]
+LL - #[test]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:16:5
+ --> $DIR/gating-of-test-attrs.rs:16:5
+ |
+ |
+LL | #[test]
+LL | #[test]
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | type T = S;
+LL | type T = S;
+ | ----------- expected a non-associated function, found a type alias
+ | ----------- 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
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[test]
+LL - #[test]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:20:5
+ --> $DIR/gating-of-test-attrs.rs:20:5
+ |
+ |
+LL | #[test]
+LL | #[test]
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | impl S { }
+LL | impl S { }
+ | ---------- expected a non-associated function, found an implementation
+ | ---------- expected a non-associated function, found an implementation
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[test]
+LL - #[test]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:28:1
+ --> $DIR/gating-of-test-attrs.rs:28:1
+ |
+ |
+LL | #[bench]
+LL | #[bench]
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | / mod bench {
+LL | / mod bench {
+LL | | mod inner { #![bench] }
+LL | | mod inner { #![bench] }
+... |
+... |
+LL | | impl S { }
+LL | | impl S { }
+LL | | }
+LL | | }
+ | |_- expected a non-associated function, found a module
+ | |_- expected a non-associated function, found a module
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[bench]
+LL - #[bench]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error[E0658]: inner macro attributes are unstable
+error[E0658]: inner macro attributes are unstable
+ --> $DIR/gating-of-test-attrs.rs:31:20
+ --> $DIR/gating-of-test-attrs.rs:31:20
+ |
+ |
+LL | mod inner { #![bench] }
+LL | mod inner { #![bench] }
+ | ^^^^^
+ | ^^^^^
+ |
+ |
+ = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
+ = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
+ = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
+ = 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
+ = 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 `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:31:17
+ --> $DIR/gating-of-test-attrs.rs:31:17
+ |
+ |
+LL | mod inner { #![bench] }
+LL | mod inner { #![bench] }
+ | ------------^^^^^^^^^--
+ | ------------^^^^^^^^^--
+ | | |
+ | | |
+ | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | | 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
+ | expected a non-associated function, found a module
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - mod inner { #![bench] }
+LL - mod inner { #![bench] }
+LL + mod inner { #[cfg(test)] }
+LL + mod inner { #[cfg(test)] }
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:35:5
+ --> $DIR/gating-of-test-attrs.rs:35:5
+ |
+ |
+LL | #[bench]
+LL | #[bench]
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | struct S;
+LL | struct S;
+ | --------- expected a non-associated function, found a struct
+ | --------- expected a non-associated function, found a struct
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[bench]
+LL - #[bench]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:39:5
+ --> $DIR/gating-of-test-attrs.rs:39:5
+ |
+ |
+LL | #[bench]
+LL | #[bench]
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | type T = S;
+LL | type T = S;
+ | ----------- expected a non-associated function, found a type alias
+ | ----------- 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
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[bench]
+LL - #[bench]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: the `#[test]` attribute may only be used on a non-associated function
+error: the `#[test]` attribute may only be used on a non-associated function
+ --> $DIR/gating-of-test-attrs.rs:43:5
+ --> $DIR/gating-of-test-attrs.rs:43:5
+ |
+ |
+LL | #[bench]
+LL | #[bench]
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+ | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
+LL |
+LL |
+LL | impl S { }
+LL | impl S { }
+ | ---------- expected a non-associated function, found an implementation
+ | ---------- expected a non-associated function, found an implementation
+ |
+ |
+help: replace with conditional compilation to make the item only exist when tests are being run
+help: replace with conditional compilation to make the item only exist when tests are being run
+ |
+ |
+LL - #[bench]
+LL - #[bench]
+LL + #[cfg(test)]
+LL + #[cfg(test)]
+ |
+ |
+
+
+error: aborting due to 12 previous errors
+error: aborting due to 12 previous errors
+
+
+For more information about this error, try `rustc --explain E0658`.
+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
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 8d67bf37279df..5b32c5ca0dfa5 100644
index 8d67bf37279df..5b32c5ca0dfa5 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
+++ b/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 {
@@ -250,38 +250,6 @@ mod macro_export {
//~| HELP remove the attribute
//~| HELP remove the attribute
}
}
-// At time of unit test authorship, if compiling without `--test` then
-// At time of unit test authorship, if compiling without `--test` then
-// non-crate-level #[test] attributes seem to be ignored.
-// non-crate-level #[test] attributes seem to be ignored.
-
-
-#[test]
-#[test]
-mod test { mod inner { #![test] }
-mod test { mod inner { #![test] }
-
-
- fn f() { }
- fn f() { }
-
-
- struct S;
- struct S;
-
-
- type T = S;
- type T = S;
-
-
- impl S { }
- impl S { }
-}
-}
-
-
-// At time of unit test authorship, if compiling without `--test` then
-// At time of unit test authorship, if compiling without `--test` then
-// non-crate-level #[bench] attributes seem to be ignored.
-// non-crate-level #[bench] attributes seem to be ignored.
-
-
-#[bench]
-#[bench]
-mod bench {
-mod bench {
- mod inner { #![bench] }
- mod inner { #![bench] }
-
-
- #[bench]
- #[bench]
- struct S;
- struct S;
-
-
- #[bench]
- #[bench]
- type T = S;
- type T = S;
-
-
- #[bench]
- #[bench]
- impl S { }
- impl S { }
-}
-}
-
-
#[path = "3800"]
#[path = "3800"]
mod path {
mod path {
mod inner { #![path="3800"] }
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
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 f7e8d9c7c4001..d8b1dc91acc4f 100644
index f7e8d9c7c4001..d8b1dc91acc4f 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
+++ b/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 @@
@@ -1,5 +1,5 @@
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
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:529:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:17
|
|
LL | mod inner { #![macro_escape] }
LL | mod inner { #![macro_escape] }
| ^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL | mod inner { #![macro_escape] }
@@ -7,7 +7,7 @@ LL | mod inner { #![macro_escape] }
= help: try an outer attribute: `#[macro_use]`
= help: try an outer attribute: `#[macro_use]`
warning: `#[macro_escape]` is a deprecated synonym for `#[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:526:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1
|
|
LL | #[macro_escape]
LL | #[macro_escape]
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
@@ -187,7 +187,7 @@ LL | #[deny(x5100)] impl S { }
@@ -187,7 +187,7 @@ LL | #[deny(x5100)] impl S { }
| ^^^^^
| ^^^^^
warning: crate-level attribute should be an inner attribute
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:501:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:1
|
|
LL | #[reexport_test_harness_main = "2900"]
LL | #[reexport_test_harness_main = "2900"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -203,7 +203,7 @@ 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
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:739:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1
|
|
LL | #[link(name = "x")]
LL | #[link(name = "x")]
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^
@@ -219,7 +219,7 @@ LL | | }
@@ -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: 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
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:865:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1
|
|
LL | #[crate_type = "0800"]
LL | #[crate_type = "0800"]
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -230,7 +230,7 @@ LL | #![crate_type = "0800"]
@@ -230,7 +230,7 @@ LL | #![crate_type = "0800"]
| +
| +
warning: crate-level attribute should be an inner attribute
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:889:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1
|
|
LL | #[feature(x0600)]
LL | #[feature(x0600)]
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
@@ -241,7 +241,7 @@ LL | #![feature(x0600)]
@@ -241,7 +241,7 @@ LL | #![feature(x0600)]
| +
| +
warning: crate-level attribute should be an inner attribute
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:914:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:882:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:882:1
|
|
LL | #[no_main]
LL | #[no_main]
| ^^^^^^^^^^
| ^^^^^^^^^^
@@ -252,7 +252,7 @@ LL | #![no_main]
@@ -252,7 +252,7 @@ LL | #![no_main]
| +
| +
warning: crate-level attribute should be an inner attribute
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:938:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:1
|
|
LL | #[no_builtins]
LL | #[no_builtins]
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^
@@ -279,13 +279,13 @@ LL | #![feature(rust1)]
@@ -279,13 +279,13 @@ LL | #![feature(rust1)]
= note: `#[warn(stable_features)]` on by default
= note: `#[warn(stable_features)]` on by default
warning: crate-level attribute should be in the root module
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:505:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:17
|
|
LL | mod inner { #![reexport_test_harness_main="2900"] }
LL | mod inner { #![reexport_test_harness_main="2900"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute
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:508:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5
|
|
LL | #[reexport_test_harness_main = "2900"] fn f() { }
LL | #[reexport_test_harness_main = "2900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -296,7 +296,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { }
@@ -296,7 +296,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { }
| +
| +
warning: crate-level attribute should be an inner attribute
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:512:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:5
|
|
LL | #[reexport_test_harness_main = "2900"] struct S;
LL | #[reexport_test_harness_main = "2900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S;
@@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:516:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5
|
|
LL | #[reexport_test_harness_main = "2900"] type T = S;
LL | #[reexport_test_harness_main = "2900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S;
@@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:520:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5
|
|
LL | #[reexport_test_harness_main = "2900"] impl S { }
LL | #[reexport_test_harness_main = "2900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { }
@@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { }
| +
| +
warning: attribute should be applied to an `extern` block with non-Rust ABI
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:745:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:17
|
|
LL | mod inner { #![link(name = "x")] }
LL | mod inner { #![link(name = "x")] }
| ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block
| ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block
@@ -337,7 +337,7 @@ LL | mod inner { #![link(name = "x")] }
@@ -337,7 +337,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: 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
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:750:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5
|
|
LL | #[link(name = "x")] fn f() { }
LL | #[link(name = "x")] fn f() { }
| ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
| ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
@@ -345,7 +345,7 @@ LL | #[link(name = "x")] fn f() { }
@@ -345,7 +345,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: 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
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:755:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5
|
|
LL | #[link(name = "x")] struct S;
LL | #[link(name = "x")] struct S;
| ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block
| ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block
@@ -353,7 +353,7 @@ LL | #[link(name = "x")] struct S;
@@ -353,7 +353,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: 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
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:760:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5
|
|
LL | #[link(name = "x")] type T = S;
LL | #[link(name = "x")] type T = S;
| ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block
| ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block
@@ -361,7 +361,7 @@ LL | #[link(name = "x")] type T = S;
@@ -361,7 +361,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: 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
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:765:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5
|
|
LL | #[link(name = "x")] impl S { }
LL | #[link(name = "x")] impl S { }
| ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
| ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
@@ -369,7 +369,7 @@ LL | #[link(name = "x")] impl S { }
@@ -369,7 +369,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: 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
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:770:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:5
|
|
LL | #[link(name = "x")] extern "Rust" {}
LL | #[link(name = "x")] extern "Rust" {}
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^
@@ -377,13 +377,13 @@ LL | #[link(name = "x")] extern "Rust" {}
@@ -377,13 +377,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: 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
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:869:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:837:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:837:17
|
|
LL | mod inner { #![crate_type="0800"] }
LL | mod inner { #![crate_type="0800"] }
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute
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:872:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5
|
|
LL | #[crate_type = "0800"] fn f() { }
LL | #[crate_type = "0800"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -394,7 +394,7 @@ LL | #![crate_type = "0800"] fn f() { }
@@ -394,7 +394,7 @@ LL | #![crate_type = "0800"] fn f() { }
| +
| +
warning: crate-level attribute should be an inner attribute
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:876:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:5
|
|
LL | #[crate_type = "0800"] struct S;
LL | #[crate_type = "0800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -405,7 +405,7 @@ LL | #![crate_type = "0800"] struct S;
@@ -405,7 +405,7 @@ LL | #![crate_type = "0800"] struct S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:880:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5
|
|
LL | #[crate_type = "0800"] type T = S;
LL | #[crate_type = "0800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -416,7 +416,7 @@ LL | #![crate_type = "0800"] type T = S;
@@ -416,7 +416,7 @@ LL | #![crate_type = "0800"] type T = S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:884:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5
|
|
LL | #[crate_type = "0800"] impl S { }
LL | #[crate_type = "0800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -427,13 +427,13 @@ LL | #![crate_type = "0800"] impl S { }
@@ -427,13 +427,13 @@ LL | #![crate_type = "0800"] impl S { }
| +
| +
warning: crate-level attribute should be in the root module
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:893:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:861:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:861:17
|
|
LL | mod inner { #![feature(x0600)] }
LL | mod inner { #![feature(x0600)] }
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute
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:896:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5
|
|
LL | #[feature(x0600)] fn f() { }
LL | #[feature(x0600)] fn f() { }
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
@@ -444,7 +444,7 @@ LL | #![feature(x0600)] fn f() { }
@@ -444,7 +444,7 @@ LL | #![feature(x0600)] fn f() { }
| +
| +
warning: crate-level attribute should be an inner attribute
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:900:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5
|
|
LL | #[feature(x0600)] struct S;
LL | #[feature(x0600)] struct S;
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
@@ -455,7 +455,7 @@ LL | #![feature(x0600)] struct S;
@@ -455,7 +455,7 @@ LL | #![feature(x0600)] struct S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:904:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5
|
|
LL | #[feature(x0600)] type T = S;
LL | #[feature(x0600)] type T = S;
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
@@ -466,7 +466,7 @@ LL | #![feature(x0600)] type T = S;
@@ -466,7 +466,7 @@ LL | #![feature(x0600)] type T = S;
| +
| +
warning: crate-level attribute should be an inner attribute
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:908:5
+ --> $DIR/issue-43106-gating-of-builtin-att
+ --> $DIR/issue-43106-gating-of-builtin-att
저장된 비교 결과
원본
파일 열기
From 552d971ea849519a743457cc52a16f8d11e57539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 00b0d26f447d7c62a05414267984f7086a6df5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 | 20 +- .../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 | 304 +++++++++--------- 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, 431 insertions(+), 233 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 532539f893aed..8f6244e418fdb 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<Annotatable> { - // 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, @@ -407,7 +407,7 @@ pub(crate) fn expand_test_or_bench( fn not_testable_error(cx: &ExtCtxt<'_>, 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 msg = "the `#[test]` attribute may only be used on a free 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). 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 8d67bf37279df..5b32c5ca0dfa5 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 f7e8d9c7c4001..d8b1dc91acc4f 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:865:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,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)] | ^^^^^^^^^^^^^^^^^ @@ -241,7 +241,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] | ^^^^^^^^^^ @@ -252,7 +252,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] | ^^^^^^^^^^^^^^ @@ -279,13 +279,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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,7 +296,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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,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 @@ -337,7 +337,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 @@ -345,7 +345,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 @@ -353,7 +353,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 @@ -361,7 +361,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 @@ -369,7 +369,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" {} | ^^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,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: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() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -394,7 +394,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,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 { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -427,13 +427,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() { } | ^^^^^^^^^^^^^^^^^ @@ -444,7 +444,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; | ^^^^^^^^^^^^^^^^^ @@ -455,7 +455,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; | ^^^^^^^^^^^^^^^^^ @@ -466,7 +466,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 { } | ^^^^^^^^^^^^^^^^^ @@ -477,13 +477,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() { } | ^^^^^^^^^^ @@ -494,7 +494,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; | ^^^^^^^^^^ @@ -505,7 +505,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; | ^^^^^^^^^^ @@ -516,7 +516,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 { } | ^^^^^^^^^^ @@ -527,13 +527,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() { } | ^^^^^^^^^^^^^^ @@ -544,7 +544,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; | ^^^^^^^^^^^^^^ @@ -555,7 +555,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; | ^^^^^^^^^^^^^^ @@ -566,7 +566,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 { } | ^^^^^^^^^^^^^^ @@ -667,7 +667,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() { } | ^^^^^^^^^^^^^^^^ @@ -676,7 +676,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; | ^^^^^^^^^^^^^^^^ @@ -685,7 +685,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; | ^^^^^^^^^^^^^^^^ @@ -694,7 +694,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 { } | ^^^^^^^^^^^^^^^^ @@ -703,7 +703,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] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -712,7 +712,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] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -730,7 +730,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -739,7 +739,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -748,7 +748,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -757,7 +757,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -766,7 +766,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] | ^^^^^^^^^^^^ @@ -775,7 +775,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] } | ^^^^^^^^^^^^^ @@ -784,7 +784,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; | ^^^^^^^^^^^^ @@ -793,7 +793,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; | ^^^^^^^^^^^^ @@ -802,7 +802,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 { } | ^^^^^^^^^^^^ @@ -811,7 +811,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(); | ^^^^^^^^^^^^ @@ -820,7 +820,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() {} | ^^^^^^^^^^^^ @@ -829,7 +829,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] | ^^^^^^^^^^^^^^^ @@ -838,7 +838,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] } | ^^^^^^^^^^^^^^^^ @@ -847,7 +847,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; | ^^^^^^^^^^^^^^^ @@ -856,7 +856,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; | ^^^^^^^^^^^^^^^ @@ -865,7 +865,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 { } | ^^^^^^^^^^^^^^^ @@ -874,7 +874,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] | ^^^^^^^^^ @@ -883,7 +883,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] } | ^^^^^^^^^^ @@ -892,7 +892,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; | ^^^^^^^^^ @@ -901,7 +901,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; | ^^^^^^^^^ @@ -910,7 +910,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 { } | ^^^^^^^^^ @@ -919,7 +919,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() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -928,7 +928,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -937,7 +937,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -946,7 +946,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 { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -955,7 +955,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() { } | ^^^^^^^^^^^^^^^ @@ -964,7 +964,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; | ^^^^^^^^^^^^^^^ @@ -973,7 +973,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; | ^^^^^^^^^^^^^^^ @@ -982,7 +982,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 { } | ^^^^^^^^^^^^^^^ @@ -991,13 +991,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 | | @@ -1007,61 +1007,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] | ^^^^^^^ @@ -1070,7 +1070,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] } | ^^^^^^^^ @@ -1079,7 +1079,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; | ^^^^^^^ @@ -1088,7 +1088,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; | ^^^^^^^ @@ -1097,7 +1097,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 { } | ^^^^^^^ @@ -1106,7 +1106,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"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1115,7 +1115,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"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1124,7 +1124,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"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1133,7 +1133,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() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1142,7 +1142,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; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1151,7 +1151,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; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1160,7 +1160,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 { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1169,7 +1169,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"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1178,7 +1178,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"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1187,7 +1187,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1196,7 +1196,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1205,7 +1205,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1214,7 +1214,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"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1223,7 +1223,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] | ^^^^^^^^^^^ @@ -1232,7 +1232,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] } | ^^^^^^^^^^^^ @@ -1241,7 +1241,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; | ^^^^^^^^^^^ @@ -1250,7 +1250,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 { } | ^^^^^^^^^^^ @@ -1259,13 +1259,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: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:1 | LL | / mod windows_subsystem { LL | | @@ -1275,67 +1275,67 @@ LL | | } | |_^ warning: the `#![windows_subsystem]` attribute can only be used at the crate root - --> $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: add an exclamation mark: `#![windows_subsystem]` - --> $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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:38 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:38 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:38 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:38 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^ 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 | | @@ -1345,67 +1345,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 | | @@ -1415,67 +1415,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 | | @@ -1485,55 +1485,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 <https://github.com/rust-lang/rust/issues/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 1938841af6af299fc5d07142592434994ffa7f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 | 20 +++---- .../feature-gates/gating-of-test-attrs.stderr | 60 +++++-------------- tests/ui/macros/issue-111749.rs | 2 +- tests/ui/macros/issue-111749.stderr | 2 +- tests/ui/macros/test-on-crate-root.rs | 2 +- tests/ui/macros/test-on-crate-root.stderr | 6 +- tests/ui/test-attrs/issue-109816.rs | 2 +- tests/ui/test-attrs/issue-109816.stderr | 2 +- .../test-attr-non-associated-functions.rs | 4 +- .../test-attr-non-associated-functions.stderr | 4 +- tests/ui/test-attrs/test-on-not-fn.rs | 24 ++++---- tests/ui/test-attrs/test-on-not-fn.stderr | 24 ++++---- 13 files changed, 74 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 8f6244e418fdb..f31ad4f591b1e 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 free function"; + let name = if is_bench { "bench" } else { "test" }; + let msg = format!("the `#[{name}]` attribute may only be used on a free 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..3b07e2ad03c9f 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.rs +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -3,22 +3,22 @@ // 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 +//~^ ERROR the `#[test]` attribute may only be used on a free 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 + //~| ERROR the `#[test]` attribute may only be used on a free function #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function type T = S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function impl S { } } @@ -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 free 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 free 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 free 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 free 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 free 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..0f47ab85dc18e 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.stderr +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:5:1 | LL | #[test] @@ -27,7 +27,7 @@ LL | mod inner { #![test] } = 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 `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:8:17 | LL | mod inner { #![test] } @@ -42,7 +42,7 @@ LL - mod inner { #![test] } LL + mod inner { #[cfg(test)] } | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:12:5 | LL | #[test] @@ -57,7 +57,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:16:5 | LL | #[test] @@ -72,7 +72,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:20:5 | LL | #[test] @@ -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 free 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 free 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 free 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 free 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 free 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/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 779a854ea5824..e92b9e4ccff82 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -6,7 +6,7 @@ macro_rules! cbor_map { fn main() { cbor_map! { #[test(test)] 4i32}; - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free 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 3afdd0ad4baff..ead01f87eaec0 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-111749.rs:8:17 | LL | cbor_map! { #[test(test)] 4i32}; diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index abe08536b1d68..0e0f3ec40976c 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -3,7 +3,7 @@ // 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 +//~| ERROR the `#[test]` attribute may only be used on a free 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 index 5a5e0597284d3..d706d6ae6c5fa 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] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,8 +8,8 @@ LL | #![core::prelude::v1::test] = 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 +error: the `#[test]` attribute may only be used on a free function + --> $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 diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs index 3cabf451c6635..c7caae67fefa6 100644 --- a/tests/ui/test-attrs/issue-109816.rs +++ b/tests/ui/test-attrs/issue-109816.rs @@ -2,6 +2,6 @@ fn align_offset_weird_strides() { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct A5(u32, u8); } diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr index 433421fff1b57..270f4e0a66683 100644 --- a/tests/ui/test-attrs/issue-109816.stderr +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-109816.rs:4:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 1a4dfda090970..4bf337d0f1b3c 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -4,12 +4,12 @@ struct A {} impl A { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn new() -> A { A {} } #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn recovery_witness() -> A { A {} } diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index 0ede0cbb97f33..13914971b558a 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:6:5 | LL | #[test] @@ -10,7 +10,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:11:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-on-not-fn.rs b/tests/ui/test-attrs/test-on-not-fn.rs index deba26f24ca71..16e9cd8d5b8d7 100644 --- a/tests/ui/test-attrs/test-on-not-fn.rs +++ b/tests/ui/test-attrs/test-on-not-fn.rs @@ -1,9 +1,9 @@ //@ compile-flags: --test -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod test {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod loooooooooooooong_teeeeeeeeeest { /* this is a comment @@ -17,37 +17,37 @@ mod loooooooooooooong_teeeeeeeeeest { */ } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function extern "C" {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function trait Foo {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function impl Foo for i32 {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function const FOO: i32 = -1_i32; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function static BAR: u64 = 10_000_u64; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function enum MyUnit { Unit, } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function struct NewI32(i32); -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function union Spooky { x: i32, y: u32, } #[repr(C, align(64))] -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function #[derive(Copy, Clone, Debug)] struct MoreAttrs { a: i32, @@ -58,7 +58,7 @@ macro_rules! foo { () => {}; } -#[test] //~ WARN: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ WARN: the `#[test]` attribute may only be used on a free function foo!(); // make sure it doesn't erroneously trigger on a real test diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index a282db012540a..db8bed100a635 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] @@ -12,7 +12,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] @@ -32,7 +32,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] @@ -46,7 +46,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] @@ -60,7 +60,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] @@ -74,7 +74,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] @@ -88,7 +88,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] @@ -102,7 +102,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] @@ -118,7 +118,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] @@ -132,7 +132,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] @@ -149,7 +149,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] @@ -167,7 +167,7 @@ LL - #[test] LL + #[cfg(test)] | -warning: the `#[test]` attribute may only be used on a non-associated function +warning: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test]
수정본
파일 열기
From 1864bf6a510a7e9df23777591f3389b6feb27e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 9dd3caeebefbb36f90ea13e5ec4b37048067ca59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 | 20 +- .../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 | 304 +++++++++--------- 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, 431 insertions(+), 233 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 532539f893aed..8f6244e418fdb 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<Annotatable> { - // 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, @@ -407,7 +407,7 @@ pub(crate) fn expand_test_or_bench( fn not_testable_error(cx: &ExtCtxt<'_>, 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 msg = "the `#[test]` attribute may only be used on a free 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). 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 8d67bf37279df..5b32c5ca0dfa5 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 f7e8d9c7c4001..d8b1dc91acc4f 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:865:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,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)] | ^^^^^^^^^^^^^^^^^ @@ -241,7 +241,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] | ^^^^^^^^^^ @@ -252,7 +252,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] | ^^^^^^^^^^^^^^ @@ -279,13 +279,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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,7 +296,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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,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 @@ -337,7 +337,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 @@ -345,7 +345,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 @@ -353,7 +353,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 @@ -361,7 +361,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 @@ -369,7 +369,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" {} | ^^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,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: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() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -394,7 +394,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,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 { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -427,13 +427,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() { } | ^^^^^^^^^^^^^^^^^ @@ -444,7 +444,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; | ^^^^^^^^^^^^^^^^^ @@ -455,7 +455,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; | ^^^^^^^^^^^^^^^^^ @@ -466,7 +466,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 { } | ^^^^^^^^^^^^^^^^^ @@ -477,13 +477,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() { } | ^^^^^^^^^^ @@ -494,7 +494,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; | ^^^^^^^^^^ @@ -505,7 +505,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; | ^^^^^^^^^^ @@ -516,7 +516,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 { } | ^^^^^^^^^^ @@ -527,13 +527,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() { } | ^^^^^^^^^^^^^^ @@ -544,7 +544,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; | ^^^^^^^^^^^^^^ @@ -555,7 +555,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; | ^^^^^^^^^^^^^^ @@ -566,7 +566,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 { } | ^^^^^^^^^^^^^^ @@ -667,7 +667,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() { } | ^^^^^^^^^^^^^^^^ @@ -676,7 +676,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; | ^^^^^^^^^^^^^^^^ @@ -685,7 +685,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; | ^^^^^^^^^^^^^^^^ @@ -694,7 +694,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 { } | ^^^^^^^^^^^^^^^^ @@ -703,7 +703,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] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -712,7 +712,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] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -730,7 +730,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -739,7 +739,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -748,7 +748,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -757,7 +757,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -766,7 +766,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] | ^^^^^^^^^^^^ @@ -775,7 +775,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] } | ^^^^^^^^^^^^^ @@ -784,7 +784,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; | ^^^^^^^^^^^^ @@ -793,7 +793,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; | ^^^^^^^^^^^^ @@ -802,7 +802,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 { } | ^^^^^^^^^^^^ @@ -811,7 +811,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(); | ^^^^^^^^^^^^ @@ -820,7 +820,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() {} | ^^^^^^^^^^^^ @@ -829,7 +829,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] | ^^^^^^^^^^^^^^^ @@ -838,7 +838,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] } | ^^^^^^^^^^^^^^^^ @@ -847,7 +847,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; | ^^^^^^^^^^^^^^^ @@ -856,7 +856,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; | ^^^^^^^^^^^^^^^ @@ -865,7 +865,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 { } | ^^^^^^^^^^^^^^^ @@ -874,7 +874,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] | ^^^^^^^^^ @@ -883,7 +883,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] } | ^^^^^^^^^^ @@ -892,7 +892,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; | ^^^^^^^^^ @@ -901,7 +901,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; | ^^^^^^^^^ @@ -910,7 +910,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 { } | ^^^^^^^^^ @@ -919,7 +919,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() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -928,7 +928,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -937,7 +937,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; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -946,7 +946,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 { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -955,7 +955,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() { } | ^^^^^^^^^^^^^^^ @@ -964,7 +964,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; | ^^^^^^^^^^^^^^^ @@ -973,7 +973,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; | ^^^^^^^^^^^^^^^ @@ -982,7 +982,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 { } | ^^^^^^^^^^^^^^^ @@ -991,13 +991,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 | | @@ -1007,61 +1007,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] | ^^^^^^^ @@ -1070,7 +1070,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] } | ^^^^^^^^ @@ -1079,7 +1079,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; | ^^^^^^^ @@ -1088,7 +1088,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; | ^^^^^^^ @@ -1097,7 +1097,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 { } | ^^^^^^^ @@ -1106,7 +1106,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"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1115,7 +1115,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"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1124,7 +1124,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"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1133,7 +1133,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() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1142,7 +1142,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; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1151,7 +1151,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; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1160,7 +1160,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 { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1169,7 +1169,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"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1178,7 +1178,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"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1187,7 +1187,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1196,7 +1196,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; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1205,7 +1205,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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1214,7 +1214,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"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1223,7 +1223,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] | ^^^^^^^^^^^ @@ -1232,7 +1232,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] } | ^^^^^^^^^^^^ @@ -1241,7 +1241,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; | ^^^^^^^^^^^ @@ -1250,7 +1250,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 { } | ^^^^^^^^^^^ @@ -1259,13 +1259,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: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:1 | LL | / mod windows_subsystem { LL | | @@ -1275,67 +1275,67 @@ LL | | } | |_^ warning: the `#![windows_subsystem]` attribute can only be used at the crate root - --> $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: add an exclamation mark: `#![windows_subsystem]` - --> $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() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:38 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:38 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:38 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $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 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:38 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^ 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 | | @@ -1345,67 +1345,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 | | @@ -1415,67 +1415,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 | | @@ -1485,55 +1485,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 <https://github.com/rust-lang/rust/issues/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 97d4d2154f4764a62710f2e2a0f3cd90b55adeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= <jana@donsz.nl> 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 | 20 +++---- .../feature-gates/gating-of-test-attrs.stderr | 60 +++++-------------- tests/ui/macros/issue-111749.rs | 2 +- tests/ui/macros/issue-111749.stderr | 2 +- tests/ui/macros/test-on-crate-root.rs | 2 +- tests/ui/macros/test-on-crate-root.stderr | 6 +- tests/ui/test-attrs/issue-109816.rs | 2 +- tests/ui/test-attrs/issue-109816.stderr | 2 +- .../test-attr-non-associated-functions.rs | 4 +- .../test-attr-non-associated-functions.stderr | 4 +- tests/ui/test-attrs/test-on-not-fn.rs | 24 ++++---- tests/ui/test-attrs/test-on-not-fn.stderr | 24 ++++---- 13 files changed, 74 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 8f6244e418fdb..f31ad4f591b1e 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 free function"; + let name = if is_bench { "bench" } else { "test" }; + let msg = format!("the `#[{name}]` attribute may only be used on a free 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..3b07e2ad03c9f 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.rs +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -3,22 +3,22 @@ // 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 +//~^ ERROR the `#[test]` attribute may only be used on a free 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 + //~| ERROR the `#[test]` attribute may only be used on a free function #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function type T = S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function impl S { } } @@ -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 free 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 free 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 free 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 free 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 free 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..0f47ab85dc18e 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.stderr +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:5:1 | LL | #[test] @@ -27,7 +27,7 @@ LL | mod inner { #![test] } = 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 `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:8:17 | LL | mod inner { #![test] } @@ -42,7 +42,7 @@ LL - mod inner { #![test] } LL + mod inner { #[cfg(test)] } | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:12:5 | LL | #[test] @@ -57,7 +57,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:16:5 | LL | #[test] @@ -72,7 +72,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:20:5 | LL | #[test] @@ -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 free 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 free 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 free 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 free 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 free 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/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 779a854ea5824..e92b9e4ccff82 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -6,7 +6,7 @@ macro_rules! cbor_map { fn main() { cbor_map! { #[test(test)] 4i32}; - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free 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 3afdd0ad4baff..ead01f87eaec0 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-111749.rs:8:17 | LL | cbor_map! { #[test(test)] 4i32}; diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index abe08536b1d68..0e0f3ec40976c 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -3,7 +3,7 @@ // 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 +//~| ERROR the `#[test]` attribute may only be used on a free 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 index 5a5e0597284d3..d706d6ae6c5fa 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] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,8 +8,8 @@ LL | #![core::prelude::v1::test] = 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 +error: the `#[test]` attribute may only be used on a free function + --> $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 diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs index 3cabf451c6635..c7caae67fefa6 100644 --- a/tests/ui/test-attrs/issue-109816.rs +++ b/tests/ui/test-attrs/issue-109816.rs @@ -2,6 +2,6 @@ fn align_offset_weird_strides() { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct A5(u32, u8); } diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr index 433421fff1b57..270f4e0a66683 100644 --- a/tests/ui/test-attrs/issue-109816.stderr +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-109816.rs:4:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 1a4dfda090970..4bf337d0f1b3c 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -4,12 +4,12 @@ struct A {} impl A { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn new() -> A { A {} } #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn recovery_witness() -> A { A {} } diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index 0ede0cbb97f33..13914971b558a 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:6:5 | LL | #[test] @@ -10,7 +10,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:11:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-on-not-fn.rs b/tests/ui/test-attrs/test-on-not-fn.rs index deba26f24ca71..16e9cd8d5b8d7 100644 --- a/tests/ui/test-attrs/test-on-not-fn.rs +++ b/tests/ui/test-attrs/test-on-not-fn.rs @@ -1,9 +1,9 @@ //@ compile-flags: --test -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod test {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod loooooooooooooong_teeeeeeeeeest { /* this is a comment @@ -17,37 +17,37 @@ mod loooooooooooooong_teeeeeeeeeest { */ } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function extern "C" {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function trait Foo {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function impl Foo for i32 {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function const FOO: i32 = -1_i32; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function static BAR: u64 = 10_000_u64; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function enum MyUnit { Unit, } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function struct NewI32(i32); -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function union Spooky { x: i32, y: u32, } #[repr(C, align(64))] -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function #[derive(Copy, Clone, Debug)] struct MoreAttrs { a: i32, @@ -58,7 +58,7 @@ macro_rules! foo { () => {}; } -#[test] //~ WARN: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ WARN: the `#[test]` attribute may only be used on a free function foo!(); // make sure it doesn't erroneously trigger on a real test diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index a282db012540a..db8bed100a635 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] @@ -12,7 +12,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] @@ -32,7 +32,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] @@ -46,7 +46,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] @@ -60,7 +60,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] @@ -74,7 +74,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] @@ -88,7 +88,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] @@ -102,7 +102,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] @@ -118,7 +118,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] @@ -132,7 +132,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] @@ -149,7 +149,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] @@ -167,7 +167,7 @@ LL - #[test] LL + #[cfg(test)] | -warning: the `#[test]` attribute may only be used on a non-associated function +warning: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test]
비교하기