-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
An associated type magically adds a destructor? #29821
Comments
(@alevy expressed interest in working on this, I will mentor.) |
Triage: still relevant. |
I'm still interested in helping to fix this. @nikomatsakis you mentioned at one point that you had a hunch for where the problem was. Perhaps a pointer would be enough to get the ball rolling? |
@alevy Hmm. So, the error is emitted by the "constant qualification" code, which walks the MIR for generating a constant value and looks for things that should be disallowed. One of those things is the creation of a struct which has a destructor. This code is in cc @eddyb, author of the code in question |
It might be the type contents, if we use them for "needs drop". Aren't they conservative wrt projections? |
@eddyb that was my first assumption, that it was something like that. When I was poking about in the code I didn't see the place where we branch into that, but maybe I just wasn't reading very carefully. |
|
This doesn't seem to be an issue anymore. Running the provided "non-working" code doesn't trigger a compiler error. |
Indeed, this not longer seems to be an issue. Happy to close the issue :) |
Should we add a regression test first? |
Add regression test for rust-lang#29821 Closes rust-lang#29821
…laumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#81526 (btree: use Option's unwrap_unchecked()) - rust-lang#81742 (Add a note about the correctness and the effect on unsafe code to the `ExactSizeIterator` docs) - rust-lang#81830 (Add long error explanation for E0542) - rust-lang#81835 (Improve long explanation for E0546) - rust-lang#81843 (Add regression test for rust-lang#29821) Failed merges: - rust-lang#81836 (Add long explanation for E0547) r? `@ghost` `@rustbot` modify labels: rollup
These two code snippets should functionally be doing the same thing, but the type checker seems to think one has a destructor. The difference seems to be in the reliance on an associated type.
rustc
complains thatmyfoo
cannot be declared a mutable static because it has a desctructor:While this, unsurprisingly, works:
Here are links to non-compiling/compiling examples on play.rust-lang:
The text was updated successfully, but these errors were encountered: