Skip to content

Commit

Permalink
skip assoc type during infer source visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanjoi committed Jul 29, 2024
1 parent 80d8270 commit 4462f93
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
//
// See the `need_type_info/issue-103053.rs` test for
// a example.
if !matches!(path.res, Res::Def(DefKind::TyAlias, _)) => {
if !matches!(path.res, Res::Def(DefKind::TyAlias | DefKind::AssocTy, _)) => {
if let Some(ty) = self.opt_node_type(expr.hir_id)
&& let ty::Adt(_, args) = ty.kind()
{
Expand Down
28 changes: 0 additions & 28 deletions tests/crashes/121613-2.rs

This file was deleted.

24 changes: 0 additions & 24 deletions tests/crashes/121613.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// issue#121613

#![feature(more_qualified_paths)]

struct S {}

struct Foo;

trait A {
type Assoc;
}

impl A for Foo {
type Assoc = S;
}

fn f() {}

fn main() {
<Foo as A>::Assoc {};
f(|a, b| a.cmp(b));
//~^ ERROR: type annotations needed
//~| ERROR: this function takes 0 arguments but 1 argument was supplied
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
error[E0282]: type annotations needed
--> $DIR/incompat-call-after-qualified-path-0.rs:21:6
|
LL | f(|a, b| a.cmp(b));
| ^ - type must be known at this point
|
help: consider giving this closure parameter an explicit type
|
LL | f(|a: /* Type */, b| a.cmp(b));
| ++++++++++++

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/incompat-call-after-qualified-path-0.rs:21:3
|
LL | f(|a, b| a.cmp(b));
| ^ --------------- unexpected argument
|
note: function defined here
--> $DIR/incompat-call-after-qualified-path-0.rs:17:4
|
LL | fn f() {}
| ^
help: remove the extra argument
|
LL - f(|a, b| a.cmp(b));
LL + f();
|

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0282.
For more information about an error, try `rustc --explain E0061`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// issue#121613

#![feature(more_qualified_paths)]

struct S<T> {
a: T
}

struct Foo;

trait A {
type Assoc<T>;
}

impl A for Foo {
type Assoc<T> = S<T>;
}

fn f() {}

fn main() {
<Foo as A>::Assoc::<i32> {
a: 1
};
f(|a, b| a.cmp(b));
//~^ ERROR: type annotations needed
//~| ERROR: this function takes 0 arguments but 1 argument was supplied
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
error[E0282]: type annotations needed
--> $DIR/incompat-call-after-qualified-path-1.rs:25:6
|
LL | f(|a, b| a.cmp(b));
| ^ - type must be known at this point
|
help: consider giving this closure parameter an explicit type
|
LL | f(|a: /* Type */, b| a.cmp(b));
| ++++++++++++

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/incompat-call-after-qualified-path-1.rs:25:3
|
LL | f(|a, b| a.cmp(b));
| ^ --------------- unexpected argument
|
note: function defined here
--> $DIR/incompat-call-after-qualified-path-1.rs:19:4
|
LL | fn f() {}
| ^
help: remove the extra argument
|
LL - f(|a, b| a.cmp(b));
LL + f();
|

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0282.
For more information about an error, try `rustc --explain E0061`.

0 comments on commit 4462f93

Please sign in to comment.