diff options
| author | Esteban Kuber <esteban@kuber.com.ar> | 2021-09-02 18:34:03 +0000 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-09-03 14:43:04 +0000 |
| commit | 12ce6e9c60c662dc7181b70021145f191c0f9f3e (patch) | |
| tree | 2d25c254eeec0782df8dced3f020e4cff9ef6785 /compiler/rustc_ast | |
| parent | fcce644119cf4e8e36001368e514bb5ed67cb855 (diff) | |
| download | rust-12ce6e9c60c662dc7181b70021145f191c0f9f3e.tar.gz rust-12ce6e9c60c662dc7181b70021145f191c0f9f3e.zip | |
Detect bare blocks with type ascription that were meant to be a `struct` literal
Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
Diffstat (limited to 'compiler/rustc_ast')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 0632d937c4c..5e154805644 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -565,6 +565,14 @@ pub struct Block { pub rules: BlockCheckMode, pub span: Span, pub tokens: Option<LazyTokenStream>, + /// The following *isn't* a parse error, but will cause multiple errors in following stages. + /// ``` + /// let x = { + /// foo: var + /// }; + /// ``` + /// #34255 + pub could_be_bare_literal: bool, } /// A match pattern. diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 368a23e3429..4d9fc6554e7 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -949,7 +949,7 @@ pub fn noop_visit_mt<T: MutVisitor>(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mu } pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) { - let Block { id, stmts, rules: _, span, tokens } = block.deref_mut(); + let Block { id, stmts, rules: _, span, tokens, could_be_bare_literal: _ } = block.deref_mut(); vis.visit_id(id); stmts.flat_map_in_place(|stmt| vis.flat_map_stmt(stmt)); vis.visit_span(span); |
