Skip to content

Commit 6e3df73

Browse files
committed
Auto merge of rust-lang#126775 - matthiaskrgr:rollup-ydxpehb, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#124101 (Add PidFd::{kill, wait, try_wait}) - rust-lang#126125 (Improve conflict marker recovery) - rust-lang#126481 (Add `powerpc-unknown-openbsd` maintenance status) - rust-lang#126613 (Print the tested value in int_log tests) - rust-lang#126617 (Expand `avx512_target_feature` to include VEX variants) - rust-lang#126700 (Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does) - rust-lang#126707 (Pass target to inaccessible-temp-dir rmake test) - rust-lang#126767 (`StaticForeignItem` and `StaticItem` are the same) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4e6de37 + 832109b commit 6e3df73

Some content is hidden

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

47 files changed

+538
-355
lines changed

compiler/rustc_ast/src/ast.rs

+1-33
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

+1-6
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

+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,

compiler/rustc_ast/src/visit.rs

+1-6
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

+1-6
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

+1-1
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

+1-6
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_expand/src/mbe/macro_rules.rs

+3-1
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

+2-1
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(

compiler/rustc_parse/src/parser/diagnostics.rs

+42-16
Original file line numberDiff line numberDiff line change
@@ -2965,9 +2965,10 @@ impl<'a> Parser<'a> {
29652965

29662966
/// This checks if this is a conflict marker, depending of the parameter passed.
29672967
///
2968-
/// * `>>>>>`
2969-
/// * `=====`
2970-
/// * `<<<<<`
2968+
/// * `<<<<<<<`
2969+
/// * `|||||||`
2970+
/// * `=======`
2971+
/// * `>>>>>>>`
29712972
///
29722973
pub(super) fn is_vcs_conflict_marker(
29732974
&mut self,
@@ -2997,14 +2998,18 @@ impl<'a> Parser<'a> {
29972998
}
29982999

29993000
pub(crate) fn err_vcs_conflict_marker(&mut self) -> PResult<'a, ()> {
3001+
// <<<<<<<
30003002
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt)
30013003
else {
30023004
return Ok(());
30033005
};
30043006
let mut spans = Vec::with_capacity(3);
30053007
spans.push(start);
3008+
// |||||||
30063009
let mut middlediff3 = None;
3010+
// =======
30073011
let mut middle = None;
3012+
// >>>>>>>
30083013
let mut end = None;
30093014
loop {
30103015
if self.token.kind == TokenKind::Eof {
@@ -3025,29 +3030,50 @@ impl<'a> Parser<'a> {
30253030
}
30263031
self.bump();
30273032
}
3033+
30283034
let mut err = self.dcx().struct_span_err(spans, "encountered diff marker");
3029-
err.span_label(start, "after this is the code before the merge");
3030-
if let Some(middle) = middlediff3 {
3031-
err.span_label(middle, "");
3032-
}
3035+
match middlediff3 {
3036+
// We're using diff3
3037+
Some(middlediff3) => {
3038+
err.span_label(
3039+
start,
3040+
"between this marker and `|||||||` is the code that we're merging into",
3041+
);
3042+
err.span_label(middlediff3, "between this marker and `=======` is the base code (what the two refs diverged from)");
3043+
}
3044+
None => {
3045+
err.span_label(
3046+
start,
3047+
"between this marker and `=======` is the code that we're merging into",
3048+
);
3049+
}
3050+
};
3051+
30333052
if let Some(middle) = middle {
3034-
err.span_label(middle, "");
3053+
err.span_label(middle, "between this marker and `>>>>>>>` is the incoming code");
30353054
}
30363055
if let Some(end) = end {
3037-
err.span_label(end, "above this are the incoming code changes");
3056+
err.span_label(end, "this marker concludes the conflict region");
30383057
}
3039-
err.help(
3040-
"if you're having merge conflicts after pulling new code, the top section is the code \
3041-
you already had and the bottom section is the remote code",
3058+
err.note(
3059+
"conflict markers indicate that a merge was started but could not be completed due \
3060+
to merge conflicts\n\
3061+
to resolve a conflict, keep only the code you want and then delete the lines \
3062+
containing conflict markers",
30423063
);
30433064
err.help(
3044-
"if you're in the middle of a rebase, the top section is the code being rebased onto \
3045-
and the bottom section is the code coming from the current commit being rebased",
3065+
"if you're having merge conflicts after pulling new code:\n\
3066+
the top section is the code you already had and the bottom section is the remote code\n\
3067+
if you're in the middle of a rebase:\n\
3068+
the top section is the code being rebased onto and the bottom section is the code \
3069+
coming from the current commit being rebased",
30463070
);
3071+
30473072
err.note(
3048-
"for an explanation on these markers from the `git` documentation, visit \
3049-
<https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
3073+
"for an explanation on these markers from the `git` documentation:\n\
3074+
visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
30503075
);
3076+
30513077
Err(err)
30523078
}
30533079

compiler/rustc_parse/src/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ impl<'a> Parser<'a> {
12281228
ident_span: ident.span,
12291229
const_span,
12301230
});
1231-
ForeignItemKind::Static(Box::new(StaticForeignItem {
1231+
ForeignItemKind::Static(Box::new(StaticItem {
12321232
ty,
12331233
mutability: Mutability::Not,
12341234
expr,

compiler/rustc_parse/src/parser/nonterminal.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a> Parser<'a> {
3636
}
3737

3838
match kind {
39-
NonterminalKind::Expr2021 => {
39+
NonterminalKind::Expr2021 { inferred: _ } => {
4040
token.can_begin_expr()
4141
// This exception is here for backwards compatibility.
4242
&& !token.is_keyword(kw::Let)
@@ -47,7 +47,6 @@ impl<'a> Parser<'a> {
4747
token.can_begin_expr()
4848
// This exception is here for backwards compatibility.
4949
&& !token.is_keyword(kw::Let)
50-
&& (!token.is_keyword(kw::Const) || token.span.edition().at_least_rust_2024())
5150
}
5251
NonterminalKind::Ty => token.can_begin_type(),
5352
NonterminalKind::Ident => get_macro_ident(token).is_some(),
@@ -149,7 +148,7 @@ impl<'a> Parser<'a> {
149148
})?)
150149
}
151150

152-
NonterminalKind::Expr | NonterminalKind::Expr2021 => {
151+
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: _ } => {
153152
NtExpr(self.parse_expr_force_collect()?)
154153
}
155154
NonterminalKind::Literal => {

compiler/rustc_resolve/src/def_collector.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
217217

218218
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
219219
let def_kind = match fi.kind {
220-
ForeignItemKind::Static(box StaticForeignItem {
221-
ty: _,
222-
mutability,
223-
expr: _,
224-
safety,
225-
}) => {
220+
ForeignItemKind::Static(box StaticItem { ty: _, mutability, expr: _, safety }) => {
226221
let safety = match safety {
227222
ast::Safety::Unsafe(_) | ast::Safety::Default => hir::Safety::Unsafe,
228223
ast::Safety::Safe(_) => hir::Safety::Safe,

compiler/rustc_target/src/target_features.rs

+5
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ const X86_ALLOWED_FEATURES: &[(&str, Stability)] = &[
208208
("avx512vnni", Unstable(sym::avx512_target_feature)),
209209
("avx512vp2intersect", Unstable(sym::avx512_target_feature)),
210210
("avx512vpopcntdq", Unstable(sym::avx512_target_feature)),
211+
("avxifma", Unstable(sym::avx512_target_feature)),
212+
("avxneconvert", Unstable(sym::avx512_target_feature)),
213+
("avxvnni", Unstable(sym::avx512_target_feature)),
214+
("avxvnniint16", Unstable(sym::avx512_target_feature)),
215+
("avxvnniint8", Unstable(sym::avx512_target_feature)),
211216
("bmi1", Stable),
212217
("bmi2", Stable),
213218
("cmpxchg16b", Stable),

0 commit comments

Comments
 (0)