Skip to content

Commit

Permalink
Unrolled build for rust-lang#117420
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer committed Jan 26, 2024
2 parents cdd4ff8 + 42b1406 commit 0705f0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ impl<'a> StripUnconfigured<'a> {
/// If attributes are not allowed on expressions, emit an error for `attr`
#[instrument(level = "trace", skip(self))]
pub(crate) fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
if self.features.is_some_and(|features| !features.stmt_expr_attributes) {
if self.features.is_some_and(|features| !features.stmt_expr_attributes)
&& !attr.span.allows_unstable(sym::stmt_expr_attributes)
{
let mut err = feature_err(
&self.sess,
sym::stmt_expr_attributes,
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/internal/internal-unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ macro_rules! bar {
}}
}

#[allow_internal_unstable(stmt_expr_attributes)]
macro_rules! internal_attr {
($e: expr) => {
#[allow(overflowing_literals)]
$e
}
}

fn main() {
// ok, the instability is contained.
call_unstable_allow!();
Expand All @@ -51,4 +59,6 @@ fn main() {
#[allow_internal_unstable]
_ => {}
}

assert_eq!(internal_attr!(1e100_f32), f32::INFINITY);
}
8 changes: 4 additions & 4 deletions tests/ui/internal/internal-unstable.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature 'function'
--> $DIR/internal-unstable.rs:40:25
--> $DIR/internal-unstable.rs:48:25
|
LL | pass_through_allow!(internal_unstable::unstable());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,7 +8,7 @@ LL | pass_through_allow!(internal_unstable::unstable());
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

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

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

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

0 comments on commit 0705f0b

Please sign in to comment.