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?
This commit is contained in:
commit
f8e128f8ad
3 changed files with 38 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue