File tree 3 files changed +17
-5
lines changed
compiler/rustc_expand/src 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> {
449
449
/// If attributes are not allowed on expressions, emit an error for `attr`
450
450
#[ instrument( level = "trace" , skip( self ) ) ]
451
451
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
+ {
453
455
let mut err = feature_err (
454
456
& self . sess . parse_sess ,
455
457
sym:: stmt_expr_attributes,
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ macro_rules! bar {
28
28
} }
29
29
}
30
30
31
+ #[ allow_internal_unstable( stmt_expr_attributes) ]
32
+ macro_rules! internal_attr {
33
+ ( $e: expr) => {
34
+ #[ allow( overflowing_literals) ]
35
+ $e
36
+ }
37
+ }
38
+
31
39
fn main ( ) {
32
40
// ok, the instability is contained.
33
41
call_unstable_allow ! ( ) ;
@@ -51,4 +59,6 @@ fn main() {
51
59
#[ allow_internal_unstable]
52
60
_ => { }
53
61
}
62
+
63
+ assert_eq ! ( internal_attr!( 1e100_f32 ) , f32 :: INFINITY ) ;
54
64
}
Original file line number Diff line number Diff line change 1
1
error[E0658]: use of unstable library feature 'function'
2
- --> $DIR/internal-unstable.rs:40 :25
2
+ --> $DIR/internal-unstable.rs:48 :25
3
3
|
4
4
LL | pass_through_allow!(internal_unstable::unstable());
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
6
|
7
7
= help: add `#![feature(function)]` to the crate attributes to enable
8
8
9
9
error[E0658]: use of unstable library feature 'function'
10
- --> $DIR/internal-unstable.rs:42 :27
10
+ --> $DIR/internal-unstable.rs:50 :27
11
11
|
12
12
LL | pass_through_noallow!(internal_unstable::unstable());
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
14
|
15
15
= help: add `#![feature(function)]` to the crate attributes to enable
16
16
17
17
error[E0658]: use of unstable library feature 'function'
18
- --> $DIR/internal-unstable.rs:46 :22
18
+ --> $DIR/internal-unstable.rs:54 :22
19
19
|
20
20
LL | println!("{:?}", internal_unstable::unstable());
21
21
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
22
|
23
23
= help: add `#![feature(function)]` to the crate attributes to enable
24
24
25
25
error[E0658]: use of unstable library feature 'function'
26
- --> $DIR/internal-unstable.rs:48 :10
26
+ --> $DIR/internal-unstable.rs:56 :10
27
27
|
28
28
LL | bar!(internal_unstable::unstable());
29
29
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments