Skip to content

Regressions caused by changed of bounds on Pin::set #129601

Closed

Description

Our CI started failing with the nightly compiler, for a day.

Code

I tried this code:

struct Foo {}
impl Foo {
    fn set(&self, _: bool) {}
}

fn main() {
    let foo = Foo {};
    let foo : core::pin::Pin<&Foo> = core::pin::Pin::new(&foo);
    foo.set(true);
}

It compiles in stable, but not with the nightly compiler:

error[E0277]: the trait bound `&Foo: DerefMut` is not satisfied
    --> src/main.rs:27:9
     |
27   |     foo.set(true);
     |         ^^^ the trait `DerefMut` is not implemented for `&Foo`
     |
note: required by a bound in `Pin::<Ptr>::set`
    --> /home/olivier/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/pin.rs:1478:14
     |
1476 |     pub fn set(&mut self, value: Ptr::Target)
     |            --- required by a bound in this associated function
1477 |     where
1478 |         Ptr: DerefMut,
     |              ^^^^^^^^ required by this bound in `Pin::<Ptr>::set`
help: consider mutably borrowing here
     |
27   |     (&mut foo).set(true);
     |     +++++    +

error[E0308]: mismatched types
    --> src/main.rs:27:13
     |
27   |     foo.set(true);
     |         --- ^^^^ expected `Foo`, found `bool`
     |         |
     |         arguments to this method are incorrect
     |
note: method defined here
    --> /home/olivier/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/pin.rs:1476:12
     |
1476 |     pub fn set(&mut self, value: Ptr::Target)
     |            ^^^

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

rustc 1.82.0-nightly (c6db1ca3c 2024-08-25)
binary: rustc
commit-hash: c6db1ca3c93ad69692a4c4b5542f26fda4bf3aec
commit-date: 2024-08-25
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Looking at the recent history, I believe the regression is caused by b968b26 (#129449)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-mediumMedium priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions