Pretty print pattern type values with transmute if they don't satisfy their pattern#136235
Merged
bors merged 1 commit intorust-lang:masterfrom Feb 6, 2025
Merged
Pretty print pattern type values with transmute if they don't satisfy their pattern#136235bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
lcnr
reviewed
Jan 29, 2025
| cx.validate_operand( | ||
| &allocated.into(), | ||
| /*recursive*/ false, | ||
| /*reset_provenance_and_padding*/ false, |
Contributor
There was a problem hiding this comment.
existing, but maybe use enums instead of bool + comments :3
ace8014 to
291f59b
Compare
RalfJung
reviewed
Jan 30, 2025
compiler/rustc_const_eval/src/util/validate_scalar_in_layout.rs
Outdated
Show resolved
Hide resolved
RalfJung
reviewed
Jan 30, 2025
compiler/rustc_const_eval/src/util/validate_scalar_in_layout.rs
Outdated
Show resolved
Hide resolved
291f59b to
7ec029c
Compare
RalfJung
reviewed
Feb 2, 2025
| let typing_env = ty::TypingEnv::fully_monomorphized(); | ||
| let mut cx = InterpCx::new(tcx.tcx, tcx.span, typing_env, machine); | ||
|
|
||
| let Ok(layout) = cx.layout_of(ty) else { return false }; |
Member
There was a problem hiding this comment.
Reporting false in case of a layout computation error seems odd? This is almost certainly a bug, right?
Contributor
Author
There was a problem hiding this comment.
I could just unwrap it and we'll do it properly when we can write a test for it
Member
There was a problem hiding this comment.
That works for me.
@matthiaskrgr heads-up if you see this ICE, please ping us and thanks in advance for generating a test case. :)
Member
|
r=me with the unwrap. |
9e50c77 to
5465770
Compare
Contributor
Author
|
@bors r=RalfJung |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Feb 3, 2025
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc `@compiler-errors` `@scottmcm`
r? `@RalfJung` because of the interpreter changes
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 3, 2025
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#134777 (Enable more tests on Windows) - rust-lang#134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - rust-lang#135621 (Move some std tests to integration tests) - rust-lang#135695 (Support raw-dylib link kind on ELF) - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136392 (bootstrap: add wrapper macros for `feature = "tracing"`-gated `tracing` macros) - rust-lang#136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Feb 3, 2025
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc ``@compiler-errors`` ``@scottmcm``
r? ``@RalfJung`` because of the interpreter changes
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 3, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#134777 (Enable more tests on Windows) - rust-lang#134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - rust-lang#135621 (Move some std tests to integration tests) - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136392 (bootstrap: add wrapper macros for `feature = "tracing"`-gated `tracing` macros) - rust-lang#136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
jieyouxu
added a commit
to jieyouxu/rust
that referenced
this pull request
Feb 3, 2025
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc ```@compiler-errors``` ```@scottmcm```
r? ```@RalfJung``` because of the interpreter changes
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 3, 2025
Rollup of 8 pull requests Successful merges: - rust-lang#134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - rust-lang#134814 (Add `kl` and `widekl` target features, and the feature gate) - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - rust-lang#136022 (Port ui/simd tests to use the intrinsic macro) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136309 (set rustc dylib on manually constructed rustc command) - rust-lang#136392 (bootstrap: add wrapper macros for `feature = "tracing"`-gated `tracing` macros) - rust-lang#136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
Member
|
@bors r- |
5465770 to
0da0286
Compare
This comment has been minimized.
This comment has been minimized.
…fy their pattern
0da0286 to
ab31159
Compare
Contributor
Author
|
@bors r=RalfJung |
Collaborator
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Feb 6, 2025
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc `@compiler-errors` `@scottmcm`
r? `@RalfJung` because of the interpreter changes
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
…kingjubilee Rollup of 9 pull requests Successful merges: - rust-lang#135439 (Make `-O` mean `OptLevel::Aggressive`) - rust-lang#136193 (Implement pattern type ffi checks) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136530 (Implement `x perf` directly in bootstrap) - rust-lang#136580 (Couple of changes to run rustc in miri) - rust-lang#136589 (Enable "jump to def" feature on rustc docs) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136435 (Simplify some code for lowering THIR patterns) - rust-lang#136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
Rollup of 7 pull requests Successful merges: - rust-lang#136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136435 (Simplify some code for lowering THIR patterns) - rust-lang#136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-gnu-debug
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136435 (Simplify some code for lowering THIR patterns) - rust-lang#136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-gnu-debug
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
…kingjubilee Rollup of 9 pull requests Successful merges: - rust-lang#135439 (Make `-O` mean `OptLevel::Aggressive`) - rust-lang#136193 (Implement pattern type ffi checks) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136530 (Implement `x perf` directly in bootstrap) - rust-lang#136580 (Couple of changes to run rustc in miri) - rust-lang#136589 (Enable "jump to def" feature on rustc docs) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 6, 2025
Rollup merge of rust-lang#136235 - oli-obk:transmuty-pat-tys, r=RalfJung Pretty print pattern type values with transmute if they don't satisfy their pattern Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`. These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code. follow-up to rust-lang#136176 cc ``@compiler-errors`` ``@scottmcm`` r? ``@RalfJung`` because of the interpreter changes
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Feb 20, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - rust-lang#136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - rust-lang#136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - rust-lang#136315 (Use short ty string for binop and unop errors) - rust-lang#136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - rust-lang#136435 (Simplify some code for lowering THIR patterns) - rust-lang#136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-gnu-debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of printing
0_u32 is 1.., we now print the default fallback rendering that we also use for invalid bools, chars, ...:{transmute(0x00000000): (u32) is 1..=}.These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to #136176
cc @compiler-errors @scottmcm
r? @RalfJung because of the interpreter changes