1
Fork 0

fix tests and code cleanup

This commit is contained in:
yukang 2022-11-09 17:10:33 +08:00
parent 952df48948
commit 5689f9c679
3 changed files with 106 additions and 56 deletions

View file

@ -1816,11 +1816,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
if let Some(Expr { kind: ExprKind::Assign(lhs, rhs, _), .. }) = if let Some(Expr { kind: ExprKind::Assign(lhs, rhs, _), .. }) =
self.diagnostic_metadata.in_assignment self.diagnostic_metadata.in_assignment
{ {
let is_rhs_assign = match rhs.kind { let is_rhs_assign = matches!(rhs.kind, ExprKind::Assign(..));
ExprKind::Assign(..) => true,
_ => false,
};
if let ast::ExprKind::Path(None, _) = lhs.kind && !is_rhs_assign { if let ast::ExprKind::Path(None, _) = lhs.kind && !is_rhs_assign {
let sm = self.r.session.source_map(); let sm = self.r.session.source_map();
let line_span = sm.span_extend_to_line(ident_span); let line_span = sm.span_extend_to_line(ident_span);

View file

@ -1,10 +1,30 @@
// error-pattern: not found in this scope
fn main() { fn main() {
x = x = x; x = x = x;
//~^ ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `x` in this scope
x = y = y = y; x = y = y = y;
//~^ ERROR cannot find value `y` in this scope
//~| ERROR cannot find value `y` in this scope
//~| ERROR cannot find value `y` in this scope
//~| ERROR cannot find value `x` in this scope
x = y = y; x = y = y;
//~^ ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `y` in this scope
//~| ERROR cannot find value `y` in this scope
x = x = y; x = x = y;
//~^ ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `y` in this scope
x = x; // will suggest add `let` x = x; // will suggest add `let`
//~^ ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `x` in this scope
x = y // will suggest add `let` x = y // will suggest add `let`
//~^ ERROR cannot find value `x` in this scope
//~| ERROR cannot find value `y` in this scope
} }

View file

@ -1,81 +1,115 @@
error[E0425]: cannot find value `x` in this scope error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:4:5 --> $DIR/issue-104086-suggest-let.rs:2:5
| |
LL | x = x = x; LL | x = x = x;
| ^ not found in this scope | ^ not found in this scope
error[E0425]: cannot find value `x` in this scope error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:4:9 --> $DIR/issue-104086-suggest-let.rs:2:9
| |
LL | x = x = x; LL | x = x = x;
| ^ not found in this scope | ^ not found in this scope
error[E0425]: cannot find value `x` in this scope error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:4:13 --> $DIR/issue-104086-suggest-let.rs:2:13
| |
LL | x = x = x; LL | x = x = x;
| ^ not found in this scope | ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:5:5
|
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:5:9
|
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:5:13
|
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:5:17
|
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:6:5
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:6:9
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:6:13
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:7:5 --> $DIR/issue-104086-suggest-let.rs:7:5
| |
LL | x = x = y; LL | x = y = y = y;
| ^ not found in this scope | ^ not found in this scope
error[E0425]: cannot find value `x` in this scope error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:7:9 --> $DIR/issue-104086-suggest-let.rs:7:9
| |
LL | x = x = y; LL | x = y = y = y;
| ^ not found in this scope | ^ not found in this scope
error[E0425]: cannot find value `y` in this scope error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:7:13 --> $DIR/issue-104086-suggest-let.rs:7:13
| |
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:7:17
|
LL | x = y = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:13:5
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:13:9
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:13:13
|
LL | x = y = y;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:18:5
|
LL | x = x = y; LL | x = x = y;
| ^ not found in this scope | ^ not found in this scope
error: aborting due to 13 previous errors error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:18:9
|
LL | x = x = y;
| ^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:18:13
|
LL | x = x = y;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:23:5
|
LL | x = x; // will suggest add `let`
| ^
|
help: you might have meant to introduce a new binding
|
LL | let x = x; // will suggest add `let`
| +++
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:23:9
|
LL | x = x; // will suggest add `let`
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/issue-104086-suggest-let.rs:27:5
|
LL | x = y // will suggest add `let`
| ^
|
help: you might have meant to introduce a new binding
|
LL | let x = y // will suggest add `let`
| +++
error[E0425]: cannot find value `y` in this scope
--> $DIR/issue-104086-suggest-let.rs:27:9
|
LL | x = y // will suggest add `let`
| ^ not found in this scope
error: aborting due to 17 previous errors
For more information about this error, try `rustc --explain E0425`. For more information about this error, try `rustc --explain E0425`.