Add a fully fledged Clause type, rename old Clause to ClauseKind#112772
Add a fully fledged Clause type, rename old Clause to ClauseKind#112772bors merged 3 commits intorust-lang:masterfrom
Clause type, rename old Clause to ClauseKind#112772Conversation
|
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 |
compiler/rustc_middle/src/ty/mod.rs
Outdated
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 |
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of rust-lang#112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] 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` [^1]: rust-lang#112714 (comment)
Rollup of 6 pull requests Successful merges: - rust-lang#112632 (Implement PartialOrd for `Vec`s over different allocators) - rust-lang#112759 (Make closure_saved_names_of_captured_variables a query. ) - rust-lang#112772 (Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`) - rust-lang#112790 (Syntactically accept `become` expressions (explicit tail calls experiment)) - rust-lang#112830 (More codegen cleanups) - rust-lang#112844 (Add retag in MIR transform: `Adt` for `Unique` may contain a reference) r? `@ghost` `@rustbot` modify labels: rollup
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of rust-lang#112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] 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`` [^1]: rust-lang#112714 (comment)
Rollup of 6 pull requests Successful merges: - rust-lang#112632 (Implement PartialOrd for `Vec`s over different allocators) - rust-lang#112759 (Make closure_saved_names_of_captured_variables a query. ) - rust-lang#112772 (Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`) - rust-lang#112790 (Syntactically accept `become` expressions (explicit tail calls experiment)) - rust-lang#112830 (More codegen cleanups) - rust-lang#112844 (Add retag in MIR transform: `Adt` for `Unique` may contain a reference) r? `@ghost` `@rustbot` modify labels: rollup
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 ↩