From 4986bbf135d477f73af96ef235407921ce952dc0 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 30 Aug 2021 21:55:10 +0200 Subject: [PATCH] Keep turbofish in prelude collision lint. --- .../src/check/method/prelude2021.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/check/method/prelude2021.rs b/compiler/rustc_typeck/src/check/method/prelude2021.rs index b5bc9d3599ac..384d25ed7718 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, );