Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 34d1963

Browse files
committedAug 12, 2021
Use smaller spans for some structured suggestions
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
1 parent eb2226b commit 34d1963

File tree

60 files changed

+1200
-958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1200
-958
lines changed
 

‎compiler/rustc_errors/src/diagnostic.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,21 @@ impl Diagnostic {
298298
)
299299
}
300300

301+
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
302+
/// In other words, multiple changes need to be applied as part of this suggestion.
303+
pub fn multipart_suggestion_verbose(
304+
&mut self,
305+
msg: &str,
306+
suggestion: Vec<(Span, String)>,
307+
applicability: Applicability,
308+
) -> &mut Self {
309+
self.multipart_suggestion_with_style(
310+
msg,
311+
suggestion,
312+
applicability,
313+
SuggestionStyle::ShowAlways,
314+
)
315+
}
301316
/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
302317
pub fn multipart_suggestion_with_style(
303318
&mut self,

‎compiler/rustc_errors/src/diagnostic_builder.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,20 @@ impl<'a> DiagnosticBuilder<'a> {
257257
self
258258
}
259259

260+
/// See [`Diagnostic::multipart_suggestion()`].
261+
pub fn multipart_suggestion_verbose(
262+
&mut self,
263+
msg: &str,
264+
suggestion: Vec<(Span, String)>,
265+
applicability: Applicability,
266+
) -> &mut Self {
267+
if !self.0.allow_suggestions {
268+
return self;
269+
}
270+
self.0.diagnostic.multipart_suggestion_verbose(msg, suggestion, applicability);
271+
self
272+
}
273+
260274
/// See [`Diagnostic::tool_only_multipart_suggestion()`].
261275
pub fn tool_only_multipart_suggestion(
262276
&mut self,

0 commit comments

Comments
 (0)
Please sign in to comment.