Skip to content

Commit 4943688

Browse files
committed
Fix from rebase
I changed the test functions to be `pub` rather than called from a `main` function too, for easier future modification of tests.
1 parent 86220d6 commit 4943688

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_ast::{
1717
};
1818
use rustc_ast_pretty::pprust;
1919
use rustc_data_structures::fx::FxHashSet;
20-
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
20+
use rustc_errors::{pluralize, struct_span_err, Diagnostic, EmissionGuarantee, ErrorGuaranteed};
2121
use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult};
2222
use rustc_span::source_map::Spanned;
2323
use rustc_span::symbol::{kw, Ident};
@@ -225,13 +225,13 @@ struct MultiSugg {
225225
}
226226

227227
impl MultiSugg {
228-
fn emit(self, err: &mut DiagnosticBuilder<'_>) {
228+
fn emit<G: EmissionGuarantee>(self, err: &mut DiagnosticBuilder<'_, G>) {
229229
err.multipart_suggestion(&self.msg, self.patches, self.applicability);
230230
}
231231

232232
/// Overrides individual messages and applicabilities.
233-
fn emit_many(
234-
err: &mut DiagnosticBuilder<'_>,
233+
fn emit_many<G: EmissionGuarantee>(
234+
err: &mut DiagnosticBuilder<'_, G>,
235235
msg: &str,
236236
applicability: Applicability,
237237
suggestions: impl Iterator<Item = Self>,
@@ -1289,7 +1289,7 @@ impl<'a> Parser<'a> {
12891289
);
12901290
err.span_label(op_span, &format!("not a valid {} operator", kind.fixity));
12911291

1292-
let help_base_case = |mut err: DiagnosticBuilder<'_>, base| {
1292+
let help_base_case = |mut err: DiagnosticBuilder<'_, _>, base| {
12931293
err.help(&format!("use `{}= 1` instead", kind.op.chr()));
12941294
err.emit();
12951295
Ok(base)

src/test/ui/parser/increment-autofix.fixed

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
// run-rustfix
22

3-
fn pre_regular() {
3+
pub fn pre_regular() {
44
let mut i = 0;
55
i += 1; //~ ERROR Rust has no prefix increment operator
66
println!("{}", i);
77
}
88

9-
fn pre_while() {
9+
pub fn pre_while() {
1010
let mut i = 0;
1111
while { i += 1; i } < 5 {
1212
//~^ ERROR Rust has no prefix increment operator
1313
println!("{}", i);
1414
}
1515
}
1616

17-
fn pre_regular_tmp() {
17+
pub fn pre_regular_tmp() {
1818
let mut tmp = 0;
1919
tmp += 1; //~ ERROR Rust has no prefix increment operator
2020
println!("{}", tmp);
2121
}
2222

23-
fn pre_while_tmp() {
23+
pub fn pre_while_tmp() {
2424
let mut tmp = 0;
2525
while { tmp += 1; tmp } < 5 {
2626
//~^ ERROR Rust has no prefix increment operator

src/test/ui/parser/increment-autofix.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
// run-rustfix
22

3-
fn pre_regular() {
3+
pub fn pre_regular() {
44
let mut i = 0;
55
++i; //~ ERROR Rust has no prefix increment operator
66
println!("{}", i);
77
}
88

9-
fn pre_while() {
9+
pub fn pre_while() {
1010
let mut i = 0;
1111
while ++i < 5 {
1212
//~^ ERROR Rust has no prefix increment operator
1313
println!("{}", i);
1414
}
1515
}
1616

17-
fn pre_regular_tmp() {
17+
pub fn pre_regular_tmp() {
1818
let mut tmp = 0;
1919
++tmp; //~ ERROR Rust has no prefix increment operator
2020
println!("{}", tmp);
2121
}
2222

23-
fn pre_while_tmp() {
23+
pub fn pre_while_tmp() {
2424
let mut tmp = 0;
2525
while ++tmp < 5 {
2626
//~^ ERROR Rust has no prefix increment operator

src/test/ui/parser/increment-autofix.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ error: Rust has no prefix increment operator
1414
--> $DIR/increment-autofix.rs:11:11
1515
|
1616
LL | while ++i < 5 {
17-
| ^^ not a valid prefix operator
17+
| ----- ^^ not a valid prefix operator
18+
| |
19+
| while parsing the condition of this `while` expression
1820
|
1921
help: use `+= 1` instead
2022
|
@@ -37,7 +39,9 @@ error: Rust has no prefix increment operator
3739
--> $DIR/increment-autofix.rs:25:11
3840
|
3941
LL | while ++tmp < 5 {
40-
| ^^ not a valid prefix operator
42+
| ----- ^^ not a valid prefix operator
43+
| |
44+
| while parsing the condition of this `while` expression
4145
|
4246
help: use `+= 1` instead
4347
|

src/test/ui/parser/increment-notfixed.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,42 @@ struct Bar {
66
qux: i32,
77
}
88

9-
fn post_regular() {
9+
pub fn post_regular() {
1010
let mut i = 0;
1111
i++; //~ ERROR Rust has no postfix increment operator
1212
println!("{}", i);
1313
}
1414

15-
fn post_while() {
15+
pub fn post_while() {
1616
let mut i = 0;
1717
while i++ < 5 {
1818
//~^ ERROR Rust has no postfix increment operator
1919
println!("{}", i);
2020
}
2121
}
2222

23-
fn post_regular_tmp() {
23+
pub fn post_regular_tmp() {
2424
let mut tmp = 0;
2525
tmp++; //~ ERROR Rust has no postfix increment operator
2626
println!("{}", tmp);
2727
}
2828

29-
fn post_while_tmp() {
29+
pub fn post_while_tmp() {
3030
let mut tmp = 0;
3131
while tmp++ < 5 {
3232
//~^ ERROR Rust has no postfix increment operator
3333
println!("{}", tmp);
3434
}
3535
}
3636

37-
fn post_field() {
37+
pub fn post_field() {
3838
let foo = Foo { bar: Bar { qux: 0 } };
3939
foo.bar.qux++;
4040
//~^ ERROR Rust has no postfix increment operator
4141
println!("{}", foo.bar.qux);
4242
}
4343

44-
fn post_field_tmp() {
44+
pub fn post_field_tmp() {
4545
struct S {
4646
tmp: i32
4747
}
@@ -51,7 +51,7 @@ fn post_field_tmp() {
5151
println!("{}", s.tmp);
5252
}
5353

54-
fn pre_field() {
54+
pub fn pre_field() {
5555
let foo = Foo { bar: Bar { qux: 0 } };
5656
++foo.bar.qux;
5757
//~^ ERROR Rust has no prefix increment operator

src/test/ui/parser/increment-notfixed.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ error: Rust has no postfix increment operator
1616
--> $DIR/increment-notfixed.rs:17:12
1717
|
1818
LL | while i++ < 5 {
19-
| ^^ not a valid postfix operator
19+
| ----- ^^ not a valid postfix operator
20+
| |
21+
| while parsing the condition of this `while` expression
2022
|
2123
help: use `+= 1` instead
2224
|
@@ -44,7 +46,9 @@ error: Rust has no postfix increment operator
4446
--> $DIR/increment-notfixed.rs:31:14
4547
|
4648
LL | while tmp++ < 5 {
47-
| ^^ not a valid postfix operator
49+
| ----- ^^ not a valid postfix operator
50+
| |
51+
| while parsing the condition of this `while` expression
4852
|
4953
help: use `+= 1` instead
5054
|

0 commit comments

Comments
 (0)