mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Expose hidden snippet suggestions
This commit is contained in:
@@ -323,6 +323,29 @@ pub fn span_suggestion_short(
|
||||
self
|
||||
}
|
||||
|
||||
/// Prints out a message with for a suggestion without showing the suggested code.
|
||||
///
|
||||
/// This is intended to be used for suggestions that are obvious in what the changes need to
|
||||
/// be from the message, showing the span label inline would be visually unpleasant
|
||||
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
|
||||
/// improve understandability.
|
||||
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::HideCodeInline,
|
||||
applicability: applicability,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
|
||||
self.span = sp.into();
|
||||
self
|
||||
|
||||
@@ -261,6 +261,26 @@ pub fn span_suggestion_short(
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn span_suggestion_hidden(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
suggestion: String,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
if !self.allow_suggestions {
|
||||
return self
|
||||
}
|
||||
self.diagnostic.span_suggestion_hidden(
|
||||
sp,
|
||||
msg,
|
||||
suggestion,
|
||||
applicability,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self);
|
||||
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user