Skip to content

Commit 60e71c7

Browse files
committedJun 20, 2024
Auto merge of #126760 - matthiaskrgr:rollup-w6ajurr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #125627 (migration lint for `expr2024` for the edition 2024) - #126481 (Add `powerpc-unknown-openbsd` maintaince status) - #126613 (Print the tested value in int_log tests) - #126617 (Expand `avx512_target_feature` to include VEX variants) - #126686 (Add `#[rustc_dump_{predicates,item_bounds}]`) - #126700 (Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does) - #126707 (Pass target to inaccessible-temp-dir rmake test) - #126757 (Properly gate `safe` keyword in pre-expansion) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 684b355 + 3319aae commit 60e71c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+490
-171
lines changed
 

Diff for: ‎compiler/rustc_ast/src/token.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,11 @@ pub enum NonterminalKind {
900900
PatWithOr,
901901
Expr,
902902
/// Matches an expression using the rules from edition 2021 and earlier.
903-
Expr2021,
903+
Expr2021 {
904+
/// Keep track of whether the user used `:expr` or `:expr_2021` and we inferred it from the
905+
/// edition of the span. This is used for diagnostics AND feature gating.
906+
inferred: bool,
907+
},
904908
Ty,
905909
Ident,
906910
Lifetime,
@@ -929,8 +933,13 @@ impl NonterminalKind {
929933
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
930934
},
931935
sym::pat_param => NonterminalKind::PatParam { inferred: false },
932-
sym::expr => NonterminalKind::Expr,
933-
sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021,
936+
sym::expr => match edition() {
937+
Edition::Edition2015 | Edition::Edition2018 | Edition::Edition2021 => {
938+
NonterminalKind::Expr2021 { inferred: true }
939+
}
940+
Edition::Edition2024 => NonterminalKind::Expr,
941+
},
942+
sym::expr_2021 => NonterminalKind::Expr2021 { inferred: false },
934943
sym::ty => NonterminalKind::Ty,
935944
sym::ident => NonterminalKind::Ident,
936945
sym::lifetime => NonterminalKind::Lifetime,
@@ -949,8 +958,8 @@ impl NonterminalKind {
949958
NonterminalKind::Stmt => sym::stmt,
950959
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
951960
NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat,
952-
NonterminalKind::Expr => sym::expr,
953-
NonterminalKind::Expr2021 => sym::expr_2021,
961+
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: true } => sym::expr,
962+
NonterminalKind::Expr2021 { inferred: false } => sym::expr_2021,
954963
NonterminalKind::Ty => sym::ty,
955964
NonterminalKind::Ident => sym::ident,
956965
NonterminalKind::Lifetime => sym::lifetime,

Diff for: ‎compiler/rustc_ast_passes/src/feature_gate.rs

+4
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
562562
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
563563
gate_all!(global_registration, "global registration is experimental");
564564
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
565+
gate_all!(
566+
unsafe_extern_blocks,
567+
"`unsafe extern {}` blocks and `safe` keyword are experimental"
568+
);
565569

566570
if !visitor.features.never_patterns {
567571
if let Some(spans) = spans.get(&sym::never_patterns) {

0 commit comments

Comments
 (0)