Skip to content

Commit df505a9

Browse files
Rollup merge of rust-lang#159826 - mejrs:sugar_parens, r=JonathanBrouwer
Remove redundant `#[rustc_paren_sugar]` feature gate It is already gated on `rustc_attrs`. Alternatively we could update attribute parsing to optionally require multiple features, but that seems unnecessary. r? @JonathanBrouwer
2 parents 532e546 + 4bd52e9 commit df505a9

5 files changed

Lines changed: 19 additions & 18 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(crate) struct RustcParenSugarParser;
5353
impl NoArgsAttributeParser for RustcParenSugarParser {
5454
const PATH: &[Symbol] = &[sym::rustc_paren_sugar];
5555
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
56-
const STABILITY: AttributeStability = unstable!(rustc_attrs);
56+
const STABILITY: AttributeStability = unstable!(unboxed_closures);
5757
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcParenSugar;
5858
}
5959

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,6 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
947947
let attrs = tcx.get_all_attrs(def_id);
948948

949949
let paren_sugar = find_attr!(attrs, RustcParenSugar);
950-
if paren_sugar && !tcx.features().unboxed_closures() {
951-
tcx.dcx().emit_err(diagnostics::ParenSugarAttribute { span: item.span });
952-
}
953950

954951
// Only regular traits can be marker.
955952
let is_marker = !is_alias && find_attr!(attrs, Marker);

compiler/rustc_hir_analysis/src/diagnostics.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -862,16 +862,6 @@ pub(crate) struct EnumDiscriminantOverflowed {
862862
pub wrapped_discr: String,
863863
}
864864

865-
#[derive(Diagnostic)]
866-
#[diag(
867-
"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation"
868-
)]
869-
#[help("add `#![feature(unboxed_closures)]` to the crate attributes to use it")]
870-
pub(crate) struct ParenSugarAttribute {
871-
#[primary_span]
872-
pub span: Span,
873-
}
874-
875865
#[derive(Diagnostic)]
876866
#[diag("use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code")]
877867
#[help("add `#![feature(simd_ffi)]` to the crate attributes to enable")]

tests/ui/feature-gates/feature-gate-unboxed-closures.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
struct Test;
44

5+
6+
#[rustc_paren_sugar]
7+
//~^ ERROR the `rustc_paren_sugar` attribute is an experimental feature
8+
pub trait Fn<Args> {}
59
impl FnOnce<(u32, u32)> for Test {
610
//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change
711
//~| ERROR manual implementations of `FnOnce` are experimental
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
error[E0658]: the `rustc_paren_sugar` attribute is an experimental feature
2+
--> $DIR/feature-gate-unboxed-closures.rs:6:3
3+
|
4+
LL | #[rustc_paren_sugar]
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
8+
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
111
error[E0658]: the extern "rust-call" ABI is experimental and subject to change
2-
--> $DIR/feature-gate-unboxed-closures.rs:10:12
12+
--> $DIR/feature-gate-unboxed-closures.rs:14:12
313
|
414
LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
515
| ^^^^^^^^^^^
@@ -9,7 +19,7 @@ LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 {
919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1020

1121
error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
12-
--> $DIR/feature-gate-unboxed-closures.rs:5:6
22+
--> $DIR/feature-gate-unboxed-closures.rs:9:6
1323
|
1424
LL | impl FnOnce<(u32, u32)> for Test {
1525
| ^^^^^^^^^^^^^^^^^^
@@ -19,14 +29,14 @@ LL | impl FnOnce<(u32, u32)> for Test {
1929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2030

2131
error[E0183]: manual implementations of `FnOnce` are experimental
22-
--> $DIR/feature-gate-unboxed-closures.rs:5:6
32+
--> $DIR/feature-gate-unboxed-closures.rs:9:6
2333
|
2434
LL | impl FnOnce<(u32, u32)> for Test {
2535
| ^^^^^^^^^^^^^^^^^^ manual implementations of `FnOnce` are experimental
2636
|
2737
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
2838

29-
error: aborting due to 3 previous errors
39+
error: aborting due to 4 previous errors
3040

3141
Some errors have detailed explanations: E0183, E0658.
3242
For more information about an error, try `rustc --explain E0183`.

0 commit comments

Comments
 (0)