Add multipart_suggestion_with_applicability
This commit is contained in:
parent
b6fea3255c
commit
2f5cb6dbdc
2 changed files with 32 additions and 2 deletions
|
@ -278,10 +278,11 @@ impl Diagnostic {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multipart_suggestion(
|
pub fn multipart_suggestion_with_applicability(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
suggestion: Vec<(Span, String)>,
|
suggestion: Vec<(Span, String)>,
|
||||||
|
applicability: Applicability,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.suggestions.push(CodeSuggestion {
|
self.suggestions.push(CodeSuggestion {
|
||||||
substitutions: vec![Substitution {
|
substitutions: vec![Substitution {
|
||||||
|
@ -292,11 +293,23 @@ impl Diagnostic {
|
||||||
}],
|
}],
|
||||||
msg: msg.to_owned(),
|
msg: msg.to_owned(),
|
||||||
show_code_when_inline: true,
|
show_code_when_inline: true,
|
||||||
applicability: Applicability::Unspecified,
|
applicability,
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
/// Prints out a message with multiple suggested edits of the code.
|
||||||
pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>) -> &mut Self {
|
pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>) -> &mut Self {
|
||||||
self.suggestions.push(CodeSuggestion {
|
self.suggestions.push(CodeSuggestion {
|
||||||
|
|
|
@ -187,6 +187,23 @@ impl<'a> DiagnosticBuilder<'a> {
|
||||||
msg: &str,
|
msg: &str,
|
||||||
suggestions: Vec<String>)
|
suggestions: Vec<String>)
|
||||||
-> &mut Self);
|
-> &mut Self);
|
||||||
|
|
||||||
|
pub fn multipart_suggestion_with_applicability(&mut self,
|
||||||
|
msg: &str,
|
||||||
|
suggestion: Vec<(Span, String)>,
|
||||||
|
applicability: Applicability)
|
||||||
|
-> &mut Self {
|
||||||
|
if !self.allow_suggestions {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
self.diagnostic.multipart_suggestion_with_applicability(
|
||||||
|
msg,
|
||||||
|
suggestion,
|
||||||
|
applicability,
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn span_suggestion_with_applicability(&mut self,
|
pub fn span_suggestion_with_applicability(&mut self,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue