@@ -40,7 +40,7 @@ use crate::ty::steal::Steal;
40
40
use crate :: ty:: subst:: { UserSubsts , UnpackedKind } ;
41
41
use crate :: ty:: { BoundVar , BindingMode } ;
42
42
use crate :: ty:: CanonicalPolyFnSig ;
43
- use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap } ;
43
+ use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap , ItemLocalSet } ;
44
44
use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
45
45
use errors:: DiagnosticBuilder ;
46
46
use rustc_data_structures:: interner:: HashInterner ;
@@ -409,9 +409,7 @@ 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
+ coercion_casts : ItemLocalSet ,
415
413
416
414
/// Set of trait imports actually used in the method resolution.
417
415
/// This is used for warning unused imports. During type
@@ -456,7 +454,7 @@ impl<'tcx> TypeckTables<'tcx> {
456
454
closure_kind_origins : Default :: default ( ) ,
457
455
liberated_fn_sigs : Default :: default ( ) ,
458
456
fru_field_types : Default :: default ( ) ,
459
- cast_kinds : Default :: default ( ) ,
457
+ coercion_casts : Default :: default ( ) ,
460
458
used_trait_imports : Lrc :: new ( Default :: default ( ) ) ,
461
459
tainted_by_errors : false ,
462
460
free_region_map : Default :: default ( ) ,
@@ -718,19 +716,17 @@ impl<'tcx> TypeckTables<'tcx> {
718
716
}
719
717
}
720
718
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
719
+ pub fn is_coercion_cast ( & self , hir_id : & hir:: HirId ) -> bool {
720
+ if self . coercion_casts . contains ( & hir_id. local_id ) {
721
+ return true
725
722
}
723
+ false
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 , hir_id : & hir:: HirId ) -> ( ) {
727
+ self . coercion_casts . insert ( hir_id. local_id ) ;
733
728
}
729
+
734
730
}
735
731
736
732
impl < ' a , ' gcx > HashStable < StableHashingContext < ' a > > for TypeckTables < ' gcx > {
@@ -753,7 +749,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
753
749
ref liberated_fn_sigs,
754
750
ref fru_field_types,
755
751
756
- ref cast_kinds ,
752
+ ref coercion_casts ,
757
753
758
754
ref used_trait_imports,
759
755
tainted_by_errors,
@@ -798,7 +794,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> {
798
794
closure_kind_origins. hash_stable ( hcx, hasher) ;
799
795
liberated_fn_sigs. hash_stable ( hcx, hasher) ;
800
796
fru_field_types. hash_stable ( hcx, hasher) ;
801
- cast_kinds . hash_stable ( hcx, hasher) ;
797
+ coercion_casts . hash_stable ( hcx, hasher) ;
802
798
used_trait_imports. hash_stable ( hcx, hasher) ;
803
799
tainted_by_errors. hash_stable ( hcx, hasher) ;
804
800
free_region_map. hash_stable ( hcx, hasher) ;
0 commit comments