Merged
Conversation
oli-obk
commented
Jul 15, 2025
| T: ~const Destruct, | ||
| { | ||
| match self { | ||
| x @ Some(_) => x, |
Contributor
Author
There was a problem hiding this comment.
This pattern was introduced in #116481 because it optimizes better.
fee1-dead
reviewed
Jul 15, 2025
Comment on lines
+1640
to
+1642
| //FIXME(const_hack): this `T: ~const Destruct` is unnecessary, but even precise live drops can't tell | ||
| // no value of type `T` gets dropped here |
Member
There was a problem hiding this comment.
I have a feeling this will nerdsnipe me hard.
Here's how code is currently generated
#![feature(const_destruct)]
#![feature(const_trait_impl)]
use std::marker::Destruct;
pub const fn opt_or_else<T, F>(this: Option<T>, f: F) -> Option<T>
where
F: ~const Destruct + ~const FnOnce() -> Option<T>,
T: ~const Destruct
{
match this {
x @ Some(_) => x,
None => f()
}
}// MIR FOR CTFE
fn opt_or_else(_1: Option<T>, _2: F) -> Option<T> {
debug this => _1;
debug f => _2;
let mut _0: std::option::Option<T>;
let mut _3: isize;
let _4: std::option::Option<T>;
let mut _5: F;
let mut _6: ();
let mut _7: bool;
let mut _8: bool;
scope 1 {
debug x => _4;
}
bb0: {
_8 = const false;
_7 = const false;
_8 = const true;
_7 = const true;
_3 = discriminant(_1);
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1];
}
bb1: {
unreachable;
}
bb2: {
StorageLive(_5);
_7 = const false;
_5 = move _2;
StorageLive(_6);
_6 = ();
ConstEvalCounter;
_0 = <F as FnOnce<()>>::call_once(move _5, move _6) -> [return: bb4, unwind: bb12];
}
bb3: {
StorageLive(_4);
_8 = const false;
_4 = move _1;
_0 = move _4;
StorageDead(_4);
goto -> bb9;
}
bb4: {
StorageDead(_6);
StorageDead(_5);
goto -> bb9;
}
bb5: {
switchInt(copy _8) -> [0: bb6, otherwise: bb10];
}
bb6: {
return;
}
bb7 (cleanup): {
resume;
}
bb8: {
drop(_2) -> [return: bb5, unwind: bb12];
}
bb9: {
switchInt(copy _7) -> [0: bb5, otherwise: bb8];
}
bb10: {
drop(_1) -> [return: bb6, unwind: bb7];
}
bb11 (cleanup): {
drop(_1) -> [return: bb7, unwind terminate(cleanup)];
}
bb12 (cleanup): {
switchInt(copy _8) -> [0: bb7, otherwise: bb11];
}
}looks like it tries to drop self at the None arm, which is just weird.
fee1-dead
requested changes
Jul 17, 2025
library/core/src/option.rs
Outdated
| #[stable(feature = "is_some_and", since = "1.70.0")] | ||
| pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool { | ||
| #[rustc_const_unstable(feature = "const_option_ops", issue = "143956")] | ||
| pub const fn is_some_and(self, f: impl ~const Destruct + ~const FnOnce(T) -> bool) -> bool { |
Member
There was a problem hiding this comment.
I think we should put FnOnce first, here and elsewhere in the PR. the destruct bound is noisy and likely to make it harder for someone to read the code.
5d2acad to
853333d
Compare
Contributor
Author
|
@bors r=fee1-dead |
Collaborator
fmease
added a commit
to fmease/rust
that referenced
this pull request
Jul 17, 2025
…e1-dead constify `Option` methods r? `@fee1-dead` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
fmease
added a commit
to fmease/rust
that referenced
this pull request
Jul 17, 2025
…e1-dead constify `Option` methods r? ``@fee1-dead`` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
bors
added a commit
that referenced
this pull request
Jul 17, 2025
Rollup of 15 pull requests Successful merges: - #142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - #143271 (Store the type of each GVN value) - #143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - #143719 (Emit warning when there is no space between `-o` and arg) - #143833 (Ban projecting into SIMD types [MCP838]) - #143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - #143879 (parse `const trait Trait`) - #143891 (Port `#[coverage]` to the new attribute system) - #143967 (constify `Option` methods) - #143985 (rustc_public: de-StableMIR-ize) - #144008 (Fix false positive double negations with macro invocation) - #144010 (Boostrap: add warning on `optimize = false`) - #144034 (tests: Test line number in debuginfo for diverging function calls) - #144049 (rustc-dev-guide subtree update) - #144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 17, 2025
…e1-dead constify `Option` methods r? ```@fee1-dead``` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
bors
added a commit
that referenced
this pull request
Jul 17, 2025
Rollup of 12 pull requests Successful merges: - #142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - #143271 (Store the type of each GVN value) - #143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - #143719 (Emit warning when there is no space between `-o` and arg) - #143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - #143891 (Port `#[coverage]` to the new attribute system) - #143967 (constify `Option` methods) - #144008 (Fix false positive double negations with macro invocation) - #144010 (Boostrap: add warning on `optimize = false`) - #144034 (tests: Test line number in debuginfo for diverging function calls) - #144049 (rustc-dev-guide subtree update) - #144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Jul 17, 2025
Rollup of 12 pull requests Successful merges: - #142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - #143271 (Store the type of each GVN value) - #143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - #143719 (Emit warning when there is no space between `-o` and arg) - #143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - #143891 (Port `#[coverage]` to the new attribute system) - #143967 (constify `Option` methods) - #144008 (Fix false positive double negations with macro invocation) - #144010 (Boostrap: add warning on `optimize = false`) - #144034 (tests: Test line number in debuginfo for diverging function calls) - #144049 (rustc-dev-guide subtree update) - #144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 18, 2025
…e1-dead constify `Option` methods r? ````@fee1-dead```` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 18, 2025
…e1-dead constify `Option` methods r? `````@fee1-dead````` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jul 18, 2025
…e1-dead constify `Option` methods r? ``````@fee1-dead`````` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
This was referenced Jul 18, 2025
bors
added a commit
that referenced
this pull request
Jul 18, 2025
Rollup of 11 pull requests Successful merges: - #142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - #143271 (Store the type of each GVN value) - #143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - #143719 (Emit warning when there is no space between `-o` and arg) - #143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - #143891 (Port `#[coverage]` to the new attribute system) - #143967 (constify `Option` methods) - #144008 (Fix false positive double negations with macro invocation) - #144010 (Boostrap: add warning on `optimize = false`) - #144049 (rustc-dev-guide subtree update) - #144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Jul 19, 2025
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Jul 21, 2025
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
Muscraft
pushed a commit
to Muscraft/rust
that referenced
this pull request
Jul 21, 2025
…e1-dead constify `Option` methods r? ```````@fee1-dead``````` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
Muscraft
pushed a commit
to Muscraft/rust
that referenced
this pull request
Jul 21, 2025
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang#143271 (Store the type of each GVN value) - rust-lang#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang#143891 (Port `#[coverage]` to the new attribute system) - rust-lang#143967 (constify `Option` methods) - rust-lang#144008 (Fix false positive double negations with macro invocation) - rust-lang#144010 (Boostrap: add warning on `optimize = false`) - rust-lang#144049 (rustc-dev-guide subtree update) - rust-lang#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this pull request
Jul 29, 2025
…e1-dead constify `Option` methods r? ```````@fee1-dead``````` tracking issue: rust-lang#143956 these unblock making `PartialOrd` and `Ord` const without resorting to inlining some of these at call sites.
Kobzol
pushed a commit
to Kobzol/rustc_codegen_gcc
that referenced
this pull request
Dec 21, 2025
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
Kobzol
pushed a commit
to Kobzol/rustc_codegen_cranelift
that referenced
this pull request
Dec 29, 2025
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
christian-schilling
pushed a commit
to christian-schilling/rustc_codegen_cranelift
that referenced
this pull request
Jan 27, 2026
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
christian-schilling
pushed a commit
to christian-schilling/rustc_codegen_cranelift
that referenced
this pull request
Jan 27, 2026
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r? @fee1-dead
tracking issue: #143956
these unblock making
PartialOrdandOrdconst without resorting to inlining some of these at call sites.