-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usages of span_suggestion without Applicability #54241
Changes from all commits
b6fea32
2f5cb6d
4b05128
959fc61
3be24c6
f395072
6ebb916
0ad1c0e
c61f4a7
2b77760
0269e66
15982fe
d0790c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,7 @@ impl Diagnostic { | |
/// inline it will only show the text message and not the text. | ||
/// | ||
/// See `CodeSuggestion` for more information. | ||
#[deprecated(note = "Use `span_suggestion_short_with_applicability`")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder how this affects other tools that might be using it. They will have to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've prepared a similar pull request for Clippy (with similar style/formatting mistakes), but it may intersect existing Applicability-assigning pull request there. |
||
pub fn span_suggestion_short(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self { | ||
self.suggestions.push(CodeSuggestion { | ||
substitutions: vec![Substitution { | ||
|
@@ -263,6 +264,7 @@ impl Diagnostic { | |
/// * may contain a name of a function, variable or type, but not whole expressions | ||
/// | ||
/// See `CodeSuggestion` for more information. | ||
#[deprecated(note = "Use `span_suggestion_with_applicability`")] | ||
pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self { | ||
self.suggestions.push(CodeSuggestion { | ||
substitutions: vec![Substitution { | ||
|
@@ -278,10 +280,11 @@ impl Diagnostic { | |
self | ||
} | ||
|
||
pub fn multipart_suggestion( | ||
pub fn multipart_suggestion_with_applicability( | ||
&mut self, | ||
msg: &str, | ||
suggestion: Vec<(Span, String)>, | ||
applicability: Applicability, | ||
) -> &mut Self { | ||
self.suggestions.push(CodeSuggestion { | ||
substitutions: vec![Substitution { | ||
|
@@ -292,12 +295,26 @@ impl Diagnostic { | |
}], | ||
msg: msg.to_owned(), | ||
show_code_when_inline: true, | ||
applicability: Applicability::Unspecified, | ||
applicability, | ||
}); | ||
self | ||
} | ||
|
||
#[deprecated(note = "Use `multipart_suggestion_with_applicability`")] | ||
pub fn multipart_suggestion( | ||
&mut self, | ||
msg: &str, | ||
suggestion: Vec<(Span, String)>, | ||
) -> &mut Self { | ||
self.multipart_suggestion_with_applicability( | ||
msg, | ||
suggestion, | ||
Applicability::Unspecified, | ||
) | ||
} | ||
|
||
/// Prints out a message with multiple suggested edits of the code. | ||
#[deprecated(note = "Use `span_suggestions_with_applicability`")] | ||
pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>) -> &mut Self { | ||
self.suggestions.push(CodeSuggestion { | ||
substitutions: suggestions.into_iter().map(|snippet| Substitution { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo fix
will actually try to iteratively apply suggestions when necessary: rust-lang/cargo#5842. IIUC, this will generate the same suggestion over and over again? This should work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@killercup Won't it cause the final code to be something along the lines of
let mut mut mut mut x
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustfix works by replacing specific byte ranges. Once a part of the file has been replaced, rustfix will yell at you when you try to replace it against. cargo-fix will then try to resolve this in some ways (see link above)