-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MIR should never emit references to std::intrinsics::drop_in_place
#82189
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
Comments
Note that the test case here will probably stop working once #82122 lands, but that PR contains nothing that should be having any effect on this. The underlying bug will still remain somewhere. This matters because if #82123 is ever fixed it might cause #82122 to be reverted, which would cause this bug to manifest again. |
Given that one is a reexport of the other, there is no meaningful difference between the two, MIR isn't making a choice here (nor could it - either way to refer to that function resolves to the same So this is just an arbitrary printing choice between Also, while #![no_std]
fn foo() {
unsafe { core::ptr::drop_in_place(&mut 1); }
} The only reason #82122 changes anything is because it removes the reexport, and causes two functions to exist instead (so the |
You can also see it in this example (playground): fn main() {
std::collections::BTreeSet::<()>::new();
} _1 = BTreeSet::<()>::new() -> bb1; // scope 0 at src/main.rs:2:5: 2:44
// mir::Constant
// + span: src/main.rs:2:5: 2:42
// + user_ty: UserType(0)
// + literal: Const { ty: fn() -> std::collections::BTreeSet<()> {std::collections::BTreeSet::<()>::new}, val: Value(Scalar(<ZST>)) }
|
Okay so seems like we should close this as not-a-bug? MIR is using the right |
Yeah, and while you should be able to replicate with You can see it in the error message on 1.47 and earlier: https://godbolt.org/z/f6sj8d (i.e. before the short path changes). |
When the
drop_in_place
feature was first stabilized, its lang item (and stable interface) wasintrinsics::drop_in_place
. Later in f2c7917 ,intrinsics::drop_in_place
was deprecated in favor ofptr::drop_in_place
. However the deprecation never actually happened in practice, because#[rustc_deprecated]
does nothing when applied to a re-export. This was remedied in #82122 , which also discovered that somehow, somewhere, MIR is still emitting hardcoded references tointrinsics::drop_in_place
, ignoring the fact that the lang item isptr::drop_in_place
.Test case:
Output when compiled with
rustc --emit=mir
:Notice the line
// + literal: Const { ty: unsafe fn(*mut i32) {std::intrinsics::drop_in_place::<i32>}
. This should be referring toptr::drop_in_place
instead.The text was updated successfully, but these errors were encountered: