diff --git a/src/test/ui/self/suggest-self.rs b/src/test/ui/self/suggest-self.rs index 56ba7ff8fe1e3..f648d781cafea 100644 --- a/src/test/ui/self/suggest-self.rs +++ b/src/test/ui/self/suggest-self.rs @@ -13,6 +13,20 @@ struct Foo { } impl Foo { + fn this1(&self) -> i32 { + let this = self; + let a = 1; + this.x + } + + fn this2(&self) -> i32 { + let a = Foo { + x: 2 + }; + let this = a; + this.x + } + fn foo(&self) -> i32 { this.x //~^ ERROR cannot find value `this` in this scope @@ -25,7 +39,7 @@ impl Foo { fn baz(&self) -> i32 { my.bar() - //~^ ERROR cannot find value `this` in this scope + //~^ ERROR cannot find value `my` in this scope } } diff --git a/src/test/ui/self/suggest-self.stderr b/src/test/ui/self/suggest-self.stderr new file mode 100644 index 0000000000000..04d7622e3c807 --- /dev/null +++ b/src/test/ui/self/suggest-self.stderr @@ -0,0 +1,30 @@ +error[E0425]: cannot find value `this` in this scope + --> $DIR/suggest-self.rs:31:9 + | +LL | this.x + | ^^^^ + | | + | not found in this scope + | help: do you mean: `self` + +error[E0425]: cannot find value `this` in this scope + --> $DIR/suggest-self.rs:36:9 + | +LL | this.foo() + | ^^^^ + | | + | not found in this scope + | help: do you mean: `self` + +error[E0425]: cannot find value `my` in this scope + --> $DIR/suggest-self.rs:41:9 + | +LL | my.bar() + | ^^ + | | + | not found in this scope + | help: do you mean: `self` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0425`.