diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-02 07:30:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-02 07:30:44 +0200 |
| commit | beb4cdddde0421710d548da5a847efec0d515343 (patch) | |
| tree | b0aa4b5648013b2ffa7bc14cbe6731fd5f499769 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | 17f76a16f9379aaf10c656e23a2d132fcb17a751 (diff) | |
| parent | 6be7a87f9ccc4ead6887d2cc7231f44df3673681 (diff) | |
| download | rust-beb4cdddde0421710d548da5a847efec0d515343.tar.gz rust-beb4cdddde0421710d548da5a847efec0d515343.zip | |
Rollup merge of #100011 - compiler-errors:let-chain-restriction, r=fee1-dead
Use Parser's `restrictions` instead of `let_expr_allowed` This also means that the `ALLOW_LET` flag is reset properly for subexpressions, so we can properly deny things like `a && (b && let c = d)`. Also the parser is a tiny bit smaller now. It doesn't reject _all_ bad `let` expr usages, just a bit more. cc `@c410-f3r`
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 1ac8b224248..0c523ad22c2 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -47,6 +47,7 @@ bitflags::bitflags! { const STMT_EXPR = 1 << 0; const NO_STRUCT_LITERAL = 1 << 1; const CONST_EXPR = 1 << 2; + const ALLOW_LET = 1 << 3; } } @@ -147,15 +148,12 @@ pub struct Parser<'a> { /// This allows us to recover when the user forget to add braces around /// multiple statements in the closure body. pub current_closure: Option<ClosureSpans>, - /// Used to track where `let`s are allowed. For example, `if true && let 1 = 1` is valid - /// but `[1, 2, 3][let _ = ()]` is not. - let_expr_allowed: bool, } // This type is used a lot, e.g. it's cloned when matching many declarative macro rules. Make sure // it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -rustc_data_structures::static_assert_size!(Parser<'_>, 336); +rustc_data_structures::static_assert_size!(Parser<'_>, 328); /// Stores span information about a closure. #[derive(Clone)] @@ -462,7 +460,6 @@ impl<'a> Parser<'a> { inner_attr_ranges: Default::default(), }, current_closure: None, - let_expr_allowed: false, }; // Make parser point to the first token. |
