@@ -1296,6 +1296,12 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1296
1296
return false ;
1297
1297
}
1298
1298
1299
+ // Using local cache if the infcx can emit `default impls`
1300
+ if self . infcx . emit_defaul_impl_candidates . get ( ) {
1301
+ return false ;
1302
+ }
1303
+
1304
+
1299
1305
// Otherwise, we can use the global cache.
1300
1306
true
1301
1307
}
@@ -1714,18 +1720,21 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1714
1720
obligation. predicate . def_id ( ) ,
1715
1721
obligation. predicate . 0 . trait_ref . self_ty ( ) ,
1716
1722
|impl_def_id| {
1717
- self . probe ( |this, snapshot| { /* [1] */
1718
- match this. match_impl ( impl_def_id, obligation, snapshot) {
1719
- Ok ( skol_map) => {
1720
- candidates. vec . push ( ImplCandidate ( impl_def_id) ) ;
1721
-
1722
- // NB: we can safely drop the skol map
1723
- // since we are in a probe [1]
1724
- mem:: drop ( skol_map) ;
1723
+ if self . infcx ( ) . emit_defaul_impl_candidates . get ( ) ||
1724
+ !self . tcx ( ) . impl_is_default ( impl_def_id) {
1725
+ self . probe ( |this, snapshot| { /* [1] */
1726
+ match this. match_impl ( impl_def_id, obligation, snapshot) {
1727
+ Ok ( skol_map) => {
1728
+ candidates. vec . push ( ImplCandidate ( impl_def_id) ) ;
1729
+
1730
+ // NB: we can safely drop the skol map
1731
+ // since we are in a probe [1]
1732
+ mem:: drop ( skol_map) ;
1733
+ }
1734
+ Err ( _) => { }
1725
1735
}
1726
- Err ( _) => { }
1727
- }
1728
- } ) ;
1736
+ } ) ;
1737
+ }
1729
1738
}
1730
1739
) ;
1731
1740
0 commit comments