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

Do not promote values with const drop that need to be dropped #89988

Merged
merged 2 commits into from
Oct 19, 2021

Commits on Oct 18, 2021

  1. Configuration menu
    Copy the full SHA
    171cbc0 View commit details
    Browse the repository at this point in the history
  2. Do not promote values with const drop that need to be dropped

    Changes from rust-lang#88558 allowed using `~const Drop` in constants by
    introducing a new `NeedsNonConstDrop` qualif.
    
    The new qualif was also used for promotion purposes, and allowed
    promotion to happen for values that needs to be dropped but which
    do have a const drop impl.
    
    Since for promoted the drop implementation is never executed,
    this lead to observable change in behaviour. For example:
    
    ```rust
    
    struct Panic();
    
    impl const Drop for Panic {
        fn drop(&mut self) {
            panic!();
        }
    }
    
    fn main() {
        let _ = &Panic();
    }
    ```
    
    Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
    tmiasko committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    915a581 View commit details
    Browse the repository at this point in the history