Move let expression checking to parsing
There was an incomplete version of the check in parsing and a second version in AST validation. This meant that some, but not all, invalid uses were allowed inside macros/disabled cfgs. It also means that later passes have a hard time knowing when the let expression is in a valid location, sometimes causing ICEs. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress later errors and MIR construction for invalid let expressions.
This commit is contained in:
parent
7b61f7f002
commit
333388fd3c
40 changed files with 915 additions and 2246 deletions
|
@ -19,6 +19,7 @@ use rustc_macros::HashStable_Generic;
|
|||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::ErrorGuaranteed;
|
||||
use rustc_span::{def_id::LocalDefId, BytePos, Span, DUMMY_SP};
|
||||
use rustc_target::asm::InlineAsmRegOrRegClass;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
@ -1415,6 +1416,9 @@ pub struct Let<'hir> {
|
|||
pub pat: &'hir Pat<'hir>,
|
||||
pub ty: Option<&'hir Ty<'hir>>,
|
||||
pub init: &'hir Expr<'hir>,
|
||||
/// `Some` when this let expressions is not in a syntanctically valid location.
|
||||
/// Used to prevent building MIR in such situations.
|
||||
pub is_recovered: Option<ErrorGuaranteed>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue