Add a fully fledged Clause type, rename old Clause to ClauseKind - #112772
Conversation
|
Some changes occurred in cc @BoxyUwU Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
There was a problem hiding this comment.
this assert is perf critical? and assuming that it is, would it not be faster to make this an assert and make using the clause use unreachable_unchecked?
There was a problem hiding this comment.
I don't think it's perf critical, just seems redundant since we already assert that it's a Clause in Clause::kind.
There was a problem hiding this comment.
Anyways I made it an assert, and we can make it unreachable_unchecked on the read path if perf warrants it later.
There was a problem hiding this comment.
What's your opinion on reexporting the ClauseKind variants from a clause module and using clause::Trait instead?
There was a problem hiding this comment.
Eh, doesn't really seem worthwhile tbh. Or at least, I think I want to do it as a follow-up 😸
|
☔ The latest upstream changes (presumably #112351) made this pull request unmergeable. Please resolve the merge conflicts. |
3f05556 to
2395086
Compare
2395086 to
dcee3ab
Compare
|
@bors r=lcnr |
Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of
ty::Predicatetoty::Clause(predicates_of/item_bounds/ParamEnv::caller_bounds).ClausetoClauseKind, so it's parallel withPredicateKind.Clausetype which is parallel toPredicate.Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>which is parallel toPredicate::kind😸The new
Clausetype essentially acts as a newtype wrapper aroundPredicatethat asserts that it is specifically aPredicateKind::Clause. Turns out from experimentation1 that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...r? @lcnr or @oli-obk
Footnotes
https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910 ↩