Skip to content

Commit d40f30e

Browse files
committed
Auto merge of #126781 - matthiaskrgr:rollup-5u4pens, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #126125 (Improve conflict marker recovery) - #126481 (Add `powerpc-unknown-openbsd` maintenance status) - #126613 (Print the tested value in int_log tests) - #126617 (Expand `avx512_target_feature` to include VEX variants) - #126700 (Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does) - #126707 (Pass target to inaccessible-temp-dir rmake test) - #126767 (`StaticForeignItem` and `StaticItem` are the same) - #126774 (Fix another assertion failure for some Expect diagnostics.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e32ea48 + d86736c commit d40f30e

Some content is hidden

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

43 files changed

+300
-237
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,38 +3184,6 @@ pub struct StaticItem {
31843184
pub expr: Option<P<Expr>>,
31853185
}
31863186

3187-
/// A static item in `extern` block.
3188-
// This struct is identical to StaticItem for now but it's going to have a safety attribute.
3189-
#[derive(Clone, Encodable, Decodable, Debug)]
3190-
pub struct StaticForeignItem {
3191-
pub ty: P<Ty>,
3192-
pub safety: Safety,
3193-
pub mutability: Mutability,
3194-
pub expr: Option<P<Expr>>,
3195-
}
3196-
3197-
impl From<StaticItem> for StaticForeignItem {
3198-
fn from(static_item: StaticItem) -> StaticForeignItem {
3199-
StaticForeignItem {
3200-
ty: static_item.ty,
3201-
safety: static_item.safety,
3202-
mutability: static_item.mutability,
3203-
expr: static_item.expr,
3204-
}
3205-
}
3206-
}
3207-
3208-
impl From<StaticForeignItem> for StaticItem {
3209-
fn from(static_item: StaticForeignItem) -> StaticItem {
3210-
StaticItem {
3211-
ty: static_item.ty,
3212-
safety: static_item.safety,
3213-
mutability: static_item.mutability,
3214-
expr: static_item.expr,
3215-
}
3216-
}
3217-
}
3218-
32193187
#[derive(Clone, Encodable, Decodable, Debug)]
32203188
pub struct ConstItem {
32213189
pub defaultness: Defaultness,
@@ -3430,7 +3398,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
34303398
#[derive(Clone, Encodable, Decodable, Debug)]
34313399
pub enum ForeignItemKind {
34323400
/// A foreign static item (`static FOO: u8`).
3433-
Static(Box<StaticForeignItem>),
3401+
Static(Box<StaticItem>),
34343402
/// An foreign function.
34353403
Fn(Box<Fn>),
34363404
/// An foreign type.

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,12 +1310,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
13101310
impl NoopVisitItemKind for ForeignItemKind {
13111311
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
13121312
match self {
1313-
ForeignItemKind::Static(box StaticForeignItem {
1314-
ty,
1315-
mutability: _,
1316-
expr,
1317-
safety: _,
1318-
}) => {
1313+
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
13191314
visitor.visit_ty(ty);
13201315
visit_opt(expr, |expr| visitor.visit_expr(expr));
13211316
}

compiler/rustc_ast/src/token.rs

Lines changed: 14 additions & 5 deletions
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,

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,7 @@ impl WalkItemKind for ForeignItemKind {
672672
) -> V::Result {
673673
let &Item { id, span, ident, ref vis, .. } = item;
674674
match self {
675-
ForeignItemKind::Static(box StaticForeignItem {
676-
ty,
677-
mutability: _,
678-
expr,
679-
safety: _,
680-
}) => {
675+
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
681676
try_visit!(visitor.visit_ty(ty));
682677
visit_opt!(visitor, visit_expr, expr);
683678
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
664664

665665
hir::ForeignItemKind::Fn(fn_dec, fn_args, generics, safety)
666666
}
667-
ForeignItemKind::Static(box StaticForeignItem {
668-
ty,
669-
mutability,
670-
expr: _,
671-
safety,
672-
}) => {
667+
ForeignItemKind::Static(box StaticItem { ty, mutability, expr: _, safety }) => {
673668
let ty = self
674669
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::StaticTy));
675670
let safety = self.lower_safety(*safety, hir::Safety::Unsafe);

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12321232
self.check_foreign_ty_genericless(generics, where_clauses);
12331233
self.check_foreign_item_ascii_only(fi.ident);
12341234
}
1235-
ForeignItemKind::Static(box StaticForeignItem { expr, safety, .. }) => {
1235+
ForeignItemKind::Static(box StaticItem { expr, safety, .. }) => {
12361236
self.check_foreign_item_safety(fi.span, *safety);
12371237
self.check_foreign_kind_bodyless(fi.ident, "static", expr.as_ref().map(|b| b.span));
12381238
self.check_foreign_item_ascii_only(fi.ident);

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ impl<'a> State<'a> {
3737
ast::ForeignItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => {
3838
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
3939
}
40-
ast::ForeignItemKind::Static(box ast::StaticForeignItem {
41-
ty,
42-
mutability,
43-
expr,
44-
safety,
45-
}) => {
40+
ast::ForeignItemKind::Static(box ast::StaticItem { ty, mutability, expr, safety }) => {
4641
self.print_safety(*safety);
4742
self.print_item_const(
4843
ident,

compiler/rustc_errors/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,10 +1456,10 @@ impl DiagCtxtInner {
14561456
}
14571457

14581458
if diagnostic.has_future_breakage() {
1459-
// Future breakages aren't emitted if they're `Level::Allow`,
1460-
// but they still need to be constructed and stashed below,
1461-
// so they'll trigger the must_produce_diag check.
1462-
assert!(matches!(diagnostic.level, Error | Warning | Allow));
1459+
// Future breakages aren't emitted if they're `Level::Allow` or
1460+
// `Level::Expect`, but they still need to be constructed and
1461+
// stashed below, so they'll trigger the must_produce_diag check.
1462+
assert!(matches!(diagnostic.level, Error | Warning | Allow | Expect(_)));
14631463
self.future_breakage_diagnostics.push(diagnostic.clone());
14641464
}
14651465

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
12921292
// maintain
12931293
IsInFollow::Yes
12941294
}
1295-
NonterminalKind::Stmt | NonterminalKind::Expr | NonterminalKind::Expr2021 => {
1295+
NonterminalKind::Stmt
1296+
| NonterminalKind::Expr
1297+
| NonterminalKind::Expr2021 { inferred: _ } => {
12961298
const TOKENS: &[&str] = &["`=>`", "`,`", "`;`"];
12971299
match tok {
12981300
TokenTree::Token(token) => match token.kind {

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ pub(super) fn parse(
113113
);
114114
token::NonterminalKind::Ident
115115
});
116-
if kind == token::NonterminalKind::Expr2021
116+
if kind
117+
== (token::NonterminalKind::Expr2021 { inferred: false })
117118
&& !features.expr_fragment_specifier_2024
118119
{
119120
rustc_session::parse::feature_err(

0 commit comments

Comments
 (0)