@@ -338,18 +338,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
338338 . unwrap_or ( trait_ref. def_id ( ) ) ;
339339 let trait_ref = * trait_ref. skip_binder ( ) ;
340340
341- let desugaring;
342- let method;
343341 let mut flags = vec ! [ ] ;
344- let direct = match obligation. cause . code {
342+ match obligation. cause . code {
345343 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+ }
353350 }
354351
355352 if let ObligationCauseCode :: ItemObligation ( item) = obligation. cause . code {
@@ -359,21 +356,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
359356 //
360357 // Currently I'm leaving it for what I need for `try`.
361358 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) ;
363360 flags. push ( ( "from_method" . to_string ( ) , None ) ) ;
364361 flags. push ( ( "from_method" . to_string ( ) , Some ( method. to_string ( ) ) ) ) ;
365362 }
366363 }
367364
368365 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 ( ) ;
370367 flags. push ( ( "from_desugaring" . to_string ( ) , None ) ) ;
371368 flags. push ( ( "from_desugaring" . to_string ( ) , Some ( desugaring. to_string ( ) ) ) ) ;
372369 }
373370 let generics = self . tcx . generics_of ( def_id) ;
374371 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+ }
377380
378381 for param in generics. types . iter ( ) {
379382 let name = param. name . as_str ( ) . to_string ( ) ;
0 commit comments