diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-24 18:20:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 18:20:09 +0200 |
| commit | f8e128f8adcdb1c026f47b6ba4db197368122826 (patch) | |
| tree | 16025d4e7f98ebd06306bc69ee8732a7deb824c1 /compiler/rustc_lint/src | |
| parent | 6deca5f067684ddb120bd8897d0e55baafcdd792 (diff) | |
| parent | 3d8c7d2c0a83a7603c3fc4164accfc41a38a5415 (diff) | |
| download | rust-f8e128f8adcdb1c026f47b6ba4db197368122826.tar.gz rust-f8e128f8adcdb1c026f47b6ba4db197368122826.zip | |
Rollup merge of #100826 - vincenzopalazzo:macros/wrong_sugg_with_positional_arg, r=TaKO8Ki
sugg: take into count the debug formatting Closes https://github.com/rust-lang/rust/issues/100648 This PR will fix a suggestion error by taking into consideration also the `:?` symbol and act in a different way ``@rustbot`` r? ``@compiler-errors`` N.B: I did not find a full way to test the change, any idea?
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index b95fc341db6..6586fe440f3 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -865,9 +865,14 @@ pub trait LintContext: Sized { if let Some(positional_arg_to_replace) = position_sp_to_replace { let name = if is_formatting_arg { named_arg_name + "$" } else { named_arg_name }; - + let span_to_replace = if let Ok(positional_arg_content) = + self.sess().source_map().span_to_snippet(positional_arg_to_replace) && positional_arg_content.starts_with(":") { + positional_arg_to_replace.shrink_to_lo() + } else { + positional_arg_to_replace + }; db.span_suggestion_verbose( - positional_arg_to_replace, + span_to_replace, "use the named argument by name to avoid ambiguity", name, Applicability::MaybeIncorrect, |
