@@ -204,6 +204,7 @@ pub struct Pick<'tcx> {
204
204
/// Indicates that we want to add an autoref (and maybe also unsize it), or if the receiver is
205
205
/// `*mut T`, convert it to `*const T`.
206
206
pub autoref_or_ptr_adjustment : Option < AutorefOrPtrAdjustment < ' tcx > > ,
207
+ pub self_ty : Ty < ' tcx > ,
207
208
}
208
209
209
210
#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -1241,7 +1242,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1241
1242
//
1242
1243
// We suppress warning if we're picking the method only because it is a
1243
1244
// suggestion.
1244
- self . emit_unstable_name_collision_hint ( p, & unstable_candidates, self_ty ) ;
1245
+ self . emit_unstable_name_collision_hint ( p, & unstable_candidates) ;
1245
1246
}
1246
1247
}
1247
1248
return Some ( pick) ;
@@ -1285,7 +1286,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1285
1286
debug ! ( "applicable_candidates: {:?}" , applicable_candidates) ;
1286
1287
1287
1288
if applicable_candidates. len ( ) > 1 {
1288
- if let Some ( pick) = self . collapse_candidates_to_trait_pick ( & applicable_candidates[ ..] ) {
1289
+ if let Some ( pick) =
1290
+ self . collapse_candidates_to_trait_pick ( self_ty, & applicable_candidates[ ..] )
1291
+ {
1289
1292
return Some ( Ok ( pick) ) ;
1290
1293
}
1291
1294
}
@@ -1309,7 +1312,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1309
1312
1310
1313
applicable_candidates. pop ( ) . map ( |( probe, status) | {
1311
1314
if status == ProbeResult :: Match {
1312
- Ok ( probe. to_unadjusted_pick ( ) )
1315
+ Ok ( probe. to_unadjusted_pick ( self_ty ) )
1313
1316
} else {
1314
1317
Err ( MethodError :: BadReturnType )
1315
1318
}
@@ -1320,7 +1323,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1320
1323
& self ,
1321
1324
stable_pick : & Pick < ' _ > ,
1322
1325
unstable_candidates : & [ ( & Candidate < ' tcx > , Symbol ) ] ,
1323
- self_ty : Ty < ' tcx > ,
1324
1326
) {
1325
1327
self . tcx . struct_span_lint_hir (
1326
1328
lint:: builtin:: UNSTABLE_NAME_COLLISIONS ,
@@ -1351,7 +1353,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1351
1353
"use the fully qualified path to the associated const" ,
1352
1354
format ! (
1353
1355
"<{} as {}>::{}" ,
1354
- self_ty,
1356
+ stable_pick . self_ty,
1355
1357
self . tcx. def_path_str( def_id) ,
1356
1358
stable_pick. item. ident
1357
1359
) ,
@@ -1591,6 +1593,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1591
1593
/// use, so it's ok to just commit to "using the method from the trait Foo".
1592
1594
fn collapse_candidates_to_trait_pick (
1593
1595
& self ,
1596
+ self_ty : Ty < ' tcx > ,
1594
1597
probes : & [ ( & Candidate < ' tcx > , ProbeResult ) ] ,
1595
1598
) -> Option < Pick < ' tcx > > {
1596
1599
// Do all probes correspond to the same trait?
@@ -1610,6 +1613,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1610
1613
import_ids : probes[ 0 ] . 0 . import_ids . clone ( ) ,
1611
1614
autoderefs : 0 ,
1612
1615
autoref_or_ptr_adjustment : None ,
1616
+ self_ty,
1613
1617
} )
1614
1618
}
1615
1619
@@ -1828,7 +1832,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1828
1832
}
1829
1833
1830
1834
impl < ' tcx > Candidate < ' tcx > {
1831
- fn to_unadjusted_pick ( & self ) -> Pick < ' tcx > {
1835
+ fn to_unadjusted_pick ( & self , self_ty : Ty < ' tcx > ) -> Pick < ' tcx > {
1832
1836
Pick {
1833
1837
item : self . item ,
1834
1838
kind : match self . kind {
@@ -1852,6 +1856,7 @@ impl<'tcx> Candidate<'tcx> {
1852
1856
import_ids : self . import_ids . clone ( ) ,
1853
1857
autoderefs : 0 ,
1854
1858
autoref_or_ptr_adjustment : None ,
1859
+ self_ty,
1855
1860
}
1856
1861
}
1857
1862
}
0 commit comments