Skip to content

Commit 7c1bc03

Browse files
committed
refactor(resolve): clean up the early error return caused by non-call
1 parent 25444e5 commit 7c1bc03

9 files changed

+65
-29
lines changed

compiler/rustc_resolve/src/late.rs

-4
Original file line numberDiff line numberDiff line change
@@ -3528,10 +3528,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
35283528
//
35293529
// Similar thing, for types, happens in `report_errors` above.
35303530
let report_errors_for_call = |this: &mut Self, parent_err: Spanned<ResolutionError<'a>>| {
3531-
if !source.is_call() {
3532-
return Some(parent_err);
3533-
}
3534-
35353531
// Before we start looking for candidates, we have to get our hands
35363532
// on the type user is trying to perform invocation on; basically:
35373533
// we're transforming `HashMap::new` into just `HashMap`.

tests/ui/generic-associated-types/equality-bound.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ error[E0433]: failed to resolve: use of undeclared type `I`
3636
--> $DIR/equality-bound.rs:9:41
3737
|
3838
LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 {
39-
| ^ use of undeclared type `I`
39+
| ^
40+
| |
41+
| use of undeclared type `I`
42+
| help: a type parameter with a similar name exists: `J`
4043

4144
error: aborting due to 4 previous errors
4245

tests/ui/macros/builtin-prelude-no-accidents.stderr

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env`
44
LL | env::current_dir;
55
| ^^^ use of undeclared crate or module `env`
66

7+
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
8+
--> $DIR/builtin-prelude-no-accidents.rs:7:14
9+
|
10+
LL | type B = vec::Vec<u8>;
11+
| ^^^
12+
| |
13+
| use of undeclared crate or module `vec`
14+
| help: a struct with a similar name exists (notice the capitalization): `Vec`
15+
716
error[E0433]: failed to resolve: use of undeclared crate or module `panic`
817
--> $DIR/builtin-prelude-no-accidents.rs:6:14
918
|
1019
LL | type A = panic::PanicInfo;
1120
| ^^^^^ use of undeclared crate or module `panic`
1221

13-
error[E0433]: failed to resolve: use of undeclared crate or module `vec`
14-
--> $DIR/builtin-prelude-no-accidents.rs:7:14
15-
|
16-
LL | type B = vec::Vec<u8>;
17-
| ^^^ use of undeclared crate or module `vec`
18-
1922
error: aborting due to 3 previous errors
2023

2124
For more information about this error, try `rustc --explain E0433`.

tests/ui/parser/dyn-trait-compatibility.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
2-
--> $DIR/dyn-trait-compatibility.rs:3:11
3-
|
4-
LL | type A1 = dyn::dyn;
5-
| ^^^ use of undeclared crate or module `dyn`
6-
71
error[E0412]: cannot find type `dyn` in this scope
82
--> $DIR/dyn-trait-compatibility.rs:1:11
93
|
@@ -46,6 +40,12 @@ error[E0412]: cannot find type `dyn` in this scope
4640
LL | type A3 = dyn<<dyn as dyn>::dyn>;
4741
| ^^^ not found in this scope
4842

43+
error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
44+
--> $DIR/dyn-trait-compatibility.rs:3:11
45+
|
46+
LL | type A1 = dyn::dyn;
47+
| ^^^ use of undeclared crate or module `dyn`
48+
4949
error: aborting due to 8 previous errors
5050

5151
Some errors have detailed explanations: E0405, E0412, E0433.

tests/ui/pattern/pattern-error-continue.stderr

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0433]: failed to resolve: use of undeclared type `E`
2-
--> $DIR/pattern-error-continue.rs:33:9
3-
|
4-
LL | E::V => {}
5-
| ^ use of undeclared type `E`
6-
71
error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
82
--> $DIR/pattern-error-continue.rs:18:9
93
|
@@ -56,6 +50,15 @@ note: function defined here
5650
LL | fn f(_c: char) {}
5751
| ^ --------
5852

53+
error[E0433]: failed to resolve: use of undeclared type `E`
54+
--> $DIR/pattern-error-continue.rs:33:9
55+
|
56+
LL | E::V => {}
57+
| ^
58+
| |
59+
| use of undeclared type `E`
60+
| help: an enum with a similar name exists: `A`
61+
5962
error: aborting due to 5 previous errors
6063

6164
Some errors have detailed explanations: E0023, E0308, E0433, E0532.

tests/ui/resolve/issue-109250.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() { //~ HELP consider importing
2+
HashMap::new; //~ ERROR failed to resolve: use of undeclared type `HashMap`
3+
}

tests/ui/resolve/issue-109250.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0433]: failed to resolve: use of undeclared type `HashMap`
2+
--> $DIR/issue-109250.rs:2:5
3+
|
4+
LL | HashMap::new;
5+
| ^^^^^^^ use of undeclared type `HashMap`
6+
|
7+
help: consider importing this struct
8+
|
9+
LL + use std::collections::HashMap;
10+
|
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0433`.

tests/ui/resolve/resolve-variant-assoc-item.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ error[E0433]: failed to resolve: `V` is a variant, not a module
33
|
44
LL | E::V::associated_item;
55
| ^ `V` is a variant, not a module
6+
|
7+
help: there is an enum variant `E::V`; try using the variant's enum
8+
|
9+
LL | E;
10+
| ~
611

712
error[E0433]: failed to resolve: `V` is a variant, not a module
813
--> $DIR/resolve-variant-assoc-item.rs:6:5
914
|
1015
LL | V::associated_item;
1116
| ^ `V` is a variant, not a module
17+
|
18+
help: there is an enum variant `E::V`; try using the variant's enum
19+
|
20+
LL | E;
21+
| ~
22+
help: an enum with a similar name exists
23+
|
24+
LL | E::associated_item;
25+
| ~
1226

1327
error: aborting due to 2 previous errors
1428

tests/ui/type/type-path-err-node-types.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0433]: failed to resolve: use of undeclared type `NonExistent`
2-
--> $DIR/type-path-err-node-types.rs:15:5
3-
|
4-
LL | NonExistent::Assoc::<u8>;
5-
| ^^^^^^^^^^^ use of undeclared type `NonExistent`
6-
71
error[E0412]: cannot find type `Nonexistent` in this scope
82
--> $DIR/type-path-err-node-types.rs:7:12
93
|
@@ -22,6 +16,12 @@ error[E0425]: cannot find value `nonexistent` in this scope
2216
LL | nonexistent.nonexistent::<u8>();
2317
| ^^^^^^^^^^^ not found in this scope
2418

19+
error[E0433]: failed to resolve: use of undeclared type `NonExistent`
20+
--> $DIR/type-path-err-node-types.rs:15:5
21+
|
22+
LL | NonExistent::Assoc::<u8>;
23+
| ^^^^^^^^^^^ use of undeclared type `NonExistent`
24+
2525
error[E0282]: type annotations needed
2626
--> $DIR/type-path-err-node-types.rs:23:14
2727
|

0 commit comments

Comments
 (0)