Skip to content

[POC] create an MVP for using Destruct for custom dtors - #156090

Draft
JayanAXHF wants to merge 10 commits into
rust-lang:mainfrom
JayanAXHF:feat/better_drop_semantics
Draft

[POC] create an MVP for using Destruct for custom dtors#156090
JayanAXHF wants to merge 10 commits into
rust-lang:mainfrom
JayanAXHF:feat/better_drop_semantics

Conversation

@JayanAXHF

@JayanAXHF JayanAXHF commented May 2, 2026

Copy link
Copy Markdown
Member

View all comments

  1. We redirect drop glue to Destruct::drop_in_place instead of mem::ptr::drop_in_place.
  2. Theres a new lang item for DestructDropInPlace
  3. The old solver checks for user candidates for impl in candidate_assembly, and only checks for builtin impl when it doesnt find one
  4. The new trait solver does something similar, and checks for user impls before calling assemble_builtin_impl_candidates

cc: @Nadrieril and @oli-obk (you were interested in reviewing this from the PG)

Note that this is a POC and i've not ironed out the comments and im not 100% confident that this is the best way to do this.

r? ghost

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels May 2, 2026
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF
JayanAXHF force-pushed the feat/better_drop_semantics branch from 13224fe to e48ef91 Compare May 3, 2026 04:10
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF
JayanAXHF force-pushed the feat/better_drop_semantics branch from e48ef91 to 30d34f8 Compare May 3, 2026 04:24
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF
JayanAXHF force-pushed the feat/better_drop_semantics branch from 30d34f8 to 1a1e29a Compare May 3, 2026 04:33
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF
JayanAXHF force-pushed the feat/better_drop_semantics branch from 1a1e29a to 74b13aa Compare May 3, 2026 05:05
@rust-log-analyzer

This comment has been minimized.

@JayanAXHF

Copy link
Copy Markdown
Member Author

welp i have no idea what this is. Is this due to smth with cg_clift? do i need to make changes there

@JayanAXHF

JayanAXHF commented May 3, 2026

Copy link
Copy Markdown
Member Author

fixed it i think, it was related to the minicores not being updated

@rustbot rustbot added A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels May 3, 2026
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk mentioned this pull request May 3, 2026
@JayanAXHF

Copy link
Copy Markdown
Member Author

It was another mini_core smh

///
/// Generated by default if not implemented manually.
#[lang = "destruct_drop_in_place"]
unsafe fn drop_in_place(_to_drop: *mut Self);

@Nadrieril Nadrieril May 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To limit the amount of trait-related magic, I would rather do this:

Suggested change
unsafe fn drop_in_place(_to_drop: *mut Self);
/// Entrypoint for drop. Called when a value is still live at end of scope
/// if none of its fields have been moved out of.
///
/// The default implementation calls `Drop::drop` if implemented,
/// then recursively calls `drop_in_place` on each field in order.
#[lang = "destruct_drop_in_place"]
unsafe fn drop_in_place(to_drop: *mut Self) {
core::intrinsics::drop_in_place_shim(to_drop);
}

and then have the intrinsic be the only thing that's auto-generated.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO there isn't much trait magic right now; the resolver simply checks if there are any user impls, and only assembles builtin ones if there aren't any. IMO this indirection would be rather confusing and also might clash with Specialization

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the opposite intuition: having a method that magically has a body generated for it is not something that exists in rust; only intrinsics do that. And I don't see why this would interact with specialization in any way. Moreover this has the benefit that if someone wants to they can call the auto-generated drop glue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The person can still invoke Destruct::drop_in_place manually, although it causes smth like a double drop issue.

Hey i was dropped
test
Hey i was dropped

I'll work on this. If you're talking about having both a custom dtor and the default one, i see very little usecase for that. Maybe that's just my intuition, but i prefer some less indirection, as this approach makes it more obvious how drop is being called (its just a function call, rather than what Drop::drop did, which called ptr::drop_in_place)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if I want to override Destruct::drop_in_place in a way that reuses the default thing, e.g. because you want to call it conditionally. I agree it's probably rare.

its just a function call, rather than what Drop::drop did, which called ptr::drop_in_place

I'm confused: Drop::drop never called ptr::drop_in_place.

