Skip to content

Rollup of 7 pull requests #138974

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

Merged
merged 21 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6ccaea1
Target modifiers fix for bool flags without value
azhogin Mar 6, 2025
8cab8e0
Don't produce debug information for compiler-introduced-vars when des…
khuey Mar 22, 2025
848b0da
Remove fields that are dead since the removal of type ascription syntax
fmease Mar 23, 2025
6df2d58
Add function for linearizing `BuildStep` substeps
Kobzol Mar 25, 2025
82796dd
Brace-ident-colon can certainly no longer start a block
fmease Mar 23, 2025
9f336ce
Remove now unreachable parse recovery code
fmease Mar 23, 2025
598f865
Combine several test files into one
fmease Mar 24, 2025
b501e58
Incorporate issue-111692.rs into the larger test file and add more te…
fmease Mar 24, 2025
813783e
Add diff of bootstrap steps
Kobzol Mar 25, 2025
4b22ac5
Ensure define_opaque is accounted for in HIR hash
compiler-errors Mar 26, 2025
0c162b1
Revert "Make `MatchPairTree::place` non-optional"
meithecatte Mar 26, 2025
c8a5b36
MatchPairTree: update invariant comment
meithecatte Mar 26, 2025
1524060
Add a regression test for TestCase::Or without place
meithecatte Mar 26, 2025
a475f5d
Fix typo in error message
thaliaarchi Mar 16, 2025
7eb27a9
Rollup merge of #138483 - azhogin:azhogin/target-modifiers-bool-fix, …
Zalathar Mar 26, 2025
ff325e0
Rollup merge of #138818 - khuey:138198, r=jieyouxu
Zalathar Mar 26, 2025
30344f7
Rollup merge of #138898 - fmease:decrustify-parser-post-ty-ascr, r=co…
Zalathar Mar 26, 2025
2ae5d34
Rollup merge of #138930 - Kobzol:analyze-bootstrap-diffs, r=marcoieni
Zalathar Mar 26, 2025
19a53b7
Rollup merge of #138954 - compiler-errors:hash-opaques, r=oli-obk
Zalathar Mar 26, 2025
33c9023
Rollup merge of #138959 - meithecatte:matchpair-place-option, r=Zalathar
Zalathar Mar 26, 2025
46a40be
Rollup merge of #138967 - thaliaarchi:error-typo, r=Noratrieb
Zalathar Mar 26, 2025
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
Prev Previous commit
Next Next commit
Remove fields that are dead since the removal of type ascription syntax
Since `{ ident: ident }` is a parse error, these fields are dead.
  • Loading branch information
fmease committed Mar 24, 2025
commit 848b0da34fa20d0ff5d12d1d4f506affc765534b
8 changes: 0 additions & 8 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,6 @@ pub struct Block {
pub rules: BlockCheckMode,
pub span: Span,
pub tokens: Option<LazyAttrTokenStream>,
/// The following *isn't* a parse error, but will cause multiple errors in following stages.
/// ```compile_fail
/// let x = {
/// foo: var
/// };
/// ```
/// #34255
pub could_be_bare_literal: bool,
}

/// A match pattern.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
}

pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
let Block { id, stmts, rules: _, span, tokens, could_be_bare_literal: _ } = block.deref_mut();
let Block { id, stmts, rules: _, span, tokens } = block.deref_mut();
vis.visit_id(id);
stmts.flat_map_in_place(|stmt| vis.flat_map_stmt(stmt));
visit_lazy_tts(vis, tokens);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ pub fn walk_field_def<'a, V: Visitor<'a>>(visitor: &mut V, field: &'a FieldDef)
}

pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::Result {
let Block { stmts, id: _, rules: _, span: _, tokens: _, could_be_bare_literal: _ } = block;
let Block { stmts, id: _, rules: _, span: _, tokens: _ } = block;
walk_list!(visitor, visit_stmt, stmts);
V::Result::output()
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ mod llvm_enzyme {
tokens: None,
rules: unsf,
span,
could_be_bare_literal: false,
};
let unsf_expr = ecx.expr_block(P(unsf_block));
let blackbox_call_expr = ecx.expr_path(ecx.path(span, blackbox_path));
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P<ast::Expr> {
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
span,
tokens: None,
could_be_bare_literal: false,
}))
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ impl<'a> ExtCtxt<'a> {
rules: BlockCheckMode::Default,
span,
tokens: None,
could_be_bare_literal: false,
})
}

