Skip to content

Conversation

compiler-errors
Copy link
Member

Let's save some space in the design of const traits by making dyn Trait where trait Trait: const Super not dyn compatible.

Such a trait cannot satisfy dyn Trait: Trait; we could in the future make this dyn compatible but NOT implement Trait, but that's a bit weird and seems like it needs to be independently justified moving forward.

Fixes #145198

r? fee1-dead

@rustbot rustbot 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 Aug 19, 2025
@compiler-errors compiler-errors force-pushed the const-supertrait-dyn-compat branch from d367474 to a65a29d Compare August 19, 2025 20:43
Comment on lines 271 to 273
if !tcx.features().const_trait_impl() {
return SmallVec::new();
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems wrong? If I am a downstream crate that attempts to use a trait upstream that has : const Tr, then I should see that the trait isn't dyn compatible no matter whether I enable const_trait_impl.

I checked the callers of this and it looks like it's not limited to just local items.

Copy link
Member Author

@compiler-errors compiler-errors Aug 20, 2025

Choose a reason for hiding this comment

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

Yeah, I kinda don't care about crate composability when it comes to nightly features, but I think it's fine to just remove this check and always run it. There isn't much of an overhead.

@rustbot rustbot 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 Aug 20, 2025
@compiler-errors compiler-errors force-pushed the const-supertrait-dyn-compat branch from a65a29d to e57e5f0 Compare August 20, 2025 15:47
@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 20, 2025
…r=<try>

Unconditionally-const supertraits are considered not dyn compatible
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 20, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 20, 2025

☀️ Try build successful (CI)
Build commit: 1d5de18 (1d5de1838cfad930bfe6fbdeaed6a5b875938a5b, parent: e8a792daf500b5ff8097896ddb6cc037abe92487)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1d5de18): 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 1.6%, secondary -2.4%)

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

mean range count
Regressions ❌
(primary)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 1.6% [1.6%, 1.6%] 1

Cycles

Results (secondary 3.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [2.9%, 3.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 471.66s -> 471.441s (-0.05%)
Artifact size: 378.20 MiB -> 378.13 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 20, 2025
@fee1-dead
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 21, 2025

📌 Commit e57e5f0 has been approved by fee1-dead

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 21, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 21, 2025
…yn-compat, r=fee1-dead

Unconditionally-const supertraits are considered not dyn compatible

Let's save some space in the design of const traits by making `dyn Trait` where `trait Trait: const Super` not dyn compatible.

Such a trait cannot satisfy `dyn Trait: Trait`; we could in the future make this dyn compatible but *NOT* implement `Trait`, but that's a bit weird and seems like it needs to be independently justified moving forward.

Fixes rust-lang#145198

r? fee1-dead
bors added a commit that referenced this pull request Aug 21, 2025
Rollup of 19 pull requests

Successful merges:

 - #143383 (stabilize `const_array_each_ref`)
 - #144758 ([Doc] Add links to the various collections)
 - #144915 (Defer tail call ret ty equality to check_tail_calls)
 - #145256 (Add new `--test-codegen-backend` bootstrap option)
 - #145297 (fix(debuginfo): handle false positives in overflow check)
 - #145390 (Shorten some dependency chains in the compiler)
 - #145415 (std_detect: RISC-V: implement implication to "C")
 - #145525 (stdlib: Replace typedef -> type alias in doc comment)
 - #145590 (Prevent impossible combinations in `ast::ModKind`.)
 - #145593 (UnsafePinned::raw_get: sync signature with get)
 - #145621 (Fix some doc typos)
 - #145627 (Unconditionally-const supertraits are considered not dyn compatible)
 - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause)
 - #145650 (Fix JS search scripts path)
 - #145654 (Download CI GCC into the correct directory)
 - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions)
 - #145673 (Add flock support for cygwin)
 - #145674 (Enable triagebot `[review-changes-since]` feature)
 - #145678 (Fix typo in docstring)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 64c43ed into rust-lang:master Aug 21, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 21, 2025
rust-timer added a commit that referenced this pull request Aug 21, 2025
Rollup merge of #145627 - compiler-errors:const-supertrait-dyn-compat, r=fee1-dead

Unconditionally-const supertraits are considered not dyn compatible

Let's save some space in the design of const traits by making `dyn Trait` where `trait Trait: const Super` not dyn compatible.

Such a trait cannot satisfy `dyn Trait: Trait`; we could in the future make this dyn compatible but *NOT* implement `Trait`, but that's a bit weird and seems like it needs to be independently justified moving forward.

Fixes #145198

r? fee1-dead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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.

trait Sub: const Super has unusable dyn
5 participants