@@ -339,18 +339,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
339339 . unwrap_or ( trait_ref. def_id ( ) ) ;
340340 let trait_ref = * trait_ref. skip_binder ( ) ;
341341
342- let desugaring;
343- let method;
344342 let mut flags = vec ! [ ] ;
345- let direct = match obligation. cause . code {
343+ match obligation. cause . code {
346344 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+ }
354351 }
355352
356353 if let ObligationCauseCode :: ItemObligation ( item) = obligation. cause . code {
@@ -360,21 +357,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
360357 //
361358 // Currently I'm leaving it for what I need for `try`.
362359 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) ;
364361 flags. push ( ( "from_method" . to_string ( ) , None ) ) ;
365362 flags. push ( ( "from_method" . to_string ( ) , Some ( method. to_string ( ) ) ) ) ;
366363 }
367364 }
368365
369366 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 ( ) ;
371368 flags. push ( ( "from_desugaring" . to_string ( ) , None ) ) ;
372369 flags. push ( ( "from_desugaring" . to_string ( ) , Some ( desugaring. to_string ( ) ) ) ) ;
373370 }
374371 let generics = self . tcx . generics_of ( def_id) ;
375372 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+ }
378381
379382 for param in generics. types . iter ( ) {
380383 let name = param. name . as_str ( ) . to_string ( ) ;
0 commit comments