Repository navigation
Conversation
ea7e4a9 to
346ed36
Compare
| let mut global_explicit_clauses = GlobalExplicitOutlivesClauses::default(); | ||
| let mut global_inferred_clauses = GlobalOutlivesClauses::default(); | ||
|
|
||
| let mut explicit_map = ExplicitClausesMap::new(); | ||
|
|
||
| let mut global_inferred_outlives = FxIndexMap::default(); |
There was a problem hiding this comment.
These are "global" ... relative to the local crate. They're mappings from items in the local crate to a set of clauses. The adjective is mainly meant to contrast with clauses belonging to the item that's currently being processed.
Not a great adjective, I'm open to naming suggestions.
The outdated comments seem to imply that once upon a time this code ran over the entire crate graph, so that might be where the name comes from.
Edit: And then there's also is_global as in HAS_FREE_LOCAL_NAMES so that might be confusing, too.
This comment has been minimized.
This comment has been minimized.
346ed36 to
c42c657
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
In summary, rename various things & update a lot of comments.
1. Rename some types, fns that have "clause" in their name to contain
"outlives clause" instead. While we are in a module called `outlives`,
it's not immediately obvious & it certainly doesn't imply that all of
these things only represent / act on outlives-clauses.
Requested by Boxy.
2. Both `global_inferred_outlives` and `explicit_map` store a "global"
mapping from each crate-local item to a set of outlives-clauses
collected so far (one containing the inferred ones, the other the
explicit ones). So name both consistently: `global_inferred_clauses`
and `global_explicit_clauses`, respectively.
Similarly for their types which are now prefixed with `Global`.
3. Remove a bunch of really obvious & distracting comments.
4. Reduce rightward drift in the `ty::Dynamic` match arm by using an
if-let guard.
5. Deduplicate code shared between ADTs & CTAs in `inferred_outlives_of`
6. `bug!()` in a `GenericArgKind::Const(_)` branch which we know is
currently unreachable and which should explode if that were to change.
7. Rename `CrateClausesMap` to `CrateInferredOutlivesClausesMap`.
The type is public & lives in `rustc_middle` since
`inferred_outlives_crate` is a query. Considering that, its name is
way too general.
Moreover, remove all of its docs. This type can only be constructed
via query `inferred_outlives_crate` (well, and via the provider) which
has good docs already that also warn about the fact that query
`inferred_outlives_of` should always be used instead.
8. Remove comment "Typically there won't be many of these [explicit
outlives clauses], except in older code where they were mandatory" is
unnecessary and factually incorrect since there are various places
where we don't imply (early-bound) outlives-bounds.
9. Re. comment "Visit all the crates [...]" and "[...] we walk the crates
again [...]" is no longer correct: We only (re)visit the items in the
local crate; the inferred outlives clauses for cross-crate items have
already been computed and stored in the relevant crate metadata files.
10. Fix the example given in `check_explicit_clauses`'s docs, it has
several issues: Struct `Outer` gets used as a trait bound, it uses
`...: 'static` bounds and states they get processed but as a matter
of fact we don't process static bounds, we specifically only infer
clauses where the LHS is early-bound!
11. Various minor code tweaks.
Split out of PR #143029.
In summary, this renames various things, updates a lot of outdated or otherwise incorrect comments and does some other minor code clean ups. Please consult the commit message for further details. Ignoring whitespace might help when reviewing the diff.
r? BoxyUwU or compiler
(No LLM was or will be used by me during the entire creation process of this PR)