Skip to content

Don't emit two assumes in transmutes when one is a subset of the other - #144209

Merged
bors merged 1 commit into
rust-lang:masterfrom
scottmcm:assume_less
Jul 25, 2025
Merged

Don't emit two assumes in transmutes when one is a subset of the other#144209
bors merged 1 commit into
rust-lang:masterfrom
scottmcm:assume_less

Conversation

@scottmcm

Copy link
Copy Markdown
Member

For example, transmuting between bool and Ordering doesn't need two assumes because one range is a superset of the other.

Multiple are still used for things like char <-> NonZero<u32>, which overlap but where neither fully contains the other.

@rustbot

Copy link
Copy Markdown
Collaborator

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 20, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@oli-obk

Copy link
Copy Markdown
Contributor

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

rust-borsBot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

⌛ Trying commit dd170e8 with merge 4e27cc3

To cancel the try build, run the command @bors2 try cancel.

rust-borsBot added a commit that referenced this pull request Jul 20, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2025
@rust-bors

rust-borsBot commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4e27cc3 (4e27cc328172a524edb4dd605053867dc92cddfa, parent: 81af9d45698a19183b8552079cbc7bf893fad1e5)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4e27cc3): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -2.9%, secondary 4.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
4.6%[4.6%, 4.6%]1
Improvements ✅
(primary)
-2.9%[-3.1%, -2.7%]2
Improvements ✅
(secondary)
--0
All ❌✅ (primary)-2.9%[-3.1%, -2.7%]2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 465.3s -> 465.355s (0.01%)
Artifact size: 374.58 MiB -> 374.59 MiB (0.00%)

@rustbotrustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2025

@lcnrlcnr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me

I haven't looked at the test annotations in detail and don't feel 100% comfortable approving these. The code changes make sense the tests seem about right from what I can tell 😅 😁

@scottmcm

Copy link
Copy Markdown
MemberAuthor

@dianqk Perhaps you could double-check that the test updates here seem reasonable to you?

(This PR is not urgent; don't feel pressured to get to it promptly.)

@dianqkdianqk self-assigned this Jul 22, 2025
@bors

bors commented Jul 22, 2025

Copy link
Copy Markdown
Collaborator

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

@dianqkdianqk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me also after a nit.

(This PR is not urgent; don't feel pressured to get to it promptly.)

Never mind, I never felt that. I was just giving an estimated time.

Comment threadcompiler/rustc_abi/src/lib.rs Outdated
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
@scottmcm

Copy link
Copy Markdown
MemberAuthor

@bors r=lcnr,dianqk rollup=maybe (no perf changes in the report, so don't think it needs the separate run)

@bors

bors commented Jul 23, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit a93a9aa has been approved by lcnr,dianqk

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2025
fmease added a commit to fmease/rust that referenced this pull request Jul 24, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
@fmeasefmease mentioned this pull request Jul 24, 2025
bors added a commit that referenced this pull request Jul 24, 2025
Rollup of 16 pull requests
Successful merges:
- #142569 (Suggest clone in user-write-code instead of inside macro)
- #143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- #143424 (clippy fix: rely on autoderef)
- #143970 (Update core::mem::copy documentation)
- #143979 (Test fixes for Arm64EC Windows)
- #144160 (tests: debuginfo: Work around or disable broken tests on powerpc)
- #144200 (Tweak output for non-`Clone` values moved into closures)
- #144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- #144225 (Don't special-case llvm.* as nounwind)
- #144314 (Hint that choose_pivot returns index in bounds)
- #144316 (bootstrap: Move musl-root fallback out of sanity check)
- #144364 (Update `dlmalloc` dependency of libstd)
- #144368 (resolve: Remove `Scope::CrateRoot`)
- #144373 (remove deprecated Error::description in impls)
- #144390 (Remove dead code and extend test coverage and diagnostics around it)
- #144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
fmease added a commit to fmease/rust that referenced this pull request Jul 25, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
@fmeasefmease mentioned this pull request Jul 25, 2025
bors added a commit that referenced this pull request Jul 25, 2025
Rollup of 17 pull requests
Successful merges:
- #142569 (Suggest clone in user-write-code instead of inside macro)
- #143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- #143424 (clippy fix: rely on autoderef)
- #143970 (Update core::mem::copy documentation)
- #143979 (Test fixes for Arm64EC Windows)
- #144160 (tests: debuginfo: Work around or disable broken tests on powerpc)
- #144200 (Tweak output for non-`Clone` values moved into closures)
- #144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- #144225 (Don't special-case llvm.* as nounwind)
- #144314 (Hint that choose_pivot returns index in bounds)
- #144316 (bootstrap: Move musl-root fallback out of sanity check)
- #144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- #144364 (Update `dlmalloc` dependency of libstd)
- #144368 (resolve: Remove `Scope::CrateRoot`)
- #144390 (Remove dead code and extend test coverage and diagnostics around it)
- #144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
- #144424 (Allow setting `release-blog-post` label with rustbot)
r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 25, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
This was referenced Jul 25, 2025
bors added a commit that referenced this pull request Jul 25, 2025
Rollup of 16 pull requests
Successful merges:
- #142569 (Suggest clone in user-write-code instead of inside macro)
- #143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- #143424 (clippy fix: rely on autoderef)
- #143970 (Update core::mem::copy documentation)
- #143979 (Test fixes for Arm64EC Windows)
- #144160 (tests: debuginfo: Work around or disable broken tests on powerpc)
- #144200 (Tweak output for non-`Clone` values moved into closures)
- #144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- #144314 (Hint that choose_pivot returns index in bounds)
- #144316 (bootstrap: Move musl-root fallback out of sanity check)
- #144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- #144364 (Update `dlmalloc` dependency of libstd)
- #144368 (resolve: Remove `Scope::CrateRoot`)
- #144390 (Remove dead code and extend test coverage and diagnostics around it)
- #144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
- #144424 (Allow setting `release-blog-post` label with rustbot)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 25, 2025
Rollup of 12 pull requests
Successful merges:
- #142569 (Suggest clone in user-write-code instead of inside macro)
- #143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- #143424 (clippy fix: rely on autoderef)
- #143970 (Update core::mem::copy documentation)
- #143979 (Test fixes for Arm64EC Windows)
- #144200 (Tweak output for non-`Clone` values moved into closures)
- #144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- #144314 (Hint that choose_pivot returns index in bounds)
- #144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- #144368 (resolve: Remove `Scope::CrateRoot`)
- #144390 (Remove dead code and extend test coverage and diagnostics around it)
- #144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit f414e7a into rust-lang:masterJul 25, 2025
11 checks passed
@rustbotrustbot added this to the 1.90.0 milestone Jul 25, 2025
rust-timer added a commit that referenced this pull request Jul 25, 2025
Rollup merge of #144209 - scottmcm:assume_less, r=lcnr,dianqk
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
@scottmcm
scottmcm deleted the assume_less branch July 25, 2025 16:22
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 28, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Jul 28, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
rust-cloud-vmsBot pushed a commit to makai410/rustc_public that referenced this pull request Aug 16, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
rust-cloud-vmsBot pushed a commit to makai410/rustc_public that referenced this pull request Aug 20, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 8, 2025
…iaskrgr
Rollup of 12 pull requests
Successful merges:
- rust-lang#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang#143424 (clippy fix: rely on autoderef)
- rust-lang#143970 (Update core::mem::copy documentation)
- rust-lang#143979 (Test fixes for Arm64EC Windows)
- rust-lang#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
makai410 pushed a commit to makai410/rust that referenced this pull request Nov 10, 2025
…iaskrgr
Rollup of 12 pull requests
Successful merges:
- rust-lang#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang#143424 (clippy fix: rely on autoderef)
- rust-lang#143970 (Update core::mem::copy documentation)
- rust-lang#143979 (Test fixes for Arm64EC Windows)
- rust-lang#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Nov 16, 2025
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
makai410 pushed a commit to makai410/rustc_public that referenced this pull request Mar 27, 2026
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.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.

7 participants

@scottmcm@rustbot@oli-obk@rust-timer@bors@dianqk@lcnr