Auto merge of #129073 - compiler-errors:receiver-variance, r=lcnr
Relate receiver invariantly in method probe for `Mode::Path` Effectively reverts part of #126128 Fixes #126227 This PR changes method probing to use equality for fully path-based method lookup, and subtyping for receiver `.` method lookup. r? lcnr
This commit is contained in:
commit
e9e13a68d7
17 changed files with 141 additions and 56 deletions
16
tests/ui/methods/receiver-equality.rs
Normal file
16
tests/ui/methods/receiver-equality.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Tests that we probe receivers invariantly when using path-based method lookup.
|
||||
|
||||
struct B<T>(T);
|
||||
|
||||
impl B<fn(&'static ())> {
|
||||
fn method(self) {
|
||||
println!("hey");
|
||||
}
|
||||
}
|
||||
|
||||
fn foo(y: B<fn(&'static ())>) {
|
||||
B::<for<'a> fn(&'a ())>::method(y);
|
||||
//~^ ERROR no function or associated item named `method` found
|
||||
}
|
||||
|
||||
fn main() {}
|
12
tests/ui/methods/receiver-equality.stderr
Normal file
12
tests/ui/methods/receiver-equality.stderr
Normal file
|
@ -0,0 +1,12 @@
|
|||
error[E0599]: no function or associated item named `method` found for struct `B<for<'a> fn(&'a ())>` in the current scope
|
||||
--> $DIR/receiver-equality.rs:12:30
|
||||
|
|
||||
LL | struct B<T>(T);
|
||||
| ----------- function or associated item `method` not found for this struct
|
||||
...
|
||||
LL | B::<for<'a> fn(&'a ())>::method(y);
|
||||
| ^^^^^^ function or associated item not found in `B<fn(&())>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
Loading…
Add table
Add a link
Reference in a new issue