Skip to content

Commit 4462f93

Browse files
committed
skip assoc type during infer source visitor
1 parent 80d8270 commit 4462f93

File tree

7 files changed

+117
-53
lines changed

7 files changed

+117
-53
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
940940
//
941941
// See the `need_type_info/issue-103053.rs` test for
942942
// a example.
943-
if !matches!(path.res, Res::Def(DefKind::TyAlias, _)) => {
943+
if !matches!(path.res, Res::Def(DefKind::TyAlias | DefKind::AssocTy, _)) => {
944944
if let Some(ty) = self.opt_node_type(expr.hir_id)
945945
&& let ty::Adt(_, args) = ty.kind()
946946
{

tests/crashes/121613-2.rs

-28
This file was deleted.

tests/crashes/121613.rs

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// issue#121613
2+
3+
#![feature(more_qualified_paths)]
4+
5+
struct S {}
6+
7+
struct Foo;
8+
9+
trait A {
10+
type Assoc;
11+
}
12+
13+
impl A for Foo {
14+
type Assoc = S;
15+
}
16+
17+
fn f() {}
18+
19+
fn main() {
20+
<Foo as A>::Assoc {};
21+
f(|a, b| a.cmp(b));
22+
//~^ ERROR: type annotations needed
23+
//~| ERROR: this function takes 0 arguments but 1 argument was supplied
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/incompat-call-after-qualified-path-0.rs:21:6
3+
|
4+
LL | f(|a, b| a.cmp(b));
5+
| ^ - type must be known at this point
6+
|
7+
help: consider giving this closure parameter an explicit type
8+
|
9+
LL | f(|a: /* Type */, b| a.cmp(b));
10+
| ++++++++++++
11+
12+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
13+
--> $DIR/incompat-call-after-qualified-path-0.rs:21:3
14+
|
15+
LL | f(|a, b| a.cmp(b));
16+
| ^ --------------- unexpected argument
17+
|
18+
note: function defined here
19+
--> $DIR/incompat-call-after-qualified-path-0.rs:17:4
20+
|
21+
LL | fn f() {}
22+
| ^
23+
help: remove the extra argument
24+
|
25+
LL - f(|a, b| a.cmp(b));
26+
LL + f();
27+
|
28+
29+
error: aborting due to 2 previous errors
30+
31+
Some errors have detailed explanations: E0061, E0282.
32+
For more information about an error, try `rustc --explain E0061`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// issue#121613
2+
3+
#![feature(more_qualified_paths)]
4+
5+
struct S<T> {
6+
a: T
7+
}
8+
9+
struct Foo;
10+
11+
trait A {
12+
type Assoc<T>;
13+
}
14+
15+
impl A for Foo {
16+
type Assoc<T> = S<T>;
17+
}
18+
19+
fn f() {}
20+
21+
fn main() {
22+
<Foo as A>::Assoc::<i32> {
23+
a: 1
24+
};
25+
f(|a, b| a.cmp(b));
26+
//~^ ERROR: type annotations needed
27+
//~| ERROR: this function takes 0 arguments but 1 argument was supplied
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/incompat-call-after-qualified-path-1.rs:25:6
3+
|
4+
LL | f(|a, b| a.cmp(b));
5+
| ^ - type must be known at this point
6+
|
7+
help: consider giving this closure parameter an explicit type
8+
|
9+
LL | f(|a: /* Type */, b| a.cmp(b));
10+
| ++++++++++++
11+
12+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
13+
--> $DIR/incompat-call-after-qualified-path-1.rs:25:3
14+
|
15+
LL | f(|a, b| a.cmp(b));
16+
| ^ --------------- unexpected argument
17+
|
18+
note: function defined here
19+
--> $DIR/incompat-call-after-qualified-path-1.rs:19:4
20+
|
21+
LL | fn f() {}
22+
| ^
23+
help: remove the extra argument
24+
|
25+
LL - f(|a, b| a.cmp(b));
26+
LL + f();
27+
|
28+
29+
error: aborting due to 2 previous errors
30+
31+
Some errors have detailed explanations: E0061, E0282.
32+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)