@@ -501,8 +501,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
501501 Some ( InferOk { obligations, value : callee } )
502502 }
503503
504- /// Performs "universal function call" lookup. If lookup is successful, it will return the type
505- /// of definition and the [`DefId`] of the found function definition.
504+ /// Performs a [full-qualified function call] (formerly "universal function call") lookup. If
505+ /// lookup is successful, it will return the type of definition and the [`DefId`] of the found
506+ /// function definition.
507+ ///
508+ /// [full-qualified function call]: https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls
506509 ///
507510 /// # Arguments
508511 ///
@@ -512,17 +515,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
512515 /// * `span`: the span of the call, excluding arguments (`Foo::bar::<T1, ...Tn>`)
513516 /// * `method_name`: the identifier of the function within the container type (`bar`)
514517 /// * `self_ty`: the type to search within (`Foo`)
518+ /// * `self_ty_span` the span for the type being searched within (span of `Foo`)
515519 /// * `expr_id`: the [`hir::HirId`] of the expression composing the entire call
516520 #[ instrument( level = "debug" , skip( self ) ) ]
517- pub fn resolve_ufcs (
521+ pub fn resolve_fully_qualified_call (
518522 & self ,
519523 span : Span ,
520524 method_name : Ident ,
521525 self_ty : Ty < ' tcx > ,
526+ self_ty_span : Span ,
522527 expr_id : hir:: HirId ,
523528 ) -> Result < ( DefKind , DefId ) , MethodError < ' tcx > > {
524529 debug ! (
525- "resolve_ufcs : method_name={:?} self_ty={:?} expr_id={:?}" ,
530+ "resolve_fully_qualified_call : method_name={:?} self_ty={:?} expr_id={:?}" ,
526531 method_name, self_ty, expr_id,
527532 ) ;
528533
@@ -589,6 +594,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
589594 method_name. name
590595 ) ) ;
591596
597+ let self_ty = self
598+ . sess ( )
599+ . source_map ( )
600+ . span_to_snippet ( self_ty_span)
601+ . unwrap_or_else ( |_| self_ty. to_string ( ) ) ;
602+
592603 lint. span_suggestion (
593604 span,
594605 "disambiguate the associated function" ,
@@ -602,18 +613,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
602613 }
603614 }
604615
605- debug ! ( "resolve_ufcs : pick={:?}" , pick) ;
616+ debug ! ( "resolve_fully_qualified_call : pick={:?}" , pick) ;
606617 {
607618 let mut typeck_results = self . typeck_results . borrow_mut ( ) ;
608619 let used_trait_imports = Lrc :: get_mut ( & mut typeck_results. used_trait_imports ) . unwrap ( ) ;
609620 for import_id in pick. import_ids {
610- debug ! ( "resolve_ufcs : used_trait_import: {:?}" , import_id) ;
621+ debug ! ( "resolve_fully_qualified_call : used_trait_import: {:?}" , import_id) ;
611622 used_trait_imports. insert ( import_id) ;
612623 }
613624 }
614625
615626 let def_kind = pick. item . kind . as_def_kind ( ) ;
616- debug ! ( "resolve_ufcs: def_kind={:?}, def_id={:?}" , def_kind, pick. item. def_id) ;
627+ debug ! (
628+ "resolve_fully_qualified_call: def_kind={:?}, def_id={:?}" ,
629+ def_kind, pick. item. def_id
630+ ) ;
617631 tcx. check_stability ( pick. item . def_id , Some ( expr_id) , span, Some ( method_name. span ) ) ;
618632 Ok ( ( def_kind, pick. item . def_id ) )
619633 }
0 commit comments