Skip to content

Commit 36c774c

Browse files
authored
Unrolled build for rust-lang#117990
Rollup merge of rust-lang#117990 - estebank:issue-100825-part-deux, r=Nilstrieb Tweak error and move tests r? `@Nilstrieb` Split off rust-lang#117565.
2 parents a577704 + 099eb40 commit 36c774c

File tree

65 files changed

+77
-15
lines changed

Some content is hidden

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

65 files changed

+77
-15
lines changed

compiler/rustc_parse/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2278,9 +2278,8 @@ pub(crate) enum InvalidMutInPattern {
22782278
#[note(parse_note_mut_pattern_usage)]
22792279
NonIdent {
22802280
#[primary_span]
2281-
#[suggestion(code = "{pat}", applicability = "machine-applicable")]
2281+
#[suggestion(code = "", applicability = "machine-applicable")]
22822282
span: Span,
2283-
pat: String,
22842283
},
22852284
}
22862285

compiler/rustc_parse/src/parser/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,8 @@ impl<'a> Parser<'a> {
830830
// https://github.com/rust-lang/rust/issues/72373
831831
if self.prev_token.is_ident() && self.token.kind == token::DotDot {
832832
let msg = format!(
833-
"if you meant to bind the contents of \
834-
the rest of the array pattern into `{}`, use `@`",
833+
"if you meant to bind the contents of the rest of the array \
834+
pattern into `{}`, use `@`",
835835
pprust::token_to_string(&self.prev_token)
836836
);
837837
expect_err

compiler/rustc_parse/src/parser/pat.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,13 @@ impl<'a> Parser<'a> {
638638

639639
/// Error on `mut $pat` where `$pat` is not an ident.
640640
fn ban_mut_general_pat(&self, lo: Span, pat: &Pat, changed_any_binding: bool) {
641-
let span = lo.to(pat.span);
642-
let pat = pprust::pat_to_string(&pat);
643-
644641
self.sess.emit_err(if changed_any_binding {
645-
InvalidMutInPattern::NestedIdent { span, pat }
642+
InvalidMutInPattern::NestedIdent {
643+
span: lo.to(pat.span),
644+
pat: pprust::pat_to_string(&pat),
645+
}
646646
} else {
647-
InvalidMutInPattern::NonIdent { span, pat }
647+
InvalidMutInPattern::NonIdent { span: lo.until(pat.span) }
648648
});
649649
}
650650

tests/ui/parser/issues/issue-32501.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: `mut` must be followed by a named binding
22
--> $DIR/issue-32501.rs:7:9
33
|
44
LL | let mut _ = 0;
5-
| ^^^^^ help: remove the `mut` prefix: `_`
5+
| ^^^^ help: remove the `mut` prefix
66
|
77
= note: `mut` may be followed by `variable` and `variable @ pattern`
88

tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: `mut` must be followed by a named binding
22
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:6:13
33
|
44
LL | let mut $eval = ();
5-
| ^^^^^^^^^ help: remove the `mut` prefix: `does_not_exist!()`
5+
| ^^^^ help: remove the `mut` prefix
66
...
77
LL | mac1! { does_not_exist!() }
88
| --------------------------- in this macro invocation
@@ -25,7 +25,7 @@ error: `mut` must be followed by a named binding
2525
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13
2626
|
2727
LL | let mut $eval = ();
28-
| ^^^ help: remove the `mut` prefix: `does_not_exist!()`
28+
| ^^^ help: remove the `mut` prefix
2929
...
3030
LL | mac2! { does_not_exist!() }
3131
| --------------------------- in this macro invocation

tests/ui/parser/mut-patterns.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ error: `mut` must be followed by a named binding
22
--> $DIR/mut-patterns.rs:9:9
33
|
44
LL | let mut _ = 0;
5-
| ^^^^^ help: remove the `mut` prefix: `_`
5+
| ^^^^ help: remove the `mut` prefix
66
|
77
= note: `mut` may be followed by `variable` and `variable @ pattern`
88

99
error: `mut` must be followed by a named binding
1010
--> $DIR/mut-patterns.rs:10:9
1111
|
1212
LL | let mut (_, _) = (0, 0);
13-
| ^^^^^^^^^^ help: remove the `mut` prefix: `(_, _)`
13+
| ^^^^ help: remove the `mut` prefix
1414
|
1515
= note: `mut` may be followed by `variable` and `variable @ pattern`
1616

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn main() {
2+
let val = 42;
3+
let x = match val {
4+
(0 if true) => {
5+
//~^ ERROR expected identifier, found keyword `if`
6+
//~| ERROR expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found keyword `if`
7+
//~| ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `true`
8+
//~| ERROR mismatched types
9+
42u8
10+
}
11+
_ => 0u8,
12+
};
13+
let _y: u32 = x; //~ ERROR mismatched types
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: expected identifier, found keyword `if`
2+
--> $DIR/recover-parens-around-match-arm-head.rs:4:12
3+
|
4+
LL | (0 if true) => {
5+
| ^^ expected identifier, found keyword
6+
7+
error: expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found keyword `if`
8+
--> $DIR/recover-parens-around-match-arm-head.rs:4:12
9+
|
10+
LL | (0 if true) => {
11+
| -^^ expected one of `)`, `,`, `...`, `..=`, `..`, or `|`
12+
| |
13+
| help: missing `,`
14+
15+
error: expected one of `)`, `,`, `@`, or `|`, found keyword `true`
16+
--> $DIR/recover-parens-around-match-arm-head.rs:4:15
17+
|
18+
LL | (0 if true) => {
19+
| -^^^^ expected one of `)`, `,`, `@`, or `|`
20+
| |
21+
| help: missing `,`
22+
23+
error[E0308]: mismatched types
24+
--> $DIR/recover-parens-around-match-arm-head.rs:4:9
25+
|
26+
LL | let x = match val {
27+
| --- this expression has type `{integer}`
28+
LL | (0 if true) => {
29+
| ^^^^^^^^^^^ expected integer, found `(_, _, _)`
30+
|
31+
= note: expected type `{integer}`
32+
found tuple `(_, _, _)`
33+
34+
error[E0308]: mismatched types
35+
--> $DIR/recover-parens-around-match-arm-head.rs:13:19
36+
|
37+
LL | let _y: u32 = x;
38+
| --- ^ expected `u32`, found `u8`
39+
| |
40+
| expected due to this
41+
|
42+
help: you can convert a `u8` to a `u32`
43+
|
44+
LL | let _y: u32 = x.into();
45+
| +++++++
46+
47+
error: aborting due to 5 previous errors
48+
49+
For more information about this error, try `rustc --explain E0308`.

tests/ui/self/self_type_keyword.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error: `mut` must be followed by a named binding
1414
--> $DIR/self_type_keyword.rs:16:9
1515
|
1616
LL | mut Self => (),
17-
| ^^^^^^^^ help: remove the `mut` prefix: `Self`
17+
| ^^^^ help: remove the `mut` prefix
1818
|
1919
= note: `mut` may be followed by `variable` and `variable @ pattern`
2020

0 commit comments

Comments
 (0)