add test + don't warn on Res::SelfTy
This commit is contained in:
parent
b7ab4777b2
commit
d6b28f377c
@ -863,6 +863,9 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||||||
// See the `need_type_info/type-alias.rs` test for
|
// See the `need_type_info/type-alias.rs` test for
|
||||||
// some examples.
|
// some examples.
|
||||||
}
|
}
|
||||||
|
// There cannot be inference variables in the self type,
|
||||||
|
// so there's nothing for us to do here.
|
||||||
|
Res::SelfTy { .. } => {}
|
||||||
_ => warn!(
|
_ => warn!(
|
||||||
"unexpected path: def={:?} substs={:?} path={:?}",
|
"unexpected path: def={:?} substs={:?} path={:?}",
|
||||||
def, substs, path,
|
def, substs, path,
|
||||||
|
16
src/test/ui/inference/need_type_info/concrete-impl.rs
Normal file
16
src/test/ui/inference/need_type_info/concrete-impl.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
trait Ambiguous<A> {
|
||||||
|
fn method() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct One;
|
||||||
|
struct Two;
|
||||||
|
struct Struct;
|
||||||
|
|
||||||
|
impl Ambiguous<One> for Struct {}
|
||||||
|
impl Ambiguous<Two> for Struct {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
<Struct as Ambiguous<_>>::method();
|
||||||
|
//~^ ERROR type annotations needed
|
||||||
|
//~| ERROR type annotations needed
|
||||||
|
}
|
33
src/test/ui/inference/need_type_info/concrete-impl.stderr
Normal file
33
src/test/ui/inference/need_type_info/concrete-impl.stderr
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/concrete-impl.rs:13:5
|
||||||
|
|
|
||||||
|
LL | <Struct as Ambiguous<_>>::method();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous`
|
||||||
|
|
|
||||||
|
help: consider specifying the generic argument
|
||||||
|
|
|
||||||
|
LL | <Struct as Ambiguous::<_>>::method();
|
||||||
|
| ~~~~~
|
||||||
|
|
||||||
|
error[E0283]: type annotations needed
|
||||||
|
--> $DIR/concrete-impl.rs:13:5
|
||||||
|
|
|
||||||
|
LL | <Struct as Ambiguous<_>>::method();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous`
|
||||||
|
|
|
||||||
|
note: multiple `impl`s satisfying `Struct: Ambiguous<_>` found
|
||||||
|
--> $DIR/concrete-impl.rs:9:1
|
||||||
|
|
|
||||||
|
LL | impl Ambiguous<One> for Struct {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL | impl Ambiguous<Two> for Struct {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
help: consider specifying the generic argument
|
||||||
|
|
|
||||||
|
LL | <Struct as Ambiguous::<_>>::method();
|
||||||
|
| ~~~~~
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0282, E0283.
|
||||||
|
For more information about an error, try `rustc --explain E0282`.
|
13
src/test/ui/inference/need_type_info/self-ty-in-path.rs
Normal file
13
src/test/ui/inference/need_type_info/self-ty-in-path.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Test that we don't ICE when encountering a `Self` in a path.
|
||||||
|
struct TestErr<T>(T);
|
||||||
|
|
||||||
|
impl<T> TestErr<T> {
|
||||||
|
fn func_a<U>() {}
|
||||||
|
|
||||||
|
fn func_b() {
|
||||||
|
Self::func_a();
|
||||||
|
//~^ ERROR type annotations needed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
14
src/test/ui/inference/need_type_info/self-ty-in-path.stderr
Normal file
14
src/test/ui/inference/need_type_info/self-ty-in-path.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/self-ty-in-path.rs:8:9
|
||||||
|
|
|
||||||
|
LL | Self::func_a();
|
||||||
|
| ^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the associated function `func_a`
|
||||||
|
|
|
||||||
|
help: consider specifying the generic argument
|
||||||
|
|
|
||||||
|
LL | Self::func_a::<U>();
|
||||||
|
| +++++
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0282`.
|
Loading…
x
Reference in New Issue
Block a user