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

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

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-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. 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.

@oli-obk oli-obk added the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label May 19, 2019
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-destructors Area: Destructors (`Drop`, …) labels Apr 21, 2020
@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. 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

3 participants