Process alias-relate obligations when proving receiver_is_valid

This commit is contained in:
Michael Goulet 2024-06-30 11:30:55 -04:00
parent 11dd90f761
commit fdde66acee
8 changed files with 38 additions and 50 deletions

View file

@ -1,12 +0,0 @@
error[E0271]: type mismatch resolving `<() as Index>::Output == &mut <() as Index>::Output`
--> $DIR/issue-100222.rs:34:12
|
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
| ^^^^^^^^^ expected `()`, found `&mut <() as Index>::Output`
|
= note: expected unit type `()`
found mutable reference `&mut <() as Index>::Output`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -1,12 +0,0 @@
error[E0271]: type mismatch resolving `<() as Index>::Output == &mut <() as Index>::Output`
--> $DIR/issue-100222.rs:25:12
|
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
| ^^^^^^^^^ expected `()`, found `&mut <() as Index>::Output`
|
= note: expected unit type `()`
found mutable reference `&mut <() as Index>::Output`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -1,6 +1,7 @@
//@ revisions: nn ny yn yy
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
//@ check-pass
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects, associated_type_defaults, const_mut_refs)]

View file

@ -1,12 +0,0 @@
error[E0271]: type mismatch resolving `<() as Index>::Output == &mut <() as Index>::Output`
--> $DIR/issue-100222.rs:34:12
|
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
| ^^^^^^^^^ expected `()`, found `&mut <() as Index>::Output`
|
= note: expected unit type `()`
found mutable reference `&mut <() as Index>::Output`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -1,12 +0,0 @@
error[E0271]: type mismatch resolving `<() as Index>::Output == &mut <() as Index>::Output`
--> $DIR/issue-100222.rs:25:12
|
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
| ^^^^^^^^^ expected `()`, found `&mut <() as Index>::Output`
|
= note: expected unit type `()`
found mutable reference `&mut <() as Index>::Output`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -0,0 +1,23 @@
//@ compile-flags: -Znext-solver
//@ check-pass
// Fixes a regression in `receiver_is_valid` in wfcheck where we were using
// `InferCtxt::can_eq` instead of processing alias-relate goals, leading to false
// positives, not deref'ing enough steps to check the receiver is valid.
trait Mirror {
type Mirror: ?Sized;
}
impl<T: ?Sized> Mirror for T {
type Mirror = T;
}
trait Foo {
fn foo(&self) {}
}
impl Foo for <() as Mirror>::Mirror {
fn foo(&self) {}
}
fn main() {}