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