@@ -41,7 +41,7 @@ use crate::ty::steal::Steal;
4141use crate :: ty:: subst:: { UserSubsts , UnpackedKind } ;
4242use crate :: ty:: { BoundVar , BindingMode } ;
4343use crate :: ty:: CanonicalPolyFnSig ;
44- use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap } ;
44+ use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap , ItemLocalSet } ;
4545use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
4646use errors:: DiagnosticBuilder ;
4747use rustc_data_structures:: interner:: HashInterner ;
@@ -409,9 +409,9 @@ pub struct TypeckTables<'tcx> {
409409 /// MIR construction and hence is not serialized to metadata.
410410 fru_field_types : ItemLocalMap < Vec < Ty < ' tcx > > > ,
411411
412- /// Maps a cast expression to its kind. This is keyed on the
413- /// *from* expression of the cast, not the cast itself .
414- cast_kinds : ItemLocalMap < ty :: cast :: CastKind > ,
412+ /// For every coercion cast we add the HIR node ID of the cast
413+ /// expression to this set .
414+ coercion_casts : ItemLocalSet ,
415415
416416 /// Set of trait imports actually used in the method resolution.
417417 /// This is used for warning unused imports. During type
@@ -456,7 +456,7 @@ impl<'tcx> TypeckTables<'tcx> {
456456 closure_kind_origins : Default :: default ( ) ,
457457 liberated_fn_sigs : Default :: default ( ) ,
458458 fru_field_types : Default :: default ( ) ,
459- cast_kinds : Default :: default ( ) ,
459+ coercion_casts : Default :: default ( ) ,
460460 used_trait_imports : Lrc :: new ( Default :: default ( ) ) ,
461461 tainted_by_errors : false ,
462462 free_region_map : Default :: default ( ) ,
@@ -718,19 +718,19 @@ impl<'tcx> TypeckTables<'tcx> {
718718 }
719719 }
720720
721- pub fn cast_kinds ( & self ) -> LocalTableInContext < ' _ , ty:: cast:: CastKind > {
722- LocalTableInContext {
723- local_id_root : self . local_id_root ,
724- data : & self . cast_kinds
725- }
721+ pub fn is_coercion_cast ( & self , hir_id : hir:: HirId ) -> bool {
722+ validate_hir_id_for_typeck_tables ( self . local_id_root , hir_id, true ) ;
723+ self . coercion_casts . contains ( & hir_id. local_id )
726724 }
727725
728- pub fn cast_kinds_mut ( & mut self ) -> LocalTableInContextMut < ' _ , ty:: cast:: CastKind > {
729- LocalTableInContextMut {
730- local_id_root : self . local_id_root ,
731- data : & mut self . cast_kinds
732- }
726+ pub fn set_coercion_cast ( & mut self , id : ItemLocalId ) {
727+ self . coercion_casts . insert ( id) ;
728+ }
729+
730+ pub fn coercion_casts ( & self ) -> & ItemLocalSet {
731+ & self . coercion_casts
733732 }
733+
734734}
735735
736736impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > > for TypeckTables < ' gcx > {
@@ -753,7 +753,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
753753 ref liberated_fn_sigs,
754754 ref fru_field_types,
755755
756- ref cast_kinds ,
756+ ref coercion_casts ,
757757
758758 ref used_trait_imports,
759759 tainted_by_errors,
@@ -798,7 +798,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
798798 closure_kind_origins. hash_stable ( hcx, hasher) ;
799799 liberated_fn_sigs. hash_stable ( hcx, hasher) ;
800800 fru_field_types. hash_stable ( hcx, hasher) ;
801- cast_kinds . hash_stable ( hcx, hasher) ;
801+ coercion_casts . hash_stable ( hcx, hasher) ;
802802 used_trait_imports. hash_stable ( hcx, hasher) ;
803803 tainted_by_errors. hash_stable ( hcx, hasher) ;
804804 free_region_map. hash_stable ( hcx, hasher) ;
0 commit comments