Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #126781

Merged
merged 19 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9b22110
Add powerpc-unknown-openbsd maintaince status
ChrisDenton Jun 14, 2024
c4ddc86
Print the tested value in int_log tests
tgross35 Jun 18, 2024
d51b446
Improve conflict marker recovery
dev-ardi Jun 7, 2024
9f63712
make this comment correct
dev-ardi Jun 10, 2024
b6d20d1
Add the target-features
sayantn Jun 18, 2024
1e1b3fc
Fix stderr cases
sayantn Jun 18, 2024
50d1efa
Add a test demonstrating the problem
compiler-errors Jun 19, 2024
3e8898a
Allow naming expr_2021 in all editions
compiler-errors Jun 19, 2024
a656bb6
Specify target for inaccessible-temp-dir rmake test
Hoverbear Jun 19, 2024
3e59f0c
StaticForeignItem and StaticItem are the same
compiler-errors Jun 20, 2024
d6efcbb
Fix another assertion failure for some Expect diagnostics.
nnethercote Jun 21, 2024
73cc4ec
Rollup merge of #126125 - dev-ardi:conflict-markers, r=estebank
matthiaskrgr Jun 21, 2024
0c1d396
Rollup merge of #126481 - ChrisDenton:powerpc-unkown-openbsd, r=ehuss
matthiaskrgr Jun 21, 2024
7a827d3
Rollup merge of #126613 - tgross35:log-test-update, r=cuviper
matthiaskrgr Jun 21, 2024
2b7f6e2
Rollup merge of #126617 - sayantn:veorq, r=workingjubilee
matthiaskrgr Jun 21, 2024
3bd84f1
Rollup merge of #126700 - compiler-errors:fragment, r=fmease
matthiaskrgr Jun 21, 2024
520118b
Rollup merge of #126707 - ferrocene:hoverbear/fix-inaccessible-temp-d…
matthiaskrgr Jun 21, 2024
f577d80
Rollup merge of #126767 - compiler-errors:static-foreign-item, r=spas…
matthiaskrgr Jun 21, 2024
d86736c
Rollup merge of #126774 - nnethercote:fix-126751, r=oli-obk
matthiaskrgr Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3184,38 +3184,6 @@ pub struct StaticItem {
pub expr: Option<P<Expr>>,
}

/// A static item in `extern` block.
// This struct is identical to StaticItem for now but it's going to have a safety attribute.
#[derive(Clone, Encodable, Decodable, Debug)]
pub struct StaticForeignItem {
pub ty: P<Ty>,
pub safety: Safety,
pub mutability: Mutability,
pub expr: Option<P<Expr>>,
}

impl From<StaticItem> for StaticForeignItem {
fn from(static_item: StaticItem) -> StaticForeignItem {
StaticForeignItem {
ty: static_item.ty,
safety: static_item.safety,
mutability: static_item.mutability,
expr: static_item.expr,
}
}
}

impl From<StaticForeignItem> for StaticItem {
fn from(static_item: StaticForeignItem) -> StaticItem {
StaticItem {
ty: static_item.ty,
safety: static_item.safety,
mutability: static_item.mutability,
expr: static_item.expr,
}
}
}

