diff --git a/compiler/rustc_typeck/src/check/method/prelude2021.rs b/compiler/rustc_typeck/src/check/method/prelude2021.rs index b5bc9d3599a..384d25ed771 100644 --- a/compiler/rustc_typeck/src/check/method/prelude2021.rs +++ b/compiler/rustc_typeck/src/check/method/prelude2021.rs @@ -163,8 +163,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sp, "disambiguate the associated function", format!( - "{}::{}({}{})", - trait_name, segment.ident.name, self_adjusted, args + "{}::{}{}({}{})", + trait_name, + segment.ident.name, + if let Some(args) = segment.args.as_ref().and_then(|args| self + .sess() + .source_map() + .span_to_snippet(args.span_ext) + .ok()) + { + // Keep turbofish. + format!("::{}", args) + } else { + String::new() + }, + self_adjusted, + args, ), Applicability::MachineApplicable, );