Skip to content

Commit

Permalink
Fix from rebase
Browse files Browse the repository at this point in the history
I changed the test functions to be `pub` rather than called from a
`main` function too, for easier future modification of tests.
  • Loading branch information
camelid committed Mar 27, 2022
1 parent 86220d6 commit 4943688
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
10 changes: 5 additions & 5 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/parser/increment-autofix.fixed
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// 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
println!("{}", i);
}
}

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
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/parser/increment-autofix.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// 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
println!("{}", i);
}
}

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
Expand Down
8 changes: 6 additions & 2 deletions src/test/ui/parser/increment-autofix.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand All @@ -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
|
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/parser/increment-notfixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ 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
println!("{}", i);
}
}

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
println!("{}", 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
}
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/test/ui/parser/increment-notfixed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down Expand Up @@ -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
|
Expand Down

0 comments on commit 4943688

Please sign in to comment.