Skip to content

Commit 0da3785

Browse files
Rollup merge of #152210 - Ozzy1423:attrs7, r=JonathanBrouwer
Gate #![reexport_test_harness_main] properly Address the FIXME Removed from `issue-43106-gating-of-builtin-attrs.rs` since that is for stable attributes only. This would be a breaking change, search of github shows it is mostly but not always used with `#![test_runner]` which is already gated correctly. Details: #50297 Feel free to close this issue if you think it is not worth addressing the FIXME...
2 parents 65a7e52 + 4af572d commit 0da3785

7 files changed

Lines changed: 236 additions & 313 deletions

File tree

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
473473
),
474474
FutureWarnFollowing, EncodeCrossCrate::No,
475475
),
476-
// FIXME(Centril): This can be used on stable but shouldn't.
477-
ungated!(
478-
reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing,
479-
EncodeCrossCrate::No,
480-
),
481476

482477
// Macros:
483478
ungated!(
@@ -831,6 +826,13 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
831826
EncodeCrossCrate::Yes, custom_test_frameworks,
832827
"custom test frameworks are an unstable feature",
833828
),
829+
830+
gated!(
831+
reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing,
832+
EncodeCrossCrate::No, custom_test_frameworks,
833+
"custom test frameworks are an unstable feature",
834+
),
835+
834836
// RFC #1268
835837
gated!(
836838
marker, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,

src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
124124
should_panic, Normal,
125125
template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason"), FutureWarnFollowing,
126126
),
127-
// FIXME(Centril): This can be used on stable but shouldn't.
128-
ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing),
129127

130128
// Macros:
131129
ungated!(automatically_derived, Normal, template!(Word), WarnFollowing),
@@ -264,6 +262,13 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
264262
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
265263
"custom test frameworks are an unstable feature",
266264
),
265+
266+
gated!(
267+
reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"),
268+
ErrorFollowing, custom_test_frameworks,
269+
"custom test frameworks are an unstable feature",
270+
),
271+
267272
// RFC #1268
268273
gated!(
269274
marker, Normal, template!(Word), WarnFollowing, @only_local: true,

tests/ui/attributes/reexport-test-harness-entry-point.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//@ run-pass
55
//@ compile-flags:--test
66

7+
#![feature(custom_test_frameworks)]
78
#![reexport_test_harness_main = "test_main"]
89

910
#[cfg(test)]

tests/ui/feature-gates/feature-gate-custom_test_frameworks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![test_runner(main)] //~ ERROR custom test frameworks are an unstable feature
2-
2+
#![reexport_test_harness_main = "foo"] //~ ERROR custom test frameworks are an unstable feature
33
#[test_case] //~ ERROR custom test frameworks are an unstable feature
44
fn f() {}
55

tests/ui/feature-gates/feature-gate-custom_test_frameworks.stderr

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ LL | #![test_runner(main)]
1818
= help: add `#![feature(custom_test_frameworks)]` to the crate attributes to enable
1919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020

21-
error: aborting due to 2 previous errors
21+
error[E0658]: custom test frameworks are an unstable feature
22+
--> $DIR/feature-gate-custom_test_frameworks.rs:2:1
23+
|
24+
LL | #![reexport_test_harness_main = "foo"]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information
28+
= help: add `#![feature(custom_test_frameworks)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error: aborting due to 3 previous errors
2232

2333
For more information about this error, try `rustc --explain E0658`.

tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
//~| HELP can only be applied to
5656
//~| HELP remove the attribute
5757
#![no_implicit_prelude]
58-
#![reexport_test_harness_main = "2900"]
5958
// see gated-link-args.rs
6059
// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
6160
// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
@@ -465,30 +464,6 @@ mod no_implicit_prelude {
465464
//~| HELP remove the attribute
466465
}
467466

468-
#[reexport_test_harness_main = "2900"]
469-
//~^ WARN crate-level attribute should be
470-
mod reexport_test_harness_main {
471-
//~^ NOTE this attribute does not have an `!`, which means it is applied to this module
472-
mod inner { #![reexport_test_harness_main="2900"] }
473-
//~^ WARN the `#![reexport_test_harness_main]` attribute can only be used at the crate root
474-
475-
#[reexport_test_harness_main = "2900"] fn f() { }
476-
//~^ WARN crate-level attribute should be
477-
//~| NOTE this attribute does not have an `!`, which means it is applied to this function
478-
479-
#[reexport_test_harness_main = "2900"] struct S;
480-
//~^ WARN crate-level attribute should be
481-
//~| NOTE this attribute does not have an `!`, which means it is applied to this struct
482-
483-
#[reexport_test_harness_main = "2900"] type T = S;
484-
//~^ WARN crate-level attribute should be
485-
//~| NOTE this attribute does not have an `!`, which means it is applied to this type alias
486-
487-
#[reexport_test_harness_main = "2900"] impl S { }
488-
//~^ WARN crate-level attribute should be
489-
//~| NOTE this attribute does not have an `!`, which means it is applied to this implementation block
490-
}
491-
492467
// Cannot feed "2700" to `#[macro_escape]` without signaling an error.
493468
#[macro_escape]
494469
//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`

0 commit comments

Comments
 (0)