Skip to content

Commit 5689f9c

Browse files
committed
fix tests and code cleanup
1 parent 952df48 commit 5689f9c

File tree

3 files changed

+71
-21
lines changed

3 files changed

+71
-21
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,11 +1816,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
18161816
if let Some(Expr { kind: ExprKind::Assign(lhs, rhs, _), .. }) =
18171817
self.diagnostic_metadata.in_assignment
18181818
{
1819-
let is_rhs_assign = match rhs.kind {
1820-
ExprKind::Assign(..) => true,
1821-
_ => false,
1822-
};
1823-
1819+
let is_rhs_assign = matches!(rhs.kind, ExprKind::Assign(..));
18241820
if let ast::ExprKind::Path(None, _) = lhs.kind && !is_rhs_assign {
18251821
let sm = self.r.session.source_map();
18261822
let line_span = sm.span_extend_to_line(ident_span);
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
// error-pattern: not found in this scope
2-
31
fn main() {
42
x = x = x;
3+
//~^ ERROR cannot find value `x` in this scope
4+
//~| ERROR cannot find value `x` in this scope
5+
//~| ERROR cannot find value `x` in this scope
6+
57
x = y = y = y;
8+
//~^ ERROR cannot find value `y` in this scope
9+
//~| ERROR cannot find value `y` in this scope
10+
//~| ERROR cannot find value `y` in this scope
11+
//~| ERROR cannot find value `x` in this scope
12+
613
x = y = y;
14+
//~^ ERROR cannot find value `x` in this scope
15+
//~| ERROR cannot find value `y` in this scope
16+
//~| ERROR cannot find value `y` in this scope
17+
718
x = x = y;
19+
//~^ ERROR cannot find value `x` in this scope
20+
//~| ERROR cannot find value `x` in this scope
21+
//~| ERROR cannot find value `y` in this scope
22+
823
x = x; // will suggest add `let`
24+
//~^ ERROR cannot find value `x` in this scope
25+
//~| ERROR cannot find value `x` in this scope
26+
927
x = y // will suggest add `let`
28+
//~^ ERROR cannot find value `x` in this scope
29+
//~| ERROR cannot find value `y` in this scope
1030
}
Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,115 @@
11
error[E0425]: cannot find value `x` in this scope
2-
--> $DIR/issue-104086-suggest-let.rs:4:5
2+
--> $DIR/issue-104086-suggest-let.rs:2:5
33
|
44
LL | x = x = x;
55
| ^ not found in this scope
66

77
error[E0425]: cannot find value `x` in this scope
8-
--> $DIR/issue-104086-suggest-let.rs:4:9
8+
--> $DIR/issue-104086-suggest-let.rs:2:9
99
|
1010
LL | x = x = x;
1111
| ^ not found in this scope
1212

1313
error[E0425]: cannot find value `x` in this scope
14-
--> $DIR/issue-104086-suggest-let.rs:4:13
14+
--> $DIR/issue-104086-suggest-let.rs:2:13
1515
|
1616
LL | x = x = x;
1717
| ^ not found in this scope
1818

1919
error[E0425]: cannot find value `x` in this scope
20-
--> $DIR/issue-104086-suggest-let.rs:5:5
20+
--> $DIR/issue-104086-suggest-let.rs:7:5
2121
|
2222
LL | x = y = y = y;
2323
| ^ not found in this scope
2424

2525
error[E0425]: cannot find value `y` in this scope
26-
--> $DIR/issue-104086-suggest-let.rs:5:9
26+
--> $DIR/issue-104086-suggest-let.rs:7:9
2727
|
2828
LL | x = y = y = y;
2929
| ^ not found in this scope
3030

3131
error[E0425]: cannot find value `y` in this scope
32-
--> $DIR/issue-104086-suggest-let.rs:5:13
32+
--> $DIR/issue-104086-suggest-let.rs:7:13
3333
|
3434
LL | x = y = y = y;
3535
| ^ not found in this scope
3636

3737
error[E0425]: cannot find value `y` in this scope
38-
--> $DIR/issue-104086-suggest-let.rs:5:17
38+
--> $DIR/issue-104086-suggest-let.rs:7:17
3939
|
4040
LL | x = y = y = y;
4141
| ^ not found in this scope
4242

4343
error[E0425]: cannot find value `x` in this scope
44-
--> $DIR/issue-104086-suggest-let.rs:6:5
44+
--> $DIR/issue-104086-suggest-let.rs:13:5
4545
|
4646
LL | x = y = y;
4747
| ^ not found in this scope
4848

4949
error[E0425]: cannot find value `y` in this scope
50-
--> $DIR/issue-104086-suggest-let.rs:6:9
50+
--> $DIR/issue-104086-suggest-let.rs:13:9
5151
|
5252
LL | x = y = y;
5353
| ^ not found in this scope
5454

5555
error[E0425]: cannot find value `y` in this scope
56-
--> $DIR/issue-104086-suggest-let.rs:6:13
56+
--> $DIR/issue-104086-suggest-let.rs:13:13
5757
|
5858
LL | x = y = y;
5959
| ^ not found in this scope
6060

6161
error[E0425]: cannot find value `x` in this scope
62-
--> $DIR/issue-104086-suggest-let.rs:7:5
62+
--> $DIR/issue-104086-suggest-let.rs:18:5
6363
|
6464
LL | x = x = y;
6565
| ^ not found in this scope
6666

6767
error[E0425]: cannot find value `x` in this scope
68-
--> $DIR/issue-104086-suggest-let.rs:7:9
68+
--> $DIR/issue-104086-suggest-let.rs:18:9
6969
|
7070
LL | x = x = y;
7171
| ^ not found in this scope
7272

7373
error[E0425]: cannot find value `y` in this scope
74-
--> $DIR/issue-104086-suggest-let.rs:7:13
74+
--> $DIR/issue-104086-suggest-let.rs:18:13
7575
|
7676
LL | x = x = y;
7777
| ^ not found in this scope
7878

79-
error: aborting due to 13 previous errors
79+
error[E0425]: cannot find value `x` in this scope
80+
--> $DIR/issue-104086-suggest-let.rs:23:5
81+
|
82+
LL | x = x; // will suggest add `let`
83+
| ^
84+
|
85+
help: you might have meant to introduce a new binding
86+
|
87+
LL | let x = x; // will suggest add `let`
88+
| +++
89+
90+
error[E0425]: cannot find value `x` in this scope
91+
--> $DIR/issue-104086-suggest-let.rs:23:9
92+
|
93+
LL | x = x; // will suggest add `let`
94+
| ^ not found in this scope
95+
96+
error[E0425]: cannot find value `x` in this scope
97+
--> $DIR/issue-104086-suggest-let.rs:27:5
98+
|
99+
LL | x = y // will suggest add `let`
100+
| ^
101+
|
102+
help: you might have meant to introduce a new binding
103+
|
104+
LL | let x = y // will suggest add `let`
105+
| +++
106+
107+
error[E0425]: cannot find value `y` in this scope
108+
--> $DIR/issue-104086-suggest-let.rs:27:9
109+
|
110+
LL | x = y // will suggest add `let`
111+
| ^ not found in this scope
112+
113+
error: aborting due to 17 previous errors
80114

81115
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)