diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-09 21:53:34 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-09 21:53:34 -0800 |
| commit | e5ecf629dd0e36e0aab9c664c7a3d11d592268c9 (patch) | |
| tree | 2ff22bd0aadd6db62d7e4ea9255d24092957f02e /compiler/rustc_errors/src | |
| parent | 5eef9b2c50ddd4e445c10043908f785b08456489 (diff) | |
| parent | 9568138069cce7915eb35386f8d9e020adcd599b (diff) | |
| download | rust-e5ecf629dd0e36e0aab9c664c7a3d11d592268c9.tar.gz rust-e5ecf629dd0e36e0aab9c664c7a3d11d592268c9.zip | |
Rollup merge of #102763 - compiler-errors:nits, r=cjgillot
Some diagnostic-related nits 1. Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` 2. Make `diag.span_suggestions` take an `IntoIterator` instead of `Iterator`, just to remove some `.into_iter` calls on the caller. idk if I should add a lint to make sure people use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` in cases where we're just, e.g., adding subdiagnostics to the diagnostic... maybe a followup.
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_builder.rs | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 43101bbb9d3..375e3ebd77d 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -742,7 +742,7 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into<SubdiagnosticMessage>, - suggestions: impl Iterator<Item = String>, + suggestions: impl IntoIterator<Item = String>, applicability: Applicability, ) -> &mut Self { self.span_suggestions_with_style( @@ -759,11 +759,11 @@ impl Diagnostic { &mut self, sp: Span, msg: impl Into<SubdiagnosticMessage>, - suggestions: impl Iterator<Item = String>, + suggestions: impl IntoIterator<Item = String>, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self { - let mut suggestions: Vec<_> = suggestions.collect(); + let mut suggestions: Vec<_> = suggestions.into_iter().collect(); suggestions.sort(); debug_assert!( @@ -790,10 +790,10 @@ impl Diagnostic { pub fn multipart_suggestions( &mut self, msg: impl Into<SubdiagnosticMessage>, - suggestions: impl Iterator<Item = Vec<(Span, String)>>, + suggestions: impl IntoIterator<Item = Vec<(Span, String)>>, applicability: Applicability, ) -> &mut Self { - let suggestions: Vec<_> = suggestions.collect(); + let suggestions: Vec<_> = suggestions.into_iter().collect(); debug_assert!( !(suggestions .iter() diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 730061fca99..18cbf963494 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -599,13 +599,13 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { &mut self, sp: Span, msg: impl Into<SubdiagnosticMessage>, - suggestions: impl Iterator<Item = String>, + suggestions: impl IntoIterator<Item = String>, applicability: Applicability, ) -> &mut Self); forward!(pub fn multipart_suggestions( &mut self, msg: impl Into<SubdiagnosticMessage>, - suggestions: impl Iterator<Item = Vec<(Span, String)>>, + suggestions: impl IntoIterator<Item = Vec<(Span, String)>>, applicability: Applicability, ) -> &mut Self); forward!(pub fn span_suggestion_short( |
