Skip to content

Commit cef0482

Browse files
committedAug 27, 2022
Add test
1 parent 703603a commit cef0482

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
 

Diff for: ‎src/test/ui/suggestions/call-on-missing.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
struct Foo { i: i32 }
2+
3+
impl Foo {
4+
fn bar(&self) {}
5+
}
6+
7+
fn foo() -> Foo {
8+
Foo { i: 1 }
9+
}
10+
11+
fn main() {
12+
foo.bar();
13+
//~^ ERROR no method named `bar`
14+
//~| HELP use parentheses to call this function
15+
16+
foo.i;
17+
//~^ ERROR no field `i`
18+
//~| HELP use parentheses to call this function
19+
}

Diff for: ‎src/test/ui/suggestions/call-on-missing.stderr

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0599]: no method named `bar` found for fn item `fn() -> Foo {foo}` in the current scope
2+
--> $DIR/call-on-missing.rs:12:9
3+
|
4+
LL | foo.bar();
5+
| ^^^ method not found in `fn() -> Foo {foo}`
6+
|
7+
help: use parentheses to call this function
8+
|
9+
LL | foo().bar();
10+
| ++
11+
12+
error[E0609]: no field `i` on type `fn() -> Foo {foo}`
13+
--> $DIR/call-on-missing.rs:16:9
14+
|
15+
LL | foo.i;
16+
| ^
17+
|
18+
help: use parentheses to call this function
19+
|
20+
LL | foo().i;
21+
| ++
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0599, E0609.
26+
For more information about an error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)
Please sign in to comment.