-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
#[unsafe_destructor] is excessively unsafe (monomorphizes wrong) #6971
Comments
Hmm, I do see your point, but I'm not sure if this is something we can actually fix. As far as I can tell, this is exactly why generic I'm not certain though, so I'll let somebody more knowledgeable than I chime in. |
This looks suspiciously similar to #2734 |
There's not really any reason for generic drops to be unsafe. The reason they currently aren't is that because of #4301/#3167, destructors are limited to types that fulfill But here the compiler appears to make the assumption that, because destructorful data shouldn't be polymorphic, it should never need to monomorphize |
Nominating for maturity milestone 2: backwards-compatible. (Though I could see it also getting thrown in the milestone 1 bin). Here are the issues that I think this bug identifies:
Also, I just want to chime in: That is a very nifty test case. :) (we may want to create sub-issues for some/all of the bullets above; I just wanted to get them out of my head in the short term.) |
I'd say "well-defined" is fine for this (or at least some related issue). It certainly seems like something that should be well defined. |
Actually I think well-covered is the right milestone. (Anybody want to cast a vote for the other two?) |
De-nominating |
Will not be relevant once #8861 is complete |
This is broken, and results in poor performance due to the undefined behaviour in the LLVM IR. LLVM's `mergefunc` is a *much* better way of doing this since it merges based on the equality of the bytecode. For example, consider `std::repr`. It generates different code per type, but is not included in the type bounds of generics. The `mergefunc` pass works for most of our code but currently hits an assert on libstd. It is receiving attention upstream so it will be ready soon, but I don't think removing this broken code should wait any longer. I've opened #9536 about enabling it by default. Closes #8651 Closes #3547 Closes #2537 Closes #6971 Closes #9222
Rustup r? `@ghost` changelog: none
prints
I suppose the clue is in the name of that attribute, but I figured this case is worth noting--I expected somewhat more subtle unsafety.
It does the right thing if the destructor refers to the field specifically.
The text was updated successfully, but these errors were encountered: