@@ -1613,8 +1613,10 @@ pub enum StatementKind<'tcx> {
16131613 Assign ( Place < ' tcx > , Rvalue < ' tcx > ) ,
16141614
16151615 /// This represents all the reading that a pattern match may do
1616- /// (e.g. inspecting constants and discriminant values).
1617- ReadForMatch ( Place < ' tcx > ) ,
1616+ /// (e.g. inspecting constants and discriminant values), and the
1617+ /// kind of pattern it comes from. This is in order to adapt potential
1618+ /// error messages to these specific patterns.
1619+ FakeRead ( FakeReadCause , Place < ' tcx > ) ,
16181620
16191621 /// Write the discriminant for a variant to the enum Place.
16201622 SetDiscriminant {
@@ -1662,6 +1664,13 @@ pub enum StatementKind<'tcx> {
16621664 Nop ,
16631665}
16641666
1667+ /// The `FakeReadCause` describes the type of pattern why a `FakeRead` statement exists.
1668+ #[ derive( Copy , Clone , RustcEncodable , RustcDecodable , Debug ) ]
1669+ pub enum FakeReadCause {
1670+ ForMatch ,
1671+ ForLet ,
1672+ }
1673+
16651674/// The `ValidationOp` describes what happens with each of the operands of a
16661675/// `Validate` statement.
16671676#[ derive( Copy , Clone , RustcEncodable , RustcDecodable , PartialEq , Eq ) ]
@@ -1718,7 +1727,7 @@ impl<'tcx> Debug for Statement<'tcx> {
17181727 use self :: StatementKind :: * ;
17191728 match self . kind {
17201729 Assign ( ref place, ref rv) => write ! ( fmt, "{:?} = {:?}" , place, rv) ,
1721- ReadForMatch ( ref place) => write ! ( fmt, "ReadForMatch ({:?})" , place) ,
1730+ FakeRead ( ref cause , ref place) => write ! ( fmt, "FakeRead ({:?}, {:?})" , cause , place) ,
17221731 // (reuse lifetime rendering policy from ppaux.)
17231732 EndRegion ( ref ce) => write ! ( fmt, "EndRegion({})" , ty:: ReScope ( * ce) ) ,
17241733 Validate ( ref op, ref places) => write ! ( fmt, "Validate({:?}, {:?})" , op, places) ,
@@ -2585,6 +2594,7 @@ CloneTypeFoldableAndLiftImpls! {
25852594 Mutability ,
25862595 SourceInfo ,
25872596 UpvarDecl ,
2597+ FakeReadCause ,
25882598 ValidationOp ,
25892599 SourceScope ,
25902600 SourceScopeData ,
@@ -2651,7 +2661,7 @@ BraceStructTypeFoldableImpl! {
26512661EnumTypeFoldableImpl ! {
26522662 impl <' tcx> TypeFoldable <' tcx> for StatementKind <' tcx> {
26532663 ( StatementKind :: Assign ) ( a, b) ,
2654- ( StatementKind :: ReadForMatch ) ( place) ,
2664+ ( StatementKind :: FakeRead ) ( cause , place) ,
26552665 ( StatementKind :: SetDiscriminant ) { place, variant_index } ,
26562666 ( StatementKind :: StorageLive ) ( a) ,
26572667 ( StatementKind :: StorageDead ) ( a) ,
0 commit comments