@@ -338,18 +338,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
338
338
. unwrap_or ( trait_ref. def_id ( ) ) ;
339
339
let trait_ref = * trait_ref. skip_binder ( ) ;
340
340
341
- let desugaring;
342
- let method;
343
341
let mut flags = vec ! [ ] ;
344
- let direct = match obligation. cause . code {
342
+ match obligation. cause . code {
345
343
ObligationCauseCode :: BuiltinDerivedObligation ( ..) |
346
- ObligationCauseCode :: ImplDerivedObligation ( ..) => false ,
347
- _ => true
348
- } ;
349
- if direct {
350
- // this is a "direct", user-specified, rather than derived,
351
- // obligation.
352
- flags. push ( ( "direct" . to_string ( ) , None ) ) ;
344
+ ObligationCauseCode :: ImplDerivedObligation ( ..) => { }
345
+ _ => {
346
+ // this is a "direct", user-specified, rather than derived,
347
+ // obligation.
348
+ flags. push ( ( "direct" . to_string ( ) , None ) ) ;
349
+ }
353
350
}
354
351
355
352
if let ObligationCauseCode :: ItemObligation ( item) = obligation. cause . code {
@@ -359,21 +356,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
359
356
//
360
357
// Currently I'm leaving it for what I need for `try`.
361
358
if self . tcx . trait_of_item ( item) == Some ( trait_ref. def_id ) {
362
- method = self . tcx . item_name ( item) ;
359
+ let method = self . tcx . item_name ( item) ;
363
360
flags. push ( ( "from_method" . to_string ( ) , None ) ) ;
364
361
flags. push ( ( "from_method" . to_string ( ) , Some ( method. to_string ( ) ) ) ) ;
365
362
}
366
363
}
367
364
368
365
if let Some ( k) = obligation. cause . span . compiler_desugaring_kind ( ) {
369
- desugaring = k. as_symbol ( ) . as_str ( ) ;
366
+ let desugaring = k. as_symbol ( ) . as_str ( ) ;
370
367
flags. push ( ( "from_desugaring" . to_string ( ) , None ) ) ;
371
368
flags. push ( ( "from_desugaring" . to_string ( ) , Some ( desugaring. to_string ( ) ) ) ) ;
372
369
}
373
370
let generics = self . tcx . generics_of ( def_id) ;
374
371
let self_ty = trait_ref. self_ty ( ) ;
375
- let self_ty_str = self_ty. to_string ( ) ;
376
- flags. push ( ( "_Self" . to_string ( ) , Some ( self_ty_str. clone ( ) ) ) ) ;
372
+ // This is also included through the generics list as `Self`,
373
+ // but the parser won't allow you to use it
374
+ flags. push ( ( "_Self" . to_string ( ) , Some ( self_ty. to_string ( ) ) ) ) ;
375
+ if let Some ( def) = self_ty. ty_adt_def ( ) {
376
+ // We also want to be able to select self's original
377
+ // signature with no type arguments resolved
378
+ flags. push ( ( "_Self" . to_string ( ) , Some ( self . tcx . type_of ( def. did ) . to_string ( ) ) ) ) ;
379
+ }
377
380
378
381
for param in generics. types . iter ( ) {
379
382
let name = param. name . as_str ( ) . to_string ( ) ;
0 commit comments