Skip to content

Error about drop in const fn without any dropping happening #60964

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
oli-obk opened this issue May 19, 2019 · 1 comment
Closed

Error about drop in const fn without any dropping happening #60964

oli-obk opened this issue May 19, 2019 · 1 comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-destructors Area: Destructors (`Drop`, …) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented May 19, 2019

The take_inner function won't ever evaluate a destructor. This is a bug in const_qualif I think

pub struct Wrapper {
    inner: String,
}

pub const fn take_inner(w: Wrapper) -> String {
    w.inner
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0493]: destructors cannot be evaluated at compile-time
 --> src/lib.rs:5:28
  |
5 | pub const fn take_inner(w: Wrapper) -> String {  // <<< lint suggestion here fails to compile
  |                         ^ constant functions cannot evaluate destructors

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@ecstatic-morse
Copy link
Contributor

This particular example is fixed by #![feature(const_precise_live_drops)] (#73255), which moves live drop checking for constants after drop elaboration. I think we can close this?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) A-destructors Area: Destructors (`Drop`, …) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants