diff options
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/parser/increment-autofix.fixed | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/increment-autofix.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/increment-autofix.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/parser/increment-notfixed.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/parser/increment-notfixed.stderr | 8 |
6 files changed, 32 insertions, 24 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index bab4ac9d08a..9bf67231278 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -17,7 +17,7 @@ use rustc_ast::{ }; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed}; +use rustc_errors::{pluralize, struct_span_err, Diagnostic, EmissionGuarantee, ErrorGuaranteed}; use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult}; use rustc_span::source_map::Spanned; use rustc_span::symbol::{kw, Ident}; @@ -225,13 +225,13 @@ struct MultiSugg { } impl MultiSugg { - fn emit(self, err: &mut DiagnosticBuilder<'_>) { + fn emit<G: EmissionGuarantee>(self, err: &mut DiagnosticBuilder<'_, G>) { err.multipart_suggestion(&self.msg, self.patches, self.applicability); } /// Overrides individual messages and applicabilities. - fn emit_many( - err: &mut DiagnosticBuilder<'_>, + fn emit_many<G: EmissionGuarantee>( + err: &mut DiagnosticBuilder<'_, G>, msg: &str, applicability: Applicability, suggestions: impl Iterator<Item = Self>, @@ -1289,7 +1289,7 @@ impl<'a> Parser<'a> { ); err.span_label(op_span, &format!("not a valid {} operator", kind.fixity)); - let help_base_case = |mut err: DiagnosticBuilder<'_>, base| { + let help_base_case = |mut err: DiagnosticBuilder<'_, _>, base| { err.help(&format!("use `{}= 1` instead", kind.op.chr())); err.emit(); Ok(base) diff --git a/src/test/ui/parser/increment-autofix.fixed b/src/test/ui/parser/increment-autofix.fixed index 24a5ac42ca6..7a426badfc2 100644 --- a/src/test/ui/parser/increment-autofix.fixed +++ b/src/test/ui/parser/increment-autofix.fixed @@ -1,12 +1,12 @@ // run-rustfix -fn pre_regular() { +pub fn pre_regular() { let mut i = 0; i += 1; //~ ERROR Rust has no prefix increment operator println!("{}", i); } -fn pre_while() { +pub fn pre_while() { let mut i = 0; while { i += 1; i } < 5 { //~^ ERROR Rust has no prefix increment operator @@ -14,13 +14,13 @@ fn pre_while() { } } -fn pre_regular_tmp() { +pub fn pre_regular_tmp() { let mut tmp = 0; tmp += 1; //~ ERROR Rust has no prefix increment operator println!("{}", tmp); } -fn pre_while_tmp() { +pub fn pre_while_tmp() { let mut tmp = 0; while { tmp += 1; tmp } < 5 { //~^ ERROR Rust has no prefix increment operator diff --git a/src/test/ui/parser/increment-autofix.rs b/src/test/ui/parser/increment-autofix.rs index b1cfd09e9ec..d38603697a7 100644 --- a/src/test/ui/parser/increment-autofix.rs +++ b/src/test/ui/parser/increment-autofix.rs @@ -1,12 +1,12 @@ // run-rustfix -fn pre_regular() { +pub fn pre_regular() { let mut i = 0; ++i; //~ ERROR Rust has no prefix increment operator println!("{}", i); } -fn pre_while() { +pub fn pre_while() { let mut i = 0; while ++i < 5 { //~^ ERROR Rust has no prefix increment operator @@ -14,13 +14,13 @@ fn pre_while() { } } -fn pre_regular_tmp() { +pub fn pre_regular_tmp() { let mut tmp = 0; ++tmp; //~ ERROR Rust has no prefix increment operator println!("{}", tmp); } -fn pre_while_tmp() { +pub fn pre_while_tmp() { let mut tmp = 0; while ++tmp < 5 { //~^ ERROR Rust has no prefix increment operator diff --git a/src/test/ui/parser/increment-autofix.stderr b/src/test/ui/parser/increment-autofix.stderr index a9dc70ad0d6..593592ba4ab 100644 --- a/src/test/ui/parser/increment-autofix.stderr +++ b/src/test/ui/parser/increment-autofix.stderr @@ -14,7 +14,9 @@ error: Rust has no prefix increment operator --> $DIR/increment-autofix.rs:11:11 | LL | while ++i < 5 { - | ^^ not a valid prefix operator + | ----- ^^ not a valid prefix operator + | | + | while parsing the condition of this `while` expression | help: use `+= 1` instead | @@ -37,7 +39,9 @@ error: Rust has no prefix increment operator --> $DIR/increment-autofix.rs:25:11 | LL | while ++tmp < 5 { - | ^^ not a valid prefix operator + | ----- ^^ not a valid prefix operator + | | + | while parsing the condition of this `while` expression | help: use `+= 1` instead | diff --git a/src/test/ui/parser/increment-notfixed.rs b/src/test/ui/parser/increment-notfixed.rs index 543f73bf772..15f159e53d2 100644 --- a/src/test/ui/parser/increment-notfixed.rs +++ b/src/test/ui/parser/increment-notfixed.rs @@ -6,13 +6,13 @@ struct Bar { qux: i32, } -fn post_regular() { +pub fn post_regular() { let mut i = 0; i++; //~ ERROR Rust has no postfix increment operator println!("{}", i); } -fn post_while() { +pub fn post_while() { let mut i = 0; while i++ < 5 { //~^ ERROR Rust has no postfix increment operator @@ -20,13 +20,13 @@ fn post_while() { } } -fn post_regular_tmp() { +pub fn post_regular_tmp() { let mut tmp = 0; tmp++; //~ ERROR Rust has no postfix increment operator println!("{}", tmp); } -fn post_while_tmp() { +pub fn post_while_tmp() { let mut tmp = 0; while tmp++ < 5 { //~^ ERROR Rust has no postfix increment operator @@ -34,14 +34,14 @@ fn post_while_tmp() { } } -fn post_field() { +pub fn post_field() { let foo = Foo { bar: Bar { qux: 0 } }; foo.bar.qux++; //~^ ERROR Rust has no postfix increment operator println!("{}", foo.bar.qux); } -fn post_field_tmp() { +pub fn post_field_tmp() { struct S { tmp: i32 } @@ -51,7 +51,7 @@ fn post_field_tmp() { println!("{}", s.tmp); } -fn pre_field() { +pub fn pre_field() { let foo = Foo { bar: Bar { qux: 0 } }; ++foo.bar.qux; //~^ ERROR Rust has no prefix increment operator diff --git a/src/test/ui/parser/increment-notfixed.stderr b/src/test/ui/parser/increment-notfixed.stderr index 75fce91c6ef..f23595da32a 100644 --- a/src/test/ui/parser/increment-notfixed.stderr +++ b/src/test/ui/parser/increment-notfixed.stderr @@ -16,7 +16,9 @@ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:17:12 | LL | while i++ < 5 { - | ^^ not a valid postfix operator + | ----- ^^ not a valid postfix operator + | | + | while parsing the condition of this `while` expression | help: use `+= 1` instead | @@ -44,7 +46,9 @@ error: Rust has no postfix increment operator --> $DIR/increment-notfixed.rs:31:14 | LL | while tmp++ < 5 { - | ^^ not a valid postfix operator + | ----- ^^ not a valid postfix operator + | | + | while parsing the condition of this `while` expression | help: use `+= 1` instead | |
