This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
compiler/rustc_expand/src Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -449,7 +449,9 @@ impl<'a> StripUnconfigured<'a> {
449449 /// If attributes are not allowed on expressions, emit an error for `attr`
450450 #[ instrument( level = "trace" , skip( self ) ) ]
451451 pub ( crate ) fn maybe_emit_expr_attr_err ( & self , attr : & Attribute ) {
452- if self . features . is_some_and ( |features| !features. stmt_expr_attributes ) {
452+ if self . features . is_some_and ( |features| !features. stmt_expr_attributes )
453+ && !attr. span . allows_unstable ( sym:: stmt_expr_attributes)
454+ {
453455 let mut err = feature_err (
454456 & self . sess . parse_sess ,
455457 sym:: stmt_expr_attributes,
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ macro_rules! bar {
2828 } }
2929}
3030
31+ #[ allow_internal_unstable( stmt_expr_attributes) ]
32+ macro_rules! internal_attr {
33+ ( $e: expr) => {
34+ #[ allow( overflowing_literals) ]
35+ $e
36+ }
37+ }
38+
3139fn main ( ) {
3240 // ok, the instability is contained.
3341 call_unstable_allow ! ( ) ;
@@ -51,4 +59,6 @@ fn main() {
5159 #[ allow_internal_unstable]
5260 _ => { }
5361 }
62+
63+ assert_eq ! ( internal_attr!( 1e100_f32 ) , f32 :: INFINITY ) ;
5464}
Original file line number Diff line number Diff line change 11error[E0658]: use of unstable library feature 'function'
2- --> $DIR/internal-unstable.rs:40 :25
2+ --> $DIR/internal-unstable.rs:48 :25
33 |
44LL | pass_through_allow!(internal_unstable::unstable());
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 |
77 = help: add `#![feature(function)]` to the crate attributes to enable
88
99error[E0658]: use of unstable library feature 'function'
10- --> $DIR/internal-unstable.rs:42 :27
10+ --> $DIR/internal-unstable.rs:50 :27
1111 |
1212LL | pass_through_noallow!(internal_unstable::unstable());
1313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414 |
1515 = help: add `#![feature(function)]` to the crate attributes to enable
1616
1717error[E0658]: use of unstable library feature 'function'
18- --> $DIR/internal-unstable.rs:46 :22
18+ --> $DIR/internal-unstable.rs:54 :22
1919 |
2020LL | println!("{:?}", internal_unstable::unstable());
2121 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2222 |
2323 = help: add `#![feature(function)]` to the crate attributes to enable
2424
2525error[E0658]: use of unstable library feature 'function'
26- --> $DIR/internal-unstable.rs:48 :10
26+ --> $DIR/internal-unstable.rs:56 :10
2727 |
2828LL | bar!(internal_unstable::unstable());
2929 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments