-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regressions caused by changed of bounds on Pin::set
#129601
Comments
Until rust-lang/rust#129601 is fixed
It appears that having a looser bound on the impl block containing As similar result can be seen in this example with use core::ops::DerefMut;
use core::ops::Deref;
struct A {}
impl Deref for A {
type Target = Q;
fn deref(&self) -> &Self::Target {
&Q
}
}
struct Q;
impl Q {
fn test_old(&self, b: bool) {
println!("test_old in Q: {b}")
}
fn test_new(&self, b: bool) {
println!("test_new in Q: {b}")
}
}
struct Test<T>(T);
impl<T: Deref> Deref for Test<T> {
type Target = T::Target;
fn deref(&self) -> &T::Target {
self.0.deref()
}
}
impl<T: DerefMut> Test<T> {
fn test_old(&mut self, _t: T::Target) where T::Target: Sized {
println!("test_old in Test<T>");
}
}
impl<T: Deref> Test<T> {
fn test_new(&mut self, _t: T::Target) where T: DerefMut, T::Target: Sized {
println!("test_new in Test<T>");
}
}
fn main() {
Test(A{}).test_old(true);
//Test(A{}).test_new(true);
} |
For the record, this could be fixed in the type system, but likely not until we've landed the new trait solver (which will not happen in the next year or longer, in my estimation). There's no (type-theoretical) reason that method probing cannot look at the where clauses on the method in addition to the where clauses on the impl block itself, skipping over the |
Rollup merge of rust-lang#129668 - coolreader18:fix-pin-set-regr, r=dtolnay Fix Pin::set bounds regression Fixes rust-lang#129601 Fixes the regression from rust-lang#129449, where changing the bounds of the impl block containing `Pin::set` changed the method resolution behavior. ```rust struct A; impl A { fn set(&self) {} } let a: Pin<&A>; a.set(); // before: // - checks <impl<Ptr: DerefMut> Pin<Ptr>>::set(): `&A` doesn't impl `DerefMut` // - autorefs -> &A: resolves to A::set() // now: // - checks <impl<Ptr: Deref> Pin<Ptr>>::set(): `&A` impls `Deref`! resolves to Pin::set() // - check method bounds: `&A` doesn't impl DerefMut: error ``` r? `@dtolnay`
Our CI started failing with the nightly compiler, for a day.
Code
I tried this code:
It compiles in stable, but not with the nightly compiler:
Version it worked on
It works in beta (1.81), it only started failing with nightly very recently (one or two day)
Version with regression
Looking at the recent history, I believe the regression is caused by b968b26 (#129449)
The text was updated successfully, but these errors were encountered: