Method resolution constrains hidden types instead of rejecting method candidates
This commit is contained in:
parent
c75f7283bf
commit
9cf60ee9d3
17 changed files with 60 additions and 215 deletions
|
|
@ -1,36 +0,0 @@
|
|||
error[E0599]: no method named `bar` found for struct `Bar<impl Sized>` in the current scope
|
||||
--> $DIR/method-resolution.rs:23:11
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ------------- method `bar` not found for this struct
|
||||
...
|
||||
LL | x.bar();
|
||||
| ^^^ method not found in `Bar<impl Sized>`
|
||||
|
|
||||
= note: the method was found for
|
||||
- `Bar<u32>`
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `foo::{opaque#0}`
|
||||
--> $DIR/method-resolution.rs:19:24
|
||||
|
|
||||
LL | fn foo(x: bool) -> Bar<impl Sized> {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires type-checking `foo`...
|
||||
--> $DIR/method-resolution.rs:23:9
|
||||
|
|
||||
LL | x.bar();
|
||||
| ^
|
||||
= note: ...which requires evaluating trait selection obligation `Bar<foo::{opaque#0}>: core::marker::Unpin`...
|
||||
= note: ...which again requires computing type of opaque `foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `foo::{opaque#0}`
|
||||
--> $DIR/method-resolution.rs:19:24
|
||||
|
|
||||
LL | fn foo(x: bool) -> Bar<impl Sized> {
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0391, E0599.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
//! Check that we do not constrain hidden types during method resolution.
|
||||
//! Otherwise we'd pick up that calling `bar` can be satisfied iff `u32`
|
||||
//! is the hidden type of the RPIT.
|
||||
//! Since there is only one possible `bar` method, we invoke it and subsequently
|
||||
//! constrain `foo`'s RPIT to `u32`.
|
||||
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
//@ check-pass
|
||||
|
||||
trait Trait {}
|
||||
|
||||
|
|
@ -17,11 +16,9 @@ impl Bar<u32> {
|
|||
}
|
||||
|
||||
fn foo(x: bool) -> Bar<impl Sized> {
|
||||
//[current]~^ ERROR: cycle detected
|
||||
if x {
|
||||
let x = foo(false);
|
||||
x.bar();
|
||||
//[current]~^ ERROR: no method named `bar` found
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//! Check that the method call does not constrain the RPIT to `i32`, even though
|
||||
//! `i32` is the only trait that satisfies the RPIT's trait bounds.
|
||||
//! `i32` is the only type that satisfies the RPIT's trait bounds.
|
||||
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
|
|
|||
|
|
@ -1,37 +1,20 @@
|
|||
error[E0599]: no method named `bar` found for struct `Bar<impl Sized>` in the current scope
|
||||
--> $DIR/method-resolution3.rs:22:11
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ------------- method `bar` not found for this struct
|
||||
...
|
||||
LL | x.bar();
|
||||
| ^^^ method not found in `Bar<impl Sized>`
|
||||
|
|
||||
= note: the method was found for
|
||||
- `Bar<i32>`
|
||||
- `Bar<u32>`
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `foo::{opaque#0}`
|
||||
--> $DIR/method-resolution3.rs:18:24
|
||||
|
|
||||
LL | fn foo(x: bool) -> Bar<impl Sized> {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires type-checking `foo`...
|
||||
--> $DIR/method-resolution3.rs:22:9
|
||||
error[E0034]: multiple applicable items in scope
|
||||
--> $DIR/method-resolution3.rs:21:11
|
||||
|
|
||||
LL | x.bar();
|
||||
| ^
|
||||
= note: ...which requires evaluating trait selection obligation `Bar<foo::{opaque#0}>: core::marker::Unpin`...
|
||||
= note: ...which again requires computing type of opaque `foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `foo::{opaque#0}`
|
||||
--> $DIR/method-resolution3.rs:18:24
|
||||
| ^^^ multiple `bar` found
|
||||
|
|
||||
LL | fn foo(x: bool) -> Bar<impl Sized> {
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
note: candidate #1 is defined in an impl for the type `Bar<i32>`
|
||||
--> $DIR/method-resolution3.rs:15:5
|
||||
|
|
||||
LL | fn bar(self) {}
|
||||
| ^^^^^^^^^^^^
|
||||
note: candidate #2 is defined in an impl for the type `Bar<u32>`
|
||||
--> $DIR/method-resolution3.rs:11:5
|
||||
|
|
||||
LL | fn bar(self) {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Some errors have detailed explanations: E0391, E0599.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
For more information about this error, try `rustc --explain E0034`.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0034]: multiple applicable items in scope
|
||||
--> $DIR/method-resolution3.rs:22:11
|
||||
--> $DIR/method-resolution3.rs:21:11
|
||||
|
|
||||
LL | x.bar();
|
||||
| ^^^ multiple `bar` found
|
||||
|
|
|
|||
|
|
@ -16,12 +16,10 @@ impl Bar<i32> {
|
|||
}
|
||||
|
||||
fn foo(x: bool) -> Bar<impl Sized> {
|
||||
//[current]~^ ERROR: cycle
|
||||
if x {
|
||||
let x = foo(false);
|
||||
x.bar();
|
||||
//[current]~^ ERROR: no method named `bar`
|
||||
//[next]~^^ ERROR: multiple applicable items in scope
|
||||
//~^ ERROR: multiple applicable items in scope
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
//! variable, but get a type mismatch when comparing `&mut _` with
|
||||
//! `std::iter::Empty`.
|
||||
|
||||
//@[current] check-pass
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[current] check-pass
|
||||
|
||||
fn foo(b: bool) -> impl Iterator<Item = ()> {
|
||||
if b {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
//@ check-pass
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
||||
impl Foo<u32> {
|
||||
|
|
@ -15,14 +18,11 @@ fn bar() -> Bar {
|
|||
impl Foo<Bar> {
|
||||
fn foo() -> Bar {
|
||||
Self::method();
|
||||
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
|
||||
Foo::<Bar>::method();
|
||||
//~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
|
||||
let x = Foo(bar());
|
||||
Foo::method2(x);
|
||||
let x = Self(bar());
|
||||
Self::method2(x);
|
||||
//~^ ERROR: no function or associated item named `method2` found for struct `Foo<Bar>`
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
|
||||
--> $DIR/opaque_param_in_ufc.rs:17:15
|
||||
|
|
||||
LL | struct Foo<T>(T);
|
||||
| ------------- function or associated item `method` not found for this struct
|
||||
...
|
||||
LL | Self::method();
|
||||
| ^^^^^^ function or associated item not found in `Foo<Bar>`
|
||||
|
|
||||
= note: the function or associated item was found for
|
||||
- `Foo<u32>`
|
||||
|
||||
error[E0599]: no function or associated item named `method` found for struct `Foo<Bar>` in the current scope
|
||||
--> $DIR/opaque_param_in_ufc.rs:19:21
|
||||
|
|
||||
LL | struct Foo<T>(T);
|
||||
| ------------- function or associated item `method` not found for this struct
|
||||
...
|
||||
LL | Foo::<Bar>::method();
|
||||
| ^^^^^^ function or associated item not found in `Foo<Bar>`
|
||||
|
|
||||
= note: the function or associated item was found for
|
||||
- `Foo<u32>`
|
||||
|
||||
error[E0599]: no function or associated item named `method2` found for struct `Foo<Bar>` in the current scope
|
||||
--> $DIR/opaque_param_in_ufc.rs:24:15
|
||||
|
|
||||
LL | struct Foo<T>(T);
|
||||
| ------------- function or associated item `method2` not found for this struct
|
||||
...
|
||||
LL | Self::method2(x);
|
||||
| ^^^^^^^ function or associated item not found in `Foo<Bar>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
error[E0599]: no method named `foo` found for struct `Bar<Foo>` in the current scope
|
||||
--> $DIR/method_resolution2.rs:17:14
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ------------- method `foo` not found for this struct
|
||||
...
|
||||
LL | self.foo()
|
||||
| ^^^ method not found in `Bar<Foo>`
|
||||
|
|
||||
= note: the method was found for
|
||||
- `Bar<u32>`
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}`
|
||||
--> $DIR/method_resolution2.rs:10:12
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires type-checking `<impl at $DIR/method_resolution2.rs:15:1: 15:14>::bar`...
|
||||
--> $DIR/method_resolution2.rs:17:9
|
||||
|
|
||||
LL | self.foo()
|
||||
| ^^^^
|
||||
= note: ...which requires evaluating trait selection obligation `Bar<Foo>: core::marker::Unpin`...
|
||||
= note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `Foo::{opaque#0}`
|
||||
--> $DIR/method_resolution2.rs:10:12
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0391, E0599.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
|
|
@ -1,21 +1,19 @@
|
|||
//! Check that we do not unify `Bar<Foo>` with `Bar<u32>`, even though the
|
||||
//! Check that we do unify `Bar<Foo>` with `Bar<u32>`, as the
|
||||
//! `foo` method call can be resolved unambiguously by doing so.
|
||||
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
//@ check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type Foo = impl Sized;
|
||||
//[current]~^ ERROR: cycle
|
||||
|
||||
struct Bar<T>(T);
|
||||
|
||||
impl Bar<Foo> {
|
||||
fn bar(self) {
|
||||
self.foo()
|
||||
//[current]~^ ERROR: no method named `foo`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
error[E0599]: no method named `bar` found for struct `Bar<u32>` in the current scope
|
||||
--> $DIR/method_resolution5.rs:25:14
|
||||
|
|
||||
LL | struct Bar<T>(T);
|
||||
| ------------- method `bar` not found for this struct
|
||||
...
|
||||
LL | self.bar()
|
||||
| ^^^ method not found in `Bar<u32>`
|
||||
|
|
||||
= note: the method was found for
|
||||
- `Bar<Foo>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
//@ check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
|
|
@ -23,7 +23,6 @@ impl Bar<u32> {
|
|||
Foo:,
|
||||
{
|
||||
self.bar()
|
||||
//[current]~^ ERROR: no method named `bar`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue