Skip to content

Commit 0705f0b

Browse files
authored
Unrolled build for rust-lang#117420
Rollup merge of rust-lang#117420 - Jules-Bertholet:internal-unstable-stmt-expr-attributes, r=petrochenkov Make `#![allow_internal_unstable(..)]` work with `stmt_expr_attributes` This is a necessary first step to fixing rust-lang#117304, as explained in rust-lang#117304 (comment). `@rustbot` label T-compiler
2 parents cdd4ff8 + 42b1406 commit 0705f0b

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

compiler/rustc_expand/src/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ impl<'a> StripUnconfigured<'a> {
373373
/// If attributes are not allowed on expressions, emit an error for `attr`
374374
#[instrument(level = "trace", skip(self))]
375375
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
376-
if self.features.is_some_and(|features| !features.stmt_expr_attributes) {
376+
if self.features.is_some_and(|features| !features.stmt_expr_attributes)
377+
&& !attr.span.allows_unstable(sym::stmt_expr_attributes)
378+
{
377379
let mut err = feature_err(
378380
&self.sess,
379381
sym::stmt_expr_attributes,

tests/ui/internal/internal-unstable.rs

+10
Original file line numberDiff line numberDiff 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+
3139
fn 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
}

tests/ui/internal/internal-unstable.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature 'function'
2-
--> $DIR/internal-unstable.rs:40:25
2+
--> $DIR/internal-unstable.rs:48:25
33
|
44
LL | pass_through_allow!(internal_unstable::unstable());
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | pass_through_allow!(internal_unstable::unstable());
88
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
99

1010
error[E0658]: use of unstable library feature 'function'
11-
--> $DIR/internal-unstable.rs:42:27
11+
--> $DIR/internal-unstable.rs:50:27
1212
|
1313
LL | pass_through_noallow!(internal_unstable::unstable());
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL | pass_through_noallow!(internal_unstable::unstable());
1717
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1818

1919
error[E0658]: use of unstable library feature 'function'
20-
--> $DIR/internal-unstable.rs:46:22
20+
--> $DIR/internal-unstable.rs:54:22
2121
|
2222
LL | println!("{:?}", internal_unstable::unstable());
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL | println!("{:?}", internal_unstable::unstable());
2626
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2727

2828
error[E0658]: use of unstable library feature 'function'
29-
--> $DIR/internal-unstable.rs:48:10
29+
--> $DIR/internal-unstable.rs:56:10
3030
|
3131
LL | bar!(internal_unstable::unstable());
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)