Comment thread compiler/rustc_ty_utils/src/instance.rs Outdated
Comment on lines -41 to -67
if ty.needs_drop(tcx, typing_env) {
debug!(" => nontrivial drop glue");
match *ty.kind() {
ty::Coroutine(coroutine_def_id, ..) => {
// FIXME: sync drop of coroutine with async drop (generate both versions?)
// Currently just ignored
if tcx.optimized_mir(coroutine_def_id).coroutine_drop_async().is_some() {
ty::InstanceKind::DropGlue(def_id, None)
} else {
ty::InstanceKind::DropGlue(def_id, Some(ty))
}
}
ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Tuple(..)
| ty::Adt(..)
| ty::Dynamic(..)
| ty::Array(..)
| ty::Slice(..)
| ty::UnsafeBinder(..) => ty::InstanceKind::DropGlue(def_id, Some(ty)),
// Drop shims can only be built from ADTs.
_ => return Ok(None),
}
} else {
debug!(" => trivial drop glue");
ty::InstanceKind::DropGlue(def_id, None)
}

@Nadrieril Nadrieril May 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For perf reasons I expect we should keep some of this shortcutting. Also whatever's happening with async drop feels important, why is it ok to remove it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look soon, thanks for pointing this out

@JayanAXHF JayanAXHF May 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but why is that ok and why is that useful? Doesn't this return the wrong instance kind in some cases now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with what kinds of instances it can return. I'll look up on that and run the tests to find any regressions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so there was a bug where it wouldn't rebase the args in this early return. The fix was pretty simple

@JayanAXHF JayanAXHF Aug 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also i feel like this might actually be a perf regression. can we get a crater perf run or smth?

@rust-log-analyzer

This comment has been minimized.

@Nadrieril Nadrieril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(github decided to not send my coments and make them review comments so I have to make a top-level review)

View changes since this review

Comment thread compiler/rustc_ty_utils/src/instance.rs Outdated
Comment on lines -41 to -67
if ty.needs_drop(tcx, typing_env) {
debug!(" => nontrivial drop glue");
match *ty.kind() {
ty::Coroutine(coroutine_def_id, ..) => {
// FIXME: sync drop of coroutine with async drop (generate both versions?)
// Currently just ignored
if tcx.optimized_mir(coroutine_def_id).coroutine_drop_async().is_some() {
ty::InstanceKind::DropGlue(def_id, None)
} else {
ty::InstanceKind::DropGlue(def_id, Some(ty))
}
}
ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Tuple(..)
| ty::Adt(..)
| ty::Dynamic(..)
| ty::Array(..)
| ty::Slice(..)
| ty::UnsafeBinder(..) => ty::InstanceKind::DropGlue(def_id, Some(ty)),
// Drop shims can only be built from ADTs.
_ => return Ok(None),
}
} else {
debug!(" => trivial drop glue");
ty::InstanceKind::DropGlue(def_id, None)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but why is that ok and why is that useful? Doesn't this return the wrong instance kind in some cases now?

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Comment on lines +143 to +156
if tcx.is_lang_item(trait_ref.def_id, LangItem::Destruct) {
if !tcx.is_lang_item(trait_item_id, LangItem::DestructDropInPlace) {
bug!(
"unexpected associated item for built-in `{trait_ref}`: {}",
tcx.item_name(trait_item_id)
);
}

debug!("Got user Destruct impl");
return Ok(Some(Instance {
def: ty::InstanceKind::Item(leaf_def.item.def_id),
args: rcvr_args,
}));
}

@Nadrieril Nadrieril May 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this early return useful/necessary? Please add a comment explaning its purpose

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment for that. its basically to skip some of the rest of the code that deals with dyn Trait overlap and specialization because Destruct is neither object-safe nor does it have any specialization concerns here.

@Nadrieril

Copy link
Copy Markdown
Member

Per the recent #154327, our new methods should take &mut self instead of *mut self.

@JayanAXHF
JayanAXHF force-pushed the feat/better_drop_semantics branch from 4d422f9 to 4a6c469 Compare July 28, 2026 09:28
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/consts/miri_unleashed/assoc_const.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const/assoc_const.stderr`
diff of stderr:

4 LL |     const F: u32 = (U::X, 42).1;
5    |                               ^ evaluation of `<NotConstDestruct as Bar<NotConstDestruct, NotConstDestruct>>::F` failed inside this call
6    |
- note: inside `std::ptr::drop_glue::<(NotConstDestruct, u32)> - shim(Some((NotConstDestruct, u32)))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- note: inside `std::ptr::drop_glue::<NotConstDestruct> - shim(Some(NotConstDestruct))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
+ note: inside `<(NotConstDestruct, u32) as Destruct>::drop_in_place - shim(Some((NotConstDestruct, u32)))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
11 
12 note: erroneous constant encountered
13   --> $DIR/assoc_const.rs:36:13

Note: some mismatched output was normalized before being compared
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
+ note: inside `<(NotConstDestruct, u32) as Destruct>::drop_in_place - shim(Some((NotConstDestruct, u32)))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/miri_unleashed/assoc_const.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/miri_unleashed/assoc_const.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/miri_unleashed/assoc_const" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you"
stdout: none
--- stderr -------------------------------
error[E0080]: calling non-const function `<NotConstDestruct as Drop>::drop`
##[error]  --> /checkout/tests/ui/consts/miri_unleashed/assoc_const.rs:19:31
   |
LL |     const F: u32 = (U::X, 42).1; //~ ERROR
   |                               ^ evaluation of `<NotConstDestruct as Bar<NotConstDestruct, NotConstDestruct>>::F` failed inside this call
   |
note: inside `<(NotConstDestruct, u32) as Destruct>::drop_in_place - shim(Some((NotConstDestruct, u32)))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4

note: erroneous constant encountered
  --> /checkout/tests/ui/consts/miri_unleashed/assoc_const.rs:36:13
   |
LL |     let y = <NotConstDestruct as Bar<NotConstDestruct, NotConstDestruct>>::F;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: erroneous constant encountered
  --> /checkout/tests/ui/consts/miri_unleashed/assoc_const.rs:36:13
   |
LL |     let y = <NotConstDestruct as Bar<NotConstDestruct, NotConstDestruct>>::F;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: skipping const checks
   |
help: skipping check that does not even have a feature gate
  --> /checkout/tests/ui/consts/miri_unleashed/assoc_const.rs:19:20
   |
LL |     const F: u32 = (U::X, 42).1; //~ ERROR
   |                    ^^^^^^^^^^

error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0080`.
---

4 LL | };
5    | ^ evaluation of `TEST_BAD` failed inside this call
6    |
- note: inside `std::ptr::drop_glue::<NotConstDestruct> - shim(Some(NotConstDestruct))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
9 
10 warning: skipping const checks
11    |

Note: some mismatched output was normalized before being compared
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/miri_unleashed/drop.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/miri_unleashed/drop.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/miri_unleashed/drop" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Zunleash-the-miri-inside-of-you"
stdout: none
--- stderr -------------------------------
error[E0080]: calling non-const function `<NotConstDestruct as Drop>::drop`
##[error]  --> /checkout/tests/ui/consts/miri_unleashed/drop.rs:23:1
   |
LL | }; //~ NOTE failed inside this call
   | ^ evaluation of `TEST_BAD` failed inside this call
   |
note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4

warning: skipping const checks
   |
help: skipping check that does not even have a feature gate
---

13 LL | };
14    | ^ evaluation of `A1` failed inside this call
15    |
- note: inside `std::ptr::drop_glue::<Option<NotConstDestruct>> - shim(Some(Option<NotConstDestruct>))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- note: inside `std::ptr::drop_glue::<NotConstDestruct> - shim(Some(NotConstDestruct))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
+ note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
20 
21 error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
22   --> $DIR/qualif-indirect-mutation-fail.rs:34:9

