Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Extend the enum check to pointer and union reads - #144353

Open
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr
Open

Extend the enum check to pointer and union reads#144353
1c3t3a wants to merge 2 commits into
rust-lang:mainfrom
1c3t3a:enum-check-enum-ptr

Conversation

@1c3t3a

@1c3t3a1c3t3a commented Jul 23, 2025

Copy link
Copy Markdown
Member

View all comments

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

This is related to #143087.

r? @saethlin

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0dCompareJuly 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from ec30c0d to 852275fCompareJuly 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 852275f to aeaa360CompareJuly 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4CompareJuly 24, 2025 14:21
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch 2 times, most recently from e9cba62 to 8ae0303CompareAugust 6, 2025 13:29
@rust-log-analyzer

This comment has been minimized.

@saethlinsaethlin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2025
@saethlin

Copy link
Copy Markdown
Member

CI doesn't pass, so I'm setting this to waiting on author. If that's wrong and you want help with getting CI to pass, give a shout.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 8ae0303 to bae1afdCompareNovember 4, 2025 10:21
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from bae1afd to a969bf9CompareNovember 4, 2025 10:40
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @vakaras

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 557081f to 5bf5a01CompareDecember 9, 2025 06:04
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from 5bf5a01 to e167550CompareDecember 9, 2025 07:12
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3aforce-pushed the enum-check-enum-ptr branch from e167550 to e6f5eb3CompareDecember 9, 2025 07:29
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@rustbot

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY TAG IMAGE ID CREATED SIZE
ghcr.io/dependabot/dependabot-updater-core latest afc745c7535d 3 weeks ago 783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_nounwind_fmt
2: core::panicking::panic_misaligned_pointer_dereference
3: <rustc_middle::mir::syntax::Rvalue>::ty::<rustc_middle::mir::Body>
4: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_statement
5: <rustc_borrowck::type_check::TypeChecker as rustc_middle::mir::visit::Visitor>::visit_body
6: rustc_borrowck::type_check::type_check
7: rustc_borrowck::borrowck_collect_region_constraints
8: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
9: rustc_borrowck::mir_borrowck
[... omitted 2 frames ...]
10: rustc_mir_transform::mir_drops_elaborated_and_const_checked
[... omitted 2 frames ...]
11: rustc_mir_transform::mir_for_ctfe
[... omitted 2 frames ...]
12: rustc_mir_transform::optimized_mir
[... omitted 2 frames ...]
13: rustc_mir_transform::deduce_param_attrs::deduced_param_attrs
[... omitted 2 frames ...]
14: rustc_ty_utils::abi::fn_abi_new_uncached
15: rustc_ty_utils::abi::fn_abi_of_instance
[... omitted 2 frames ...]
16: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine> as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance
17: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
18: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_terminator
19: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
[... omitted 2 frames ...]
20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
21: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>>
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::analysis
[... omitted 2 frames ...]
24: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
25: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}>
26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
27: std::panicking::catch_unwind::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}>>
28: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
29: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2026-02-19T18_34_06-39467.txt`: Read-only file system (os error 30)
note: rustc 1.95.0-nightly (183457d66 2026-02-19) running on aarch64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C symbol-mangling-version=v0 -Z annotate-moves -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C link-arg=-L/usr/lib/llvm-20/lib -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z binary-dep-depinfo -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#2 [mir_for_ctfe] caching mir of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github` for CTFE
#3 [optimized_mir] optimizing MIR for `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#4 [deduced_param_attrs] deducing parameter attributes for prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github
#5 [fn_abi_of_instance] computing call ABI of `prepare::<impl at compiler/rustc_codegen_cranelift/build_system/prepare.rs:69:1: 69:13>::github`
#6 [eval_static_initializer] evaluating initializer of static `abi_cafe::ABI_CAFE_REPO`
#7 [analysis] running analysis passes on crate `y`
end of query stack
thread caused non-unwinding panic. aborting.
[RUSTC-TIMING] y test:false 0.439
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `y` (bin "y")
Caused by:
process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name y --edition=2021 compiler/rustc_codegen_cranelift/build_system/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("unstable-features"))' -C metadata=7254b91c94d9ae57 -C extra-filename=-fe9a244d40edbf17 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/release/deps -Csymbol-mangling-version=v0 -Zannotate-moves -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' -Zmacro-backtrace -Csplit-debuginfo=off -Clink-arg=-L/usr/lib/llvm-20/lib -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Z binary-dep-depinfo` (exit status: 254)
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run -Zwarnings --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 101
Created at: src/bootstrap/src/core/build_steps/test.rs:3877:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3922:26
Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:24:45
local time: Thu Feb 19 18:34:06 UTC 2026
network time: Thu, 19 Feb 2026 18:34:07 GMT
##[error]Process completed with exit code 1.

@rust-bors

rust-borsBot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #153741) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@1c3t3a@rustbot@rust-log-analyzer@saethlin