]> git.lizzy.rs Git - rust.git/commitdiff
Keep turbofish in prelude collision lint.
authorMara Bos <m-ou.se@m-ou.se>
Mon, 30 Aug 2021 19:55:10 +0000 (21:55 +0200)
committerMara Bos <m-ou.se@m-ou.se>
Mon, 30 Aug 2021 19:55:10 +0000 (21:55 +0200)
compiler/rustc_typeck/src/check/method/prelude2021.rs

index b5bc9d3599acbf78435a0aac31394514e38acaa0..384d25ed7718377b76ccf62314f3bf0504ceaa88 100644 (file)
@@ -163,8 +163,22 @@ pub(super) fn lint_dot_call_from_2018(
                             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,
                         );