Reimplement ~const trait specialization#133325
Conversation
| } | ||
|
|
||
| debug!("fulfill_implication: an impl for {:?} specializes {:?}", source_trait, target_trait); | ||
| // If the parent impl is const, then the specializing impl must be const. |
There was a problem hiding this comment.
Note to self: Actually I don't know if this is correct -- well, it's not sufficient.
const trait Bar {}
impl const Bar for T {}
const trait Foo {}
impl const Foo for T where T: ~const Bar {}
// specializing impl:
impl Foo for (T,) {}
The specializing impl satisfies (T,): ~const Bar because of the blanket impl, but it's still less const than the parent impl. I think we need to check that the specializing impl is also conditionally const, and then bail.
|
@rustbot author |
d1b64f1 to
ebfd56f
Compare
|
@rustbot ready |
fee1-dead
left a comment
There was a problem hiding this comment.
not 100% confident that I can review the specialization impl, but the tests lgtm.
5dc04d8 to
e41df70
Compare
| @@ -230,23 +231,26 @@ pub(super) fn specialization_enabled_in(tcx: TyCtxt<'_>, _: LocalCrate) -> bool | |||
| /// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies | |||
There was a problem hiding this comment.
comment is outdated after your rename
There was a problem hiding this comment.
also, I feel like it's very helpful to explicitly write down "We therefore prove that the specializing impl implies the parent impl".
Because then it feels clear why we're instantiating the specializing impl with placeholders and the parent impl with existentials and prove all bounds of the parent impül
e41df70 to
9bda88b
Compare
|
@bors r=lcnr,fee1-dead |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#132723 (Unify `sysroot_target_{bin,lib}dir` handling) - rust-lang#133041 (Print name of env var in `--print=deployment-target`) - rust-lang#133325 (Reimplement `~const` trait specialization) - rust-lang#133395 (Add simd_relaxed_fma intrinsic) - rust-lang#133517 (Deeply normalize when computing implied outlives bounds) - rust-lang#133785 (Add const evaluation error UI test.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133325 - compiler-errors:const-spec, r=lcnr,fee1-dead Reimplement `~const` trait specialization Reimplement const specialization. We need this for `PartialEq` constification :) r? lcnr
Reimplement const specialization. We need this for
PartialEqconstification :)r? lcnr