Skip to content

Commit 1490fae

Browse files
committed
Leave error reporting of method calls on inference variables to method call checks
1 parent 138c6df commit 1490fae

14 files changed

+41
-23
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13311331
) -> Ty<'tcx> {
13321332
let rcvr_t = self.check_expr(rcvr);
13331333
// no need to check for bot/err -- callee does that
1334-
let rcvr_t = self.structurally_resolve_type(rcvr.span, rcvr_t);
1334+
let rcvr_t = self.try_structurally_resolve_type(rcvr.span, rcvr_t);
13351335

13361336
let method = match self.lookup_method(rcvr_t, segment, segment.ident.span, expr, rcvr, args)
13371337
{

tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | needs_foo(|x| {
55
| ^
66
...
77
LL | x.to_string();
8-
| - type must be known at this point
8+
| --------- type must be known at this point
99
|
1010
help: consider giving this closure parameter an explicit type
1111
|

tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | Thunk::new(|mut cont| {
55
| ^^^^^^^^
66
LL |
77
LL | cont.reify_as();
8-
| ---- type must be known at this point
8+
| -------- type must be known at this point
99
|
1010
help: consider giving this closure parameter an explicit type
1111
|
@@ -19,7 +19,7 @@ LL | Thunk::new(|mut cont| {
1919
| ^^^^^^^^
2020
LL |
2121
LL | cont.reify_as();
22-
| ---- type must be known at this point
22+
| -------- type must be known at this point
2323
|
2424
help: consider giving this closure parameter an explicit type
2525
|

tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | Thunk::new(|mut cont| {
55
| ^^^^^^^^
66
LL |
77
LL | cont.reify_as();
8-
| ---- type must be known at this point
8+
| -------- type must be known at this point
99
|
1010
help: consider giving this closure parameter an explicit type
1111
|
@@ -19,7 +19,7 @@ LL | Thunk::new(|mut cont| {
1919
| ^^^^^^^^
2020
LL |
2121
LL | cont.reify_as();
22-
| ---- type must be known at this point
22+
| -------- type must be known at this point
2323
|
2424
help: consider giving this closure parameter an explicit type
2525
|

tests/ui/impl-trait/recursive-bound-eval.next.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/recursive-bound-eval.rs:19:13
2+
--> $DIR/recursive-bound-eval.rs:19:28
33
|
44
LL | move || recursive_fn().parse()
5-
| ^^^^^^^^^^^^^^ cannot infer type
5+
| ^^^^^ cannot infer type
66

77
error: aborting due to 1 previous error
88

tests/ui/issues/issue-2151.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x = panic!();
55
| ^
66
LL | x.clone();
7-
| - type must be known at this point
7+
| ----- type must be known at this point
88
|
99
help: consider giving `x` an explicit type
1010
|

tests/ui/issues/issue-7092.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn foo(x: Whatever) {
99
//~| expected enum `Whatever`
1010
//~| found enum `Option<_>`
1111
field.access(),
12+
//~^ ERROR: type annotations needed
1213
}
1314
}
1415

tests/ui/issues/issue-7092.stderr

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ LL | Some(field) =>
99
= note: expected enum `Whatever`
1010
found enum `Option<_>`
1111

12-
error: aborting due to 1 previous error
12+
error[E0282]: type annotations needed
13+
--> $DIR/issue-7092.rs:11:19
14+
|
15+
LL | field.access(),
16+
| ^^^^^^ cannot infer type
17+
18+
error: aborting due to 2 previous errors
1319

14-
For more information about this error, try `rustc --explain E0308`.
20+
Some errors have detailed explanations: E0282, E0308.
21+
For more information about an error, try `rustc --explain E0282`.

tests/ui/lazy-type-alias-impl-trait/branches3.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/branches3.rs:8:10
33
|
44
LL | |s| s.len()
5-
| ^ - type must be known at this point
5+
| ^ --- type must be known at this point
66
|
77
help: consider giving this closure parameter an explicit type
88
|
@@ -13,7 +13,7 @@ error[E0282]: type annotations needed
1313
--> $DIR/branches3.rs:15:10
1414
|
1515
LL | |s| s.len()
16-
| ^ - type must be known at this point
16+
| ^ --- type must be known at this point
1717
|
1818
help: consider giving this closure parameter an explicit type
1919
|
@@ -24,7 +24,7 @@ error[E0282]: type annotations needed
2424
--> $DIR/branches3.rs:23:10
2525
|
2626
LL | |s| s.len()
27-
| ^ - type must be known at this point
27+
| ^ --- type must be known at this point
2828
|
2929
help: consider giving this closure parameter an explicit type
3030
|
@@ -35,7 +35,7 @@ error[E0282]: type annotations needed
3535
--> $DIR/branches3.rs:30:10
3636
|
3737
LL | |s| s.len()
38-
| ^ - type must be known at this point
38+
| ^ --- type must be known at this point
3939
|
4040
help: consider giving this closure parameter an explicit type
4141
|

tests/ui/span/issue-42234-unknown-receiver-type.full.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x: Option<_> = None;
55
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
66
LL | x.unwrap().method_that_could_exist_on_some_type();
7-
| ---------- type must be known at this point
7+
| ------------------------------------ type must be known at this point
88
|
99
help: consider specifying the generic argument
1010
|
@@ -16,6 +16,8 @@ error[E0282]: type annotations needed
1616
|
1717
LL | .sum::<_>()
1818
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
19+
LL | .to_string()
20+
| --------- type must be known at this point
1921
|
2022
help: consider specifying the generic argument
2123
|

tests/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
44
LL | let x: Option<_> = None;
55
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
66
LL | x.unwrap().method_that_could_exist_on_some_type();
7-
| ---------- type must be known at this point
7+
| ------------------------------------ type must be known at this point
88
|
99
help: consider specifying the generic argument
1010
|
@@ -16,6 +16,8 @@ error[E0282]: type annotations needed
1616
|
1717
LL | .sum::<_>()
1818
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
19+
LL | .to_string()
20+
| --------- type must be known at this point
1921
|
2022
help: consider specifying the generic argument
2123
|

tests/ui/type-alias-impl-trait/closures_in_branches.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed
22
--> $DIR/closures_in_branches.rs:7:10
33
|
44
LL | |x| x.len()
5-
| ^ - type must be known at this point
5+
| ^ --- type must be known at this point
66
|
77
help: consider giving this closure parameter an explicit type
88
|
@@ -13,7 +13,7 @@ error[E0282]: type annotations needed
1313
--> $DIR/closures_in_branches.rs:21:10
1414
|
1515
LL | |x| x.len()
16-
| ^ - type must be known at this point
16+
| ^ --- type must be known at this point
1717
|
1818
help: consider giving this closure parameter an explicit type
1919
|

tests/ui/typeck/issue-13853.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Node for Stuff {
2525

2626
fn iterate<N: Node, G: Graph<N>>(graph: &G) {
2727
for node in graph.iter() { //~ ERROR no method named `iter` found
28-
node.zomg();
28+
node.zomg(); //~ ERROR type annotations needed
2929
}
3030
}
3131

tests/ui/typeck/issue-13853.stderr

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ error[E0599]: no method named `iter` found for reference `&G` in the current sco
1717
LL | for node in graph.iter() {
1818
| ^^^^ method not found in `&G`
1919

20+
error[E0282]: type annotations needed
21+
--> $DIR/issue-13853.rs:28:14
22+
|
23+
LL | node.zomg();
24+
| ^^^^ cannot infer type
25+
2026
error[E0308]: mismatched types
2127
--> $DIR/issue-13853.rs:37:13
2228
|
@@ -37,7 +43,7 @@ help: consider borrowing here
3743
LL | iterate(&graph);
3844
| +
3945

40-
error: aborting due to 3 previous errors
46+
error: aborting due to 4 previous errors
4147

42-
Some errors have detailed explanations: E0308, E0599.
43-
For more information about an error, try `rustc --explain E0308`.
48+
Some errors have detailed explanations: E0282, E0308, E0599.
49+
For more information about an error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)