#[derive(Clone, Encodable, Decodable, Debug)]
pub struct ConstItem {
pub defaultness: Defaultness,
Expand Down Expand Up @@ -3430,7 +3398,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
#[derive(Clone, Encodable, Decodable, Debug)]
pub enum ForeignItemKind {
/// A foreign static item (`static FOO: u8`).
Static(Box<StaticForeignItem>),
Static(Box<StaticItem>),
/// An foreign function.
Fn(Box<Fn>),
/// An foreign type.
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,12 +1310,7 @@ pub fn noop_flat_map_item<K: NoopVisitItemKind>(
impl NoopVisitItemKind for ForeignItemKind {
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
match self {
ForeignItemKind::Static(box StaticForeignItem {
ty,
mutability: _,
expr,
safety: _,
}) => {
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
visitor.visit_ty(ty);
visit_opt(expr, |expr| visitor.visit_expr(expr));
}
Expand Down
19 changes: 14 additions & 5 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,11 @@ pub enum NonterminalKind {
PatWithOr,
Expr,
/// Matches an expression using the rules from edition 2021 and earlier.
Expr2021,
Expr2021 {
/// Keep track of whether the user used `:expr` or `:expr_2021` and we inferred it from the
/// edition of the span. This is used for diagnostics AND feature gating.
inferred: bool,
},
Ty,
Ident,
Lifetime,
Expand Down Expand Up @@ -929,8 +933,13 @@ impl NonterminalKind {
Edition::Edition2021 | Edition::Edition2024 => NonterminalKind::PatWithOr,
},
sym::pat_param => NonterminalKind::PatParam { inferred: false },
sym::expr => NonterminalKind::Expr,
sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021,
sym::expr => match edition() {
Edition::Edition2015 | Edition::Edition2018 | Edition::Edition2021 => {
NonterminalKind::Expr2021 { inferred: true }
}
Edition::Edition2024 => NonterminalKind::Expr,
},
sym::expr_2021 => NonterminalKind::Expr2021 { inferred: false },
sym::ty => NonterminalKind::Ty,
sym::ident => NonterminalKind::Ident,
sym::lifetime => NonterminalKind::Lifetime,
Expand All @@ -949,8 +958,8 @@ impl NonterminalKind {
NonterminalKind::Stmt => sym::stmt,
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat,
NonterminalKind::Expr => sym::expr,
NonterminalKind::Expr2021 => sym::expr_2021,
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: true } => sym::expr,
NonterminalKind::Expr2021 { inferred: false } => sym::expr_2021,
NonterminalKind::Ty => sym::ty,
NonterminalKind::Ident => sym::ident,
NonterminalKind::Lifetime => sym::lifetime,
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,7 @@ impl WalkItemKind for ForeignItemKind {
) -> V::Result {
let &Item { id, span, ident, ref vis, .. } = item;
match self {
ForeignItemKind::Static(box StaticForeignItem {
ty,
mutability: _,
expr,
safety: _,
}) => {
ForeignItemKind::Static(box StaticItem { ty, mutability: _, expr, safety: _ }) => {
try_visit!(visitor.visit_ty(ty));
visit_opt!(visitor, visit_expr, expr);
}
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

hir::ForeignItemKind::Fn(fn_dec, fn_args, generics, safety)
}
ForeignItemKind::Static(box StaticForeignItem {
ty,
mutability,
expr: _,
safety,
}) => {
ForeignItemKind::Static(box StaticItem { ty, mutability, expr: _, safety }) => {
let ty = self
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::StaticTy));
let safety = self.lower_safety(*safety, hir::Safety::Unsafe);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self.check_foreign_ty_genericless(generics, where_clauses);
self.check_foreign_item_ascii_only(fi.ident);
}
ForeignItemKind::Static(box StaticForeignItem { expr, safety, .. }) => {
ForeignItemKind::Static(box StaticItem { expr, safety, .. }) => {
self.check_foreign_item_safety(fi.span, *safety);
self.check_foreign_kind_bodyless(fi.ident, "static", expr.as_ref().map(|b| b.span));
self.check_foreign_item_ascii_only(fi.ident);
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ impl<'a> State<'a> {
ast::ForeignItemKind::Fn(box ast::Fn { defaultness, sig, generics, body }) => {
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
}
ast::ForeignItemKind::Static(box ast::StaticForeignItem {
ty,
mutability,
expr,
safety,
}) => {
ast::ForeignItemKind::Static(box ast::StaticItem { ty, mutability, expr, safety }) => {
self.print_safety(*safety);
self.print_item_const(
ident,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1456,10 +1456,10 @@ impl DiagCtxtInner {
}

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

Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
// maintain
IsInFollow::Yes
}
NonterminalKind::Stmt | NonterminalKind::Expr | NonterminalKind::Expr2021 => {
NonterminalKind::Stmt
| NonterminalKind::Expr
| NonterminalKind::Expr2021 { inferred: _ } => {
const TOKENS: &[&str] = &["`=>`", "`,`", "`;`"];
match tok {
TokenTree::Token(token) => match token.kind {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ pub(super) fn parse(
);
token::NonterminalKind::Ident
});
if kind == token::NonterminalKind::Expr2021
if kind
== (token::NonterminalKind::Expr2021 { inferred: false })
&& !features.expr_fragment_specifier_2024
{
rustc_session::parse::feature_err(
Expand Down
58 changes: 42 additions & 16 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,9 +2965,10 @@ impl<'a> Parser<'a> {

/// This checks if this is a conflict marker, depending of the parameter passed.
///
/// * `>>>>>`
/// * `=====`
/// * `<<<<<`
/// * `<<<<<<<`
/// * `|||||||`
/// * `=======`
/// * `>>>>>>>`
///
pub(super) fn is_vcs_conflict_marker(
&mut self,
Expand Down Expand Up @@ -2997,14 +2998,18 @@ impl<'a> Parser<'a> {
}

pub(crate) fn err_vcs_conflict_marker(&mut self) -> PResult<'a, ()> {
// <<<<<<<
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt)
else {
return Ok(());
};
let mut spans = Vec::with_capacity(3);
spans.push(start);
// |||||||
let mut middlediff3 = None;
// =======
let mut middle = None;
// >>>>>>>
let mut end = None;
loop {
if self.token.kind == TokenKind::Eof {
Expand All @@ -3025,29 +3030,50 @@ impl<'a> Parser<'a> {
}
self.bump();
}

let mut err = self.dcx().struct_span_err(spans, "encountered diff marker");
err.span_label(start, "after this is the code before the merge");
if let Some(middle) = middlediff3 {
err.span_label(middle, "");
}
match middlediff3 {
// We're using diff3
Some(middlediff3) => {
err.span_label(
start,
"between this marker and `|||||||` is the code that we're merging into",
);
err.span_label(middlediff3, "between this marker and `=======` is the base code (what the two refs diverged from)");
}
None => {
err.span_label(
start,
"between this marker and `=======` is the code that we're merging into",
);
}
};

if let Some(middle) = middle {
err.span_label(middle, "");
err.span_label(middle, "between this marker and `>>>>>>>` is the incoming code");
}
if let Some(end) = end {
err.span_label(end, "above this are the incoming code changes");
err.span_label(end, "this marker concludes the conflict region");
}
err.help(
"if you're having merge conflicts after pulling new code, the top section is the code \
you already had and the bottom section is the remote code",
err.note(
"conflict markers indicate that a merge was started but could not be completed due \
to merge conflicts\n\
to resolve a conflict, keep only the code you want and then delete the lines \
containing conflict markers",
);
err.help(
"if you're in the middle of a rebase, the top section is the code being rebased onto \
and the bottom section is the code coming from the current commit being rebased",
"if you're having merge conflicts after pulling new code:\n\
the top section is the code you already had and the bottom section is the remote code\n\
if you're in the middle of a rebase:\n\
the top section is the code being rebased onto and the bottom section is the code \
coming from the current commit being rebased",
);

err.note(
"for an explanation on these markers from the `git` documentation, visit \
<https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
"for an explanation on these markers from the `git` documentation:\n\
visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
);

Err(err)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ impl<'a> Parser<'a> {
ident_span: ident.span,
const_span,
});
ForeignItemKind::Static(Box::new(StaticForeignItem {
ForeignItemKind::Static(Box::new(StaticItem {
ty,
mutability: Mutability::Not,
expr,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_parse/src/parser/nonterminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> Parser<'a> {
}

match kind {
NonterminalKind::Expr2021 => {
NonterminalKind::Expr2021 { inferred: _ } => {
token.can_begin_expr()
// This exception is here for backwards compatibility.
&& !token.is_keyword(kw::Let)
Expand All @@ -47,7 +47,6 @@ impl<'a> Parser<'a> {
token.can_begin_expr()
// This exception is here for backwards compatibility.
&& !token.is_keyword(kw::Let)
&& (!token.is_keyword(kw::Const) || token.span.edition().at_least_rust_2024())
}
NonterminalKind::Ty => token.can_begin_type(),
NonterminalKind::Ident => get_macro_ident(token).is_some(),
Expand Down Expand Up @@ -149,7 +148,7 @@ impl<'a> Parser<'a> {
})?)
}

NonterminalKind::Expr | NonterminalKind::Expr2021 => {
NonterminalKind::Expr | NonterminalKind::Expr2021 { inferred: _ } => {
NtExpr(self.parse_expr_force_collect()?)
}
NonterminalKind::Literal => {
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {

fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
let def_kind = match fi.kind {
ForeignItemKind::Static(box StaticForeignItem {
ty: _,
mutability,
expr: _,
safety,
}) => {
ForeignItemKind::Static(box StaticItem { ty: _, mutability, expr: _, safety }) => {
let safety = match safety {
ast::Safety::Unsafe(_) | ast::Safety::Default => hir::Safety::Unsafe,
ast::Safety::Safe(_) => hir::Safety::Safe,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ const X86_ALLOWED_FEATURES: &[(&str, Stability)] = &[
("avx512vnni", Unstable(sym::avx512_target_feature)),
("avx512vp2intersect", Unstable(sym::avx512_target_feature)),
("avx512vpopcntdq", Unstable(sym::avx512_target_feature)),
("avxifma", Unstable(sym::avx512_target_feature)),
("avxneconvert", Unstable(sym::avx512_target_feature)),
("avxvnni", Unstable(sym::avx512_target_feature)),
("avxvnniint16", Unstable(sym::avx512_target_feature)),
("avxvnniint8", Unstable(sym::avx512_target_feature)),
("bmi1", Stable),
("bmi2", Stable),
("cmpxchg16b", Stable),
Expand Down
Loading
Loading