@@ -90,22 +90,23 @@ impl PathResolution {
9090#[ derive( Debug ) ]
9191pub struct TypeInfo {
9292 /// The original type of the expression or pattern.
93- pub ty : Type ,
94- /// The coerced type, if a coercion happened.
95- pub coerced : Option < Type > ,
93+ pub original : Type ,
94+ /// The adjusted type, if an adjustment happened.
95+ pub adjusted : Option < Type > ,
9696}
9797
9898impl TypeInfo {
99- pub fn ty ( self ) -> Type {
100- self . ty
99+ pub fn original ( self ) -> Type {
100+ self . original
101101 }
102102
103- pub fn has_coercion ( & self ) -> bool {
104- self . coerced . is_some ( )
103+ pub fn has_adjustment ( & self ) -> bool {
104+ self . adjusted . is_some ( )
105105 }
106106
107- pub fn coerced ( self ) -> Type {
108- self . coerced . unwrap_or ( self . ty )
107+ /// The adjusted type, or the original in case no adjustments occurred.
108+ pub fn adjusted ( self ) -> Type {
109+ self . adjusted . unwrap_or ( self . original )
109110 }
110111}
111112
@@ -581,13 +582,13 @@ impl<'db> SemanticsImpl<'db> {
581582 fn type_of_expr ( & self , expr : & ast:: Expr ) -> Option < TypeInfo > {
582583 self . analyze ( expr. syntax ( ) )
583584 . type_of_expr ( self . db , expr)
584- . map ( |( ty, coerced) | TypeInfo { ty, coerced } )
585+ . map ( |( ty, coerced) | TypeInfo { original : ty, adjusted : coerced } )
585586 }
586587
587588 fn type_of_pat ( & self , pat : & ast:: Pat ) -> Option < TypeInfo > {
588589 self . analyze ( pat. syntax ( ) )
589590 . type_of_pat ( self . db , pat)
590- . map ( |( ty, coerced) | TypeInfo { ty, coerced } )
591+ . map ( |( ty, coerced) | TypeInfo { original : ty, adjusted : coerced } )
591592 }
592593
593594 fn type_of_self ( & self , param : & ast:: SelfParam ) -> Option < Type > {
@@ -766,7 +767,7 @@ impl<'db> SemanticsImpl<'db> {
766767 ast:: Expr :: FieldExpr ( field_expr) => field_expr,
767768 _ => return None ,
768769 } ;
769- let ty = self . type_of_expr ( & field_expr. expr ( ) ?) ?. ty ;
770+ let ty = self . type_of_expr ( & field_expr. expr ( ) ?) ?. original ;
770771 if !ty. is_packed ( self . db ) {
771772 return None ;
772773 }
@@ -793,7 +794,7 @@ impl<'db> SemanticsImpl<'db> {
793794 self . type_of_expr ( & expr)
794795 } )
795796 // Binding a reference to a packed type is possibly unsafe.
796- . map ( |ty| ty. ty . is_packed ( self . db ) )
797+ . map ( |ty| ty. original . is_packed ( self . db ) )
797798 . unwrap_or ( false )
798799
799800 // FIXME This needs layout computation to be correct. It will highlight
@@ -839,7 +840,7 @@ impl<'db> SemanticsImpl<'db> {
839840 }
840841 } )
841842 // Binding a reference to a packed type is possibly unsafe.
842- . map ( |ty| ty. ty . is_packed ( self . db ) )
843+ . map ( |ty| ty. original . is_packed ( self . db ) )
843844 . unwrap_or ( false )
844845 }
845846}
0 commit comments