Expand Down
25 changes: 10 additions & 15 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,18 +971,8 @@ impl<'a> Parser<'a> {
// fn foo() -> Foo {
// field: value,
// }
// Suggest:
// fn foo() -> Foo { Path {
// field: value,
// } }
let guar = err.delay_as_bug();
self.restore_snapshot(snapshot);
let mut tail = self.mk_block(
thin_vec![self.mk_stmt_err(expr.span, guar)],
s,
lo.to(self.prev_token.span),
);
tail.could_be_bare_literal = true;
if maybe_struct_name.is_ident() && can_be_struct_literal {
// Account for `if Example { a: one(), }.is_pos() {}`.
// expand `before` so that we take care of module path such as:
Expand All @@ -1004,14 +994,22 @@ impl<'a> Parser<'a> {
return None;
}
} else {
// Suggest:
// fn foo() -> Foo { Path {
// field: value,
// } }
self.dcx().emit_err(StructLiteralBodyWithoutPath {
span: expr.span,
sugg: StructLiteralBodyWithoutPathSugg {
before: expr.span.shrink_to_lo(),
after: expr.span.shrink_to_hi(),
},
});
Ok(tail)
Ok(self.mk_block(
thin_vec![self.mk_stmt_err(expr.span, guar)],
s,
lo.to(self.prev_token.span),
))
}
}
(Err(err), Ok(tail)) => {
Expand All @@ -1025,10 +1023,7 @@ impl<'a> Parser<'a> {
self.consume_block(exp!(OpenBrace), exp!(CloseBrace), ConsumeClosingDelim::Yes);
Err(err)
}
(Ok(_), Ok(mut tail)) => {
tail.could_be_bare_literal = true;
Ok(tail)
}
(Ok(_), Ok(tail)) => Ok(tail),
});
}
None
Expand Down
9 changes: 1 addition & 8 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,14 +1043,7 @@ impl<'a> Parser<'a> {
rules: BlockCheckMode,
span: Span,
) -> P<Block> {
P(Block {
stmts,
id: DUMMY_NODE_ID,
rules,
span,
tokens: None,
could_be_bare_literal: false,
})
P(Block { stmts, id: DUMMY_NODE_ID, rules, span, tokens: None })
}

pub(super) fn mk_stmt(&self, span: Span, kind: StmtKind) -> Stmt {
Expand Down
13 changes: 0 additions & 13 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,6 @@ struct DiagMetadata<'ast> {
/// they are used (in a `break` or `continue` statement)
unused_labels: FxHashMap<NodeId, Span>,

/// Only used for better errors on `let x = { foo: bar };`.
/// In the case of a parse error with `let x = { foo: bar, };`, this isn't needed, it's only
/// needed for cases where this parses as a correct type ascription.
current_block_could_be_bare_struct_literal: Option<Span>,

/// Only used for better errors on `let <pat>: <expr, not type>;`.
current_let_binding: Option<(Span, Option<Span>, Option<Span>)>,

Expand Down Expand Up @@ -4650,13 +4645,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
self.ribs[ValueNS].push(Rib::new(RibKind::Normal));
}

let prev = self.diag_metadata.current_block_could_be_bare_struct_literal.take();
if let (true, [Stmt { kind: StmtKind::Expr(expr), .. }]) =
(block.could_be_bare_literal, &block.stmts[..])
&& let ExprKind::Type(..) = expr.kind
{
self.diag_metadata.current_block_could_be_bare_struct_literal = Some(block.span);
}
// Descend into the block.
for stmt in &block.stmts {
if let StmtKind::Item(ref item) = stmt.kind
Expand All @@ -4670,7 +4658,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {

self.visit_stmt(stmt);
}
self.diag_metadata.current_block_could_be_bare_struct_literal = prev;

// Move back up.
self.parent_scope.module = orig_module;
Expand Down
14 changes: 0 additions & 14 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
err.span_suggestion_verbose(sugg.0, sugg.1, &sugg.2, Applicability::MaybeIncorrect);
}

self.suggest_bare_struct_literal(&mut err);
self.suggest_changing_type_to_const_param(&mut err, res, source, span);
self.explain_functions_in_pattern(&mut err, res, source);

Expand Down Expand Up @@ -1281,19 +1280,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}
}

fn suggest_bare_struct_literal(&mut self, err: &mut Diag<'_>) {
if let Some(span) = self.diag_metadata.current_block_could_be_bare_struct_literal {
err.multipart_suggestion(
"you might have meant to write a `struct` literal",
vec![
(span.shrink_to_lo(), "{ SomeStruct ".to_string()),
(span.shrink_to_hi(), "}".to_string()),
],
Applicability::HasPlaceholders,
);
}
}

fn explain_functions_in_pattern(
&mut self,
err: &mut Diag<'_>,
Expand Down
1 change: 0 additions & 1 deletion src/tools/rustfmt/src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ fn rewrite_closure_with_block(
.first()
.map(|attr| attr.span.to(body.span))
.unwrap_or(body.span),
could_be_bare_literal: false,
};
let block = crate::expr::rewrite_block_with_visitor(
context,
Expand Down
1 change: 0 additions & 1 deletion src/tools/rustfmt/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ fn rewrite_empty_macro_def_body(
rules: ast::BlockCheckMode::Default,
span,
tokens: None,
could_be_bare_literal: false,
};
block.rewrite_result(context, shape)
}
Expand Down
1 change: 0 additions & 1 deletion tests/ui-fulldeps/pprust-expr-roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
rules: BlockCheckMode::Default,
span: DUMMY_SP,
tokens: None,
could_be_bare_literal: false,
});
iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None)));
}
Expand Down