@@ -41,7 +41,7 @@ use crate::ty::steal::Steal;
41
41
use crate :: ty:: subst:: { UserSubsts , UnpackedKind } ;
42
42
use crate :: ty:: { BoundVar , BindingMode } ;
43
43
use crate :: ty:: CanonicalPolyFnSig ;
44
- use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap } ;
44
+ use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap , ItemLocalSet } ;
45
45
use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
46
46
use errors:: DiagnosticBuilder ;
47
47
use rustc_data_structures:: interner:: HashInterner ;
@@ -409,9 +409,9 @@ pub struct TypeckTables<'tcx> {
409
409
/// MIR construction and hence is not serialized to metadata.
410
410
fru_field_types : ItemLocalMap < Vec < Ty < ' tcx > > > ,
411
411
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 ,
415
415
416
416
/// Set of trait imports actually used in the method resolution.
417
417
/// This is used for warning unused imports. During type
@@ -456,7 +456,7 @@ impl<'tcx> TypeckTables<'tcx> {
456
456
closure_kind_origins : Default :: default ( ) ,
457
457
liberated_fn_sigs : Default :: default ( ) ,
458
458
fru_field_types : Default :: default ( ) ,
459
- cast_kinds : Default :: default ( ) ,
459
+ coercion_casts : Default :: default ( ) ,
460
460
used_trait_imports : Lrc :: new ( Default :: default ( ) ) ,
461
461
tainted_by_errors : false ,
462
462
free_region_map : Default :: default ( ) ,
@@ -718,19 +718,19 @@ impl<'tcx> TypeckTables<'tcx> {
718
718
}
719
719
}
720
720
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 )
726
724
}
727
725
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
733
732
}
733
+
734
734
}
735
735
736
736
impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > > for TypeckTables < ' gcx > {
@@ -753,7 +753,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
753
753
ref liberated_fn_sigs,
754
754
ref fru_field_types,
755
755
756
- ref cast_kinds ,
756
+ ref coercion_casts ,
757
757
758
758
ref used_trait_imports,
759
759
tainted_by_errors,
@@ -798,7 +798,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
798
798
closure_kind_origins. hash_stable ( hcx, hasher) ;
799
799
liberated_fn_sigs. hash_stable ( hcx, hasher) ;
800
800
fru_field_types. hash_stable ( hcx, hasher) ;
801
- cast_kinds . hash_stable ( hcx, hasher) ;
801
+ coercion_casts . hash_stable ( hcx, hasher) ;
802
802
used_trait_imports. hash_stable ( hcx, hasher) ;
803
803
tainted_by_errors. hash_stable ( hcx, hasher) ;
804
804
free_region_map. hash_stable ( hcx, hasher) ;
0 commit comments