Skip to content

Commit a10737c

Browse files
committed
Add a test for issue #101637
1 parent 20a8427 commit a10737c

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
struct Struct;
2+
//~^ NOTE function or associated item `fob` not found for this struct
3+
4+
impl Struct {
5+
fn foo() { }
6+
}
7+
8+
mod module {
9+
fn foo() { }
10+
11+
struct Struct;
12+
13+
impl Struct {
14+
fn foo() { }
15+
}
16+
}
17+
18+
trait Trait {
19+
fn foo();
20+
}
21+
22+
fn main() {
23+
Struct::fob();
24+
//~^ ERROR no function or associated item named `fob` found for struct `Struct` in the current scope
25+
//~| NOTE function or associated item not found in `Struct`
26+
27+
Struc::foo();
28+
//~^ ERROR failed to resolve: use of undeclared type `Struc`
29+
//~| NOTE use of undeclared type `Struc`
30+
31+
modul::foo();
32+
//~^ ERROR failed to resolve: use of undeclared crate or module `modul`
33+
//~| NOTE use of undeclared crate or module `modul`
34+
35+
module::Struc::foo();
36+
//~^ ERROR failed to resolve: could not find `Struc` in `module`
37+
//~| NOTE could not find `Struc` in `module`
38+
39+
Trai::foo();
40+
//~^ ERROR failed to resolve: use of undeclared type `Trai`
41+
//~| NOTE use of undeclared type `Trai`
42+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
error[E0433]: failed to resolve: use of undeclared type `Struc`
2+
--> $DIR/typo-suggestion-mistyped-in-path.rs:27:5
3+
|
4+
LL | Struc::foo();
5+
| ^^^^^
6+
| |
7+
| use of undeclared type `Struc`
8+
| help: a struct with a similar name exists: `Struct`
9+
10+
error[E0433]: failed to resolve: use of undeclared crate or module `modul`
11+
--> $DIR/typo-suggestion-mistyped-in-path.rs:31:5
12+
|
13+
LL | modul::foo();
14+
| ^^^^^ use of undeclared crate or module `modul`
15+
|
16+
help: there is a crate or module with a similar name
17+
|
18+
LL | module::foo();
19+
| ~~~~~~
20+
21+
error[E0433]: failed to resolve: could not find `Struc` in `module`
22+
--> $DIR/typo-suggestion-mistyped-in-path.rs:35:13
23+
|
24+
LL | module::Struc::foo();
25+
| ^^^^^
26+
| |
27+
| could not find `Struc` in `module`
28+
| help: a struct with a similar name exists: `Struct`
29+
30+
error[E0433]: failed to resolve: use of undeclared type `Trai`
31+
--> $DIR/typo-suggestion-mistyped-in-path.rs:39:5
32+
|
33+
LL | Trai::foo();
34+
| ^^^^
35+
| |
36+
| use of undeclared type `Trai`
37+
| help: a trait with a similar name exists: `Trait`
38+
39+
error[E0599]: no function or associated item named `fob` found for struct `Struct` in the current scope
40+
--> $DIR/typo-suggestion-mistyped-in-path.rs:23:13
41+
|
42+
LL | struct Struct;
43+
| ------------- function or associated item `fob` not found for this struct
44+
...
45+
LL | Struct::fob();
46+
| ^^^
47+
| |
48+
| function or associated item not found in `Struct`
49+
| help: there is an associated function with a similar name: `foo`
50+
51+
error: aborting due to 5 previous errors
52+
53+
Some errors have detailed explanations: E0433, E0599.
54+
For more information about an error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)