@@ -18,6 +18,7 @@ use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
18
18
use rustc_infer:: traits:: ObligationCauseCode ;
19
19
use rustc_middle:: middle:: stability;
20
20
use rustc_middle:: query:: Providers ;
21
+ use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
21
22
use rustc_middle:: ty:: fast_reject:: { simplify_type, TreatParams } ;
22
23
use rustc_middle:: ty:: AssocItem ;
23
24
use rustc_middle:: ty:: AssocItemContainer ;
@@ -664,7 +665,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
664
665
665
666
#[ instrument( level = "debug" , skip( self ) ) ]
666
667
fn assemble_probe ( & mut self , self_ty : & Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ) {
667
- let raw_self_ty = self_ty. value . value ;
668
+ let ( QueryResponse { value : raw_self_ty, .. } , _) =
669
+ self . instantiate_canonical ( DUMMY_SP , self_ty) ;
668
670
match * raw_self_ty. kind ( ) {
669
671
ty:: Dynamic ( data, ..) if let Some ( p) = data. principal ( ) => {
670
672
// Subtle: we can't use `instantiate_query_response` here: using it will
@@ -709,6 +711,47 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
709
711
ty:: Param ( p) => {
710
712
self . assemble_inherent_candidates_from_param ( p) ;
711
713
}
714
+ // which have some integer or float as a self type.
715
+ ty:: Infer ( ty:: IntVar ( _) ) => {
716
+ use ty:: IntTy :: * ;
717
+ use ty:: UintTy :: * ;
718
+ // This causes a compiler error if any new integer kinds are added.
719
+ let ( I8 | I16 | I32 | I64 | I128 | Isize ) : ty:: IntTy ;
720
+ let ( U8 | U16 | U32 | U64 | U128 | Usize ) : ty:: UintTy ;
721
+ let possible_integers = [
722
+ // signed integers
723
+ SimplifiedType :: Int ( I8 ) ,
724
+ SimplifiedType :: Int ( I16 ) ,
725
+ SimplifiedType :: Int ( I32 ) ,
726
+ SimplifiedType :: Int ( I64 ) ,
727
+ SimplifiedType :: Int ( I128 ) ,
728
+ SimplifiedType :: Int ( Isize ) ,
729
+ // unsigned integers
730
+ SimplifiedType :: Uint ( U8 ) ,
731
+ SimplifiedType :: Uint ( U16 ) ,
732
+ SimplifiedType :: Uint ( U32 ) ,
733
+ SimplifiedType :: Uint ( U64 ) ,
734
+ SimplifiedType :: Uint ( U128 ) ,
735
+ SimplifiedType :: Uint ( Usize ) ,
736
+ ] ;
737
+ for simp in possible_integers {
738
+ self . assemble_inherent_candidates_for_simplified_type ( simp) ;
739
+ }
740
+ }
741
+ ty:: Infer ( ty:: FloatVar ( _) ) => {
742
+ // This causes a compiler error if any new float kinds are added.
743
+ let ( ty:: FloatTy :: F16 | ty:: FloatTy :: F32 | ty:: FloatTy :: F64 | ty:: FloatTy :: F128 ) ;
744
+ let possible_floats = [
745
+ SimplifiedType :: Float ( ty:: FloatTy :: F16 ) ,
746
+ SimplifiedType :: Float ( ty:: FloatTy :: F32 ) ,
747
+ SimplifiedType :: Float ( ty:: FloatTy :: F64 ) ,
748
+ SimplifiedType :: Float ( ty:: FloatTy :: F128 ) ,
749
+ ] ;
750
+
751
+ for simp in possible_floats {
752
+ self . assemble_inherent_candidates_for_simplified_type ( simp) ;
753
+ }
754
+ }
712
755
ty:: Bool
713
756
| ty:: Char
714
757
| ty:: Int ( _)
@@ -729,6 +772,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
729
772
let Some ( simp) = simplify_type ( self . tcx , self_ty, TreatParams :: AsCandidateKey ) else {
730
773
bug ! ( "unexpected incoherent type: {:?}" , self_ty)
731
774
} ;
775
+ self . assemble_inherent_candidates_for_simplified_type ( simp) ;
776
+ }
777
+
778
+ fn assemble_inherent_candidates_for_simplified_type ( & mut self , simp : SimplifiedType ) {
732
779
for & impl_def_id in self . tcx . incoherent_impls ( simp) . into_iter ( ) . flatten ( ) {
733
780
self . assemble_inherent_impl_probe ( impl_def_id) ;
734
781
}
0 commit comments