File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,24 @@ impl<'tcx> TyCtxt<'tcx> {
193193 self_ty : Ty < ' tcx > ,
194194 ) -> impl Iterator < Item = DefId > + ' tcx {
195195 let impls = self . trait_impls_of ( trait_def_id) ;
196- if let Some ( simp) = fast_reject:: simplify_type ( self , self_ty, TreatParams :: AsCandidateKey ) {
197- if let Some ( impls) = impls. non_blanket_impls . get ( & simp) {
196+
197+ // Non-blanket impls are grouped into two different maps:
198+ // 1) impls for references to simplifiable types
199+ if let TyKind :: Ref ( _, ref_ty, _) = self_ty. kind ( ) {
200+ if let Some ( simplified_ref_ty) =
201+ fast_reject:: simplify_type ( self , * ref_ty, TreatParams :: AsCandidateKey )
202+ {
203+ if let Some ( impls) = impls. impls_for_ref_x . get ( & simplified_ref_ty) {
204+ return impls. iter ( ) . copied ( ) ;
205+ }
206+ }
207+ }
208+
209+ // 2) the other non-blanket impls
210+ if let Some ( simplified_self_ty) =
211+ fast_reject:: simplify_type ( self , self_ty, TreatParams :: AsCandidateKey )
212+ {
213+ if let Some ( impls) = impls. non_blanket_impls . get ( & simplified_self_ty) {
198214 return impls. iter ( ) . copied ( ) ;
199215 }
200216 }
You can’t perform that action at this time.
0 commit comments