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
|
||||
}
|
||||
|
||||
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,11 +293,23 @@ impl Diagnostic {
|
|||
}],
|
||||
msg: msg.to_owned(),
|
||||
show_code_when_inline: true,
|
||||
applicability: Applicability::Unspecified,
|
||||
applicability,
|
||||
});
|
||||
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.
|
||||
pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec<String>) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
|
|
|
@ -187,6 +187,23 @@ impl<'a> DiagnosticBuilder<'a> {
|
|||
msg: &str,
|
||||
suggestions: Vec<String>)
|
||||
-> &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,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue