Uh oh!
There was an error while loading. Please reload this page.
Suggest the [const] Destruct bound for type parameters in const functions when missing - #155013
Conversation
rustbot
commented
Apr 8, 2026
Some changes occurred to constck cc @fee1-dead Some changes occurred to the CTFE machinery |
rustbot
commented
Apr 8, 2026
r? @wesleywiser rustbot has assigned @wesleywiser. Use Why was this reviewer chosen?The reviewer was selected based on:
|
[const] Destruct bound for type parameters in const functions[const] Destruct bound for type parameters in const functions when missingKivooeo
commented
Apr 8, 2026
thanks for the contribution, but this is experimental syntax which means syntax may change in future, so I think it should be held until stabilization |
rustbot
commented
Apr 24, 2026
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jakubadamw
commented
Jul 13, 2026
@wesleywiser, thank you, I made the suggestion trigger on nightly only. 🙂 |
This comment has been minimized.
This comment has been minimized.
…ctions When a const function drops a value whose type is a type parameter, suggest adding a `[const] Destruct` bound so the destructor can be evaluated at compile-time.
The suggested bound requires the unstable `const_destruct` feature, so it is not actionable on a stable compiler. Add a run-make test that verifies the suggestion is only emitted on nightly.
rustbot
commented
Jul 13, 2026
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Suggest the `[const] Destruct` bound for type parameters in const functions when missing When a const function drops a value whose type is a type parameter without a `[const] Destruct` bound, suggest adding it so that the destructor can be evaluated at compile-time. Closesrust-lang#103270. Example: ```rust const fn f(_x: impl std::fmt::Debug) {} ``` Before: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions ``` After: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions | help: consider restricting opaque type `impl std::fmt::Debug` with unstable trait `Destruct` | LL | const fn f(_x: impl std::fmt::Debug + [const] Destruct) {} | ++++++++++++++++++ ``` No new tests as the existing ones had their results updated with the new suggestion.
Suggest the `[const] Destruct` bound for type parameters in const functions when missing When a const function drops a value whose type is a type parameter without a `[const] Destruct` bound, suggest adding it so that the destructor can be evaluated at compile-time. Closesrust-lang#103270. Example: ```rust const fn f(_x: impl std::fmt::Debug) {} ``` Before: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions ``` After: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions | help: consider restricting opaque type `impl std::fmt::Debug` with unstable trait `Destruct` | LL | const fn f(_x: impl std::fmt::Debug + [const] Destruct) {} | ++++++++++++++++++ ``` No new tests as the existing ones had their results updated with the new suggestion.
…uwer Rollup of 22 pull requests Successful merges: - #156047 (Fix trait method resolution on an adjusted never type) - #157824 (Comptime inherent impls) - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - #158723 (Support EII on Windows MSVC) - #158993 (rerun in original typing mode if we meet any opaques in post analysis) - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - #159183 (Introduce InstanceKind::LlvmIntrinsic) - #159251 (Bump rustc-perf submodule) - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - #159155 (unstable book: Document `diagnostic_on_unknown` feature) - #159235 (Add regression test for #95719) - #159243 (inline Once wait and wait_force) - #159255 (Replace shortened type with `_` instead of `...` as placeholder) - #159259 (Add regression test for #144033) - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - #159269 (disable range-len-try-from.rs on s390x) - #159272 (slice: make swap delegate to swap_unchecked) - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - #159275 (remove obsolete comment) - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - #159283 (Remove obsolete verbose flag from deref/ref suggestions) - #159290 (rustc-dev-guide subtree update)
…uwer Rollup of 22 pull requests Successful merges: - #156047 (Fix trait method resolution on an adjusted never type) - #157824 (Comptime inherent impls) - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - #158723 (Support EII on Windows MSVC) - #158993 (rerun in original typing mode if we meet any opaques in post analysis) - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - #159183 (Introduce InstanceKind::LlvmIntrinsic) - #159251 (Bump rustc-perf submodule) - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - #159155 (unstable book: Document `diagnostic_on_unknown` feature) - #159235 (Add regression test for #95719) - #159243 (inline Once wait and wait_force) - #159255 (Replace shortened type with `_` instead of `...` as placeholder) - #159259 (Add regression test for #144033) - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - #159269 (disable range-len-try-from.rs on s390x) - #159272 (slice: make swap delegate to swap_unchecked) - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - #159275 (remove obsolete comment) - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - #159283 (Remove obsolete verbose flag from deref/ref suggestions) - #159290 (rustc-dev-guide subtree update)
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #155013 - jakubadamw:issue-103270, r=oli-obk Suggest the `[const] Destruct` bound for type parameters in const functions when missing When a const function drops a value whose type is a type parameter without a `[const] Destruct` bound, suggest adding it so that the destructor can be evaluated at compile-time. Closes#103270. Example: ```rust const fn f(_x: impl std::fmt::Debug) {} ``` Before: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions ``` After: ``` error[E0493]: destructor of `impl std::fmt::Debug` cannot be evaluated at compile-time --> $DIR/min_const_fn.rs:1:11 | LL | const fn f(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | the destructor for this type cannot be evaluated in constant functions | help: consider restricting opaque type `impl std::fmt::Debug` with unstable trait `Destruct` | LL | const fn f(_x: impl std::fmt::Debug + [const] Destruct) {} | ++++++++++++++++++ ``` No new tests as the existing ones had their results updated with the new suggestion.
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#156047 (Fix trait method resolution on an adjusted never type) - rust-lang/rust#157824 (Comptime inherent impls) - rust-lang/rust#158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - rust-lang/rust#158723 (Support EII on Windows MSVC) - rust-lang/rust#158993 (rerun in original typing mode if we meet any opaques in post analysis) - rust-lang/rust#159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - rust-lang/rust#159183 (Introduce InstanceKind::LlvmIntrinsic) - rust-lang/rust#159251 (Bump rustc-perf submodule) - rust-lang/rust#155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - rust-lang/rust#159155 (unstable book: Document `diagnostic_on_unknown` feature) - rust-lang/rust#159235 (Add regression test for rust-lang/rust#95719) - rust-lang/rust#159243 (inline Once wait and wait_force) - rust-lang/rust#159255 (Replace shortened type with `_` instead of `...` as placeholder) - rust-lang/rust#159259 (Add regression test for rust-lang/rust#144033) - rust-lang/rust#159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - rust-lang/rust#159269 (disable range-len-try-from.rs on s390x) - rust-lang/rust#159272 (slice: make swap delegate to swap_unchecked) - rust-lang/rust#159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - rust-lang/rust#159275 (remove obsolete comment) - rust-lang/rust#159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - rust-lang/rust#159283 (Remove obsolete verbose flag from deref/ref suggestions) - rust-lang/rust#159290 (rustc-dev-guide subtree update)
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#156047 (Fix trait method resolution on an adjusted never type) - rust-lang/rust#157824 (Comptime inherent impls) - rust-lang/rust#158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - rust-lang/rust#158723 (Support EII on Windows MSVC) - rust-lang/rust#158993 (rerun in original typing mode if we meet any opaques in post analysis) - rust-lang/rust#159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - rust-lang/rust#159183 (Introduce InstanceKind::LlvmIntrinsic) - rust-lang/rust#159251 (Bump rustc-perf submodule) - rust-lang/rust#155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - rust-lang/rust#159155 (unstable book: Document `diagnostic_on_unknown` feature) - rust-lang/rust#159235 (Add regression test for rust-lang/rust#95719) - rust-lang/rust#159243 (inline Once wait and wait_force) - rust-lang/rust#159255 (Replace shortened type with `_` instead of `...` as placeholder) - rust-lang/rust#159259 (Add regression test for rust-lang/rust#144033) - rust-lang/rust#159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - rust-lang/rust#159269 (disable range-len-try-from.rs on s390x) - rust-lang/rust#159272 (slice: make swap delegate to swap_unchecked) - rust-lang/rust#159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - rust-lang/rust#159275 (remove obsolete comment) - rust-lang/rust#159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - rust-lang/rust#159283 (Remove obsolete verbose flag from deref/ref suggestions) - rust-lang/rust#159290 (rustc-dev-guide subtree update)
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#156047 (Fix trait method resolution on an adjusted never type) - rust-lang/rust#157824 (Comptime inherent impls) - rust-lang/rust#158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`) - rust-lang/rust#158723 (Support EII on Windows MSVC) - rust-lang/rust#158993 (rerun in original typing mode if we meet any opaques in post analysis) - rust-lang/rust#159160 (Make `HasTokens` a sub-trait of `HasAttrs`.) - rust-lang/rust#159183 (Introduce InstanceKind::LlvmIntrinsic) - rust-lang/rust#159251 (Bump rustc-perf submodule) - rust-lang/rust#155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing) - rust-lang/rust#159155 (unstable book: Document `diagnostic_on_unknown` feature) - rust-lang/rust#159235 (Add regression test for rust-lang/rust#95719) - rust-lang/rust#159243 (inline Once wait and wait_force) - rust-lang/rust#159255 (Replace shortened type with `_` instead of `...` as placeholder) - rust-lang/rust#159259 (Add regression test for rust-lang/rust#144033) - rust-lang/rust#159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable) - rust-lang/rust#159269 (disable range-len-try-from.rs on s390x) - rust-lang/rust#159272 (slice: make swap delegate to swap_unchecked) - rust-lang/rust#159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`) - rust-lang/rust#159275 (remove obsolete comment) - rust-lang/rust#159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants) - rust-lang/rust#159283 (Remove obsolete verbose flag from deref/ref suggestions) - rust-lang/rust#159290 (rustc-dev-guide subtree update)
When a const function drops a value whose type is a type parameter without a
[const] Destructbound, suggest adding it so that the destructor can be evaluated at compile-time.Closes#103270.
Example:
Before:
After:
No new tests as the existing ones had their results updated with the new suggestion.