Skip to content
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

T: Drop bound not satisfied from Option::unwrap_or (et. al) when Drop anti-bound is present #92111

Closed
chorman0773 opened this issue Dec 20, 2021 · 1 comment · Fixed by #92149
Assignees
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Milestone

Comments

@chorman0773
Copy link
Contributor

chorman0773 commented Dec 20, 2021

Code

I tried this code:

pub trait NoDrop{}

impl<T: Drop> NoDrop for T{}

#[derive(Debug)]
pub struct DoesNotHaveDrop(i32);

impl NoDrop for DoesNotHaveDrop{}

fn main() {
    let x = Some(DoesNotHaveDrop(0));
    println!("{:?}",x.unwrap_or(DoesNotHaveDrop(0)))
}

I expected to see this happen: print DoesNotHaveDrop(0) (from Debug impl)

Instead, this happened: E0277, trait impl DoesNotHaveDrop: Drop not found

This was found by CI in the Ruffle Project: https://github.com/ruffle-rs/ruffle/runs/4576592287?check_suite_focus=true

The issue is caused by the effective anti-bound of Drop, introduced by the manual impl of the NoDrop trait, as well as the PR #91928 which introduced ~const Drop bounds for a number of functions in Option.

Version it worked on

It most recently worked on: rustc 1.59.0-nightly (7abab1e 2021-12-18)

Version with regression

rustc --version --verbose:

rustc 1.59.0-nightly (91a0600a5 2021-12-18)

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

@chorman0773 chorman0773 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Dec 20, 2021
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels Dec 20, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.59.0 milestone Dec 20, 2021
@ecstatic-morse
Copy link
Contributor

cc @fee1-dead @oli-obk

@fee1-dead fee1-dead self-assigned this Dec 21, 2021
@bors bors closed this as completed in 8ad3c1d Dec 21, 2021
@rustbot rustbot removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants