review comments
This commit is contained in:
parent
02f57f83a9
commit
76456e7406
@ -304,6 +304,24 @@ impl Diagnostic {
|
||||
msg: &str,
|
||||
suggestion: String,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
self.span_suggestion_with_style(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
SuggestionStyle::ShowCode,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn span_suggestion_with_style(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
suggestion: String,
|
||||
applicability: Applicability,
|
||||
style: SuggestionStyle,
|
||||
) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
@ -313,7 +331,7 @@ impl Diagnostic {
|
||||
}],
|
||||
}],
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::ShowCode,
|
||||
style,
|
||||
applicability,
|
||||
});
|
||||
self
|
||||
@ -326,17 +344,13 @@ impl Diagnostic {
|
||||
suggestion: String,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
snippet: suggestion,
|
||||
span: sp,
|
||||
}],
|
||||
}],
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::ShowAlways,
|
||||
self.span_suggestion_with_style(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
});
|
||||
SuggestionStyle::ShowAlways,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
@ -369,17 +383,13 @@ impl Diagnostic {
|
||||
pub fn span_suggestion_short(
|
||||
&mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
|
||||
) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
snippet: suggestion,
|
||||
span: sp,
|
||||
}],
|
||||
}],
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::HideCodeInline,
|
||||
self.span_suggestion_with_style(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
});
|
||||
SuggestionStyle::HideCodeInline,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
@ -392,17 +402,13 @@ impl Diagnostic {
|
||||
pub fn span_suggestion_hidden(
|
||||
&mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
|
||||
) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
snippet: suggestion,
|
||||
span: sp,
|
||||
}],
|
||||
}],
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::HideCodeAlways,
|
||||
self.span_suggestion_with_style(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
});
|
||||
SuggestionStyle::HideCodeAlways,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
@ -413,17 +419,13 @@ impl Diagnostic {
|
||||
pub fn tool_only_span_suggestion(
|
||||
&mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
|
||||
) -> &mut Self {
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: vec![SubstitutionPart {
|
||||
snippet: suggestion,
|
||||
span: sp,
|
||||
}],
|
||||
}],
|
||||
msg: msg.to_owned(),
|
||||
style: SuggestionStyle::CompletelyHidden,
|
||||
self.span_suggestion_with_style(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
});
|
||||
SuggestionStyle::CompletelyHidden,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -218,12 +218,14 @@ pub trait Emitter {
|
||||
sugg.msg.split_whitespace().count() < 10 &&
|
||||
// don't display multiline suggestions as labels
|
||||
!sugg.substitutions[0].parts[0].snippet.contains('\n') &&
|
||||
// when this style is set we want the suggestion to be a message, not inline
|
||||
sugg.style != SuggestionStyle::HideCodeAlways &&
|
||||
// trivial suggestion for tooling's sake, never shown
|
||||
sugg.style != SuggestionStyle::CompletelyHidden &&
|
||||
// subtle suggestion, never shown inline
|
||||
sugg.style != SuggestionStyle::ShowAlways
|
||||
![
|
||||
// when this style is set we want the suggestion to be a message, not inline
|
||||
SuggestionStyle::HideCodeAlways,
|
||||
// trivial suggestion for tooling's sake, never shown
|
||||
SuggestionStyle::CompletelyHidden,
|
||||
// subtle suggestion, never shown inline
|
||||
SuggestionStyle::ShowAlways,
|
||||
].contains(&sugg.style)
|
||||
{
|
||||
let substitution = &sugg.substitutions[0].parts[0].snippet.trim();
|
||||
let msg = if substitution.len() == 0 || sugg.style.hide_inline() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user