Skip to content

Commit 6bb4aad

Browse files
committed
introducing span_suggestion_short_with_applicability
Some would argue that this 40-character method name is ludicrously unwieldy (even ironic), but it's the unique continuation of the precedent set by the other suggestion methods. (And there is some hope that someday we'll just fold `Applicability` into the signature of the "basic" method `span_suggestion`.) This is in support of rust-lang#50723.
1 parent b438449 commit 6bb4aad

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Diff for: src/librustc_errors/diagnostic.rs

+17
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ impl Diagnostic {
311311
self
312312
}
313313

314+
pub fn span_suggestion_short_with_applicability(
315+
&mut self, sp: Span, msg: &str, suggestion: String, applicability: Applicability
316+
) -> &mut Self {
317+
self.suggestions.push(CodeSuggestion {
318+
substitutions: vec![Substitution {
319+
parts: vec![SubstitutionPart {
320+
snippet: suggestion,
321+
span: sp,
322+
}],
323+
}],
324+
msg: msg.to_owned(),
325+
show_code_when_inline: false,
326+
applicability: applicability,
327+
});
328+
self
329+
}
330+
314331
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
315332
self.span = sp.into();
316333
self

Diff for: src/librustc_errors/diagnostic_builder.rs

+6
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ impl<'a> DiagnosticBuilder<'a> {
200200
suggestions: Vec<String>,
201201
applicability: Applicability)
202202
-> &mut Self);
203+
forward!(pub fn span_suggestion_short_with_applicability(&mut self,
204+
sp: Span,
205+
msg: &str,
206+
suggestion: String,
207+
applicability: Applicability)
208+
-> &mut Self);
203209
forward!(pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self);
204210
forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self);
205211

0 commit comments

Comments
 (0)