32 LL | };
33    | ^ evaluation of `A2` failed inside this call
34    |
- note: inside `std::ptr::drop_glue::<Option<NotConstDestruct>> - shim(Some(Option<NotConstDestruct>))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
- note: inside `std::ptr::drop_glue::<NotConstDestruct> - shim(Some(NotConstDestruct))`
-   --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
+ note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
39 
40 error[E0493]: destructor of `(u32, Option<NotConstDestruct>)` cannot be evaluated at compile-time
41   --> $DIR/qualif-indirect-mutation-fail.rs:12:9

Note: some mismatched output was normalized before being compared
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
-   --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
+ note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL
+ note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
+   --> $SRC_DIR/core/src/marker.rs:LL:COL


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/qualif-indirect-mutation-fail.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/qualif-indirect-mutation-fail" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--crate-type=lib"
stdout: none
--- stderr -------------------------------
error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:18:9
   |
LL |     let mut x = None; //~ ERROR destructor of
   |         ^^^^^ the destructor for this type cannot be evaluated in constants
...
LL | }; //~ ERROR calling non-const function `<NotConstDestruct as Drop>::drop`
   | - value is dropped here

error[E0080]: calling non-const function `<NotConstDestruct as Drop>::drop`
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:24:1
   |
LL | }; //~ ERROR calling non-const function `<NotConstDestruct as Drop>::drop`
   | ^ evaluation of `A1` failed inside this call
   |
note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4

error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:34:9
   |
LL |     let _z = x; //~ ERROR destructor of
   |         ^^ the destructor for this type cannot be evaluated in constants
LL | }; //~ ERROR calling non-const function `<NotConstDestruct as Drop>::drop`
   | - value is dropped here

error[E0080]: calling non-const function `<NotConstDestruct as Drop>::drop`
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:35:1
   |
LL | }; //~ ERROR calling non-const function `<NotConstDestruct as Drop>::drop`
   | ^ evaluation of `A2` failed inside this call
   |
note: inside `<Option<NotConstDestruct> as Destruct>::drop_in_place - shim(Some(Option<NotConstDestruct>))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4
note: inside `<NotConstDestruct as Destruct>::drop_in_place - shim(Some(NotConstDestruct))`
  --> /rustc/FAKE_PREFIX/library/core/src/marker.rs:1067:4

error[E0493]: destructor of `(u32, Option<NotConstDestruct>)` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:12:9
   |
LL |     let mut a: (u32, Option<NotConstDestruct>) = (0, None); //~ ERROR destructor of
   |         ^^^^^ the destructor for this type cannot be evaluated in constant functions
LL |     let _ = &mut a.1;
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:39:9
   |
LL |     let x: Option<T> = None; //~ ERROR destructor of
   |         ^ the destructor for this type cannot be evaluated in constant functions
LL |     let _ = x.is_some();
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<T>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:47:9
   |
LL |     let _y = x; //~ ERROR destructor of
   |         ^^ the destructor for this type cannot be evaluated in constant functions
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:55:9
   |
LL |     let mut y: Option<NotConstDestruct> = None; //~ ERROR destructor of
   |         ^^^^^ the destructor for this type cannot be evaluated in constant functions
LL |     std::ptr::addr_of_mut!(y);
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:52:9
   |
LL |     let mut x: Option<NotConstDestruct> = None; //~ ERROR destructor of
   |         ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:65:9
   |
LL |     let y: Option<NotConstDestruct> = None; //~ ERROR destructor of
   |         ^ the destructor for this type cannot be evaluated in constant functions
LL |     std::ptr::addr_of!(y);
LL | }
   | - value is dropped here

error[E0493]: destructor of `Option<NotConstDestruct>` cannot be evaluated at compile-time
##[error]  --> /checkout/tests/ui/consts/qualif-indirect-mutation-fail.rs:62:9
   |
LL |     let x: Option<NotConstDestruct> = None; //~ ERROR destructor of
   |         ^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
   | - value is dropped here

---

---- [ui] tests/ui/consts/qualif-indirect-mutation-fail.rs stdout end ----
---- [ui] tests/ui/sanitizer/cfi/drop-in-place.rs stdout ----

error: test did not exit with success! code=None so test would pass with `run-crash`
status: signal: 5 (SIGTRAP) (core dumped)
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitizer/cfi/drop-in-place" && RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitizer/cfi/drop-in-place/a"
stdout: none
stderr: none

---- [ui] tests/ui/sanitizer/cfi/drop-in-place.rs stdout end ----
---- [ui] tests/ui/sanitizer/cfi/coroutine.rs#cfi stdout ----

error in revision `cfi`: test did not exit with success! code=None so test would pass with `run-crash`
status: signal: 5 (SIGTRAP) (core dumped)
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitizer/cfi/coroutine.cfi" && RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitizer/cfi/coroutine.cfi/a"
--- stdout -------------------------------

running 4 tests
------------------------------------------
stderr: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants