Repository navigation
Conversation
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
09ec27c to
95c777d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95c777df89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b449213cc2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee1c5bab6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 993d9e88fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a225022b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A written type was checked by each item, parameter, field and body site in its own way: lowering errors, then the whole type's well-formedness, which reports only the first failure at the whole span, then a second walk to point at a type inside a qualified path, a separate normalization limit check, and a `let` check that ran only without an initializer. Some sites checked no bounds at all, and a trait's associated type default was not checked: `type B = Missing` was accepted. `check_written_ty` now checks each type a written type is made of where it is written, inner types first, and a type only when nothing inside it was reported: lowering errors and invalid types, a projection past the normalization limit, and, when asked, whether its bounds hold. Every written type in a signature goes through it, including return shapes, product parameters, associated shape values and defaults, associated const types, const parameter types and a trait impl's self type, which was checked only after normalization. Items report its errors first, then their own checks, then the ill-formed parts. A body's written types are checked once by the finalizer, and a statement's expressions are not reported again for a bound reported where the statement writes a type. Diagnostics point at the innermost written type that is ill-formed, every ill-formed part is reported, and an impl's associated type definition that cannot be normalized within the limits is reported at the impl.
A projection resolved only through impls whose where clauses the solver
did not refute, so normalization proved goals and the solver normalized
them: the two recursed into each other, and an impl whose where clause
names the projection it defines was settled by salsa's cycle iteration.
Normalization now selects the impl whose header matches the
projection's trait reference and proves nothing. Where clauses only
choose between impls whose headers both match, and are solved without
normalizing through impls, so a clause that names the projection being
resolved can't recurse into it. A clause that needs an impl to resolve a
projection, in itself or in a candidate's binding, doesn't rule an impl
out, and leaves the projection unresolved.
The trait reference of a projection is checked where the projection is
written, including in a path in a body, as `<V<T> as Ty>::A { x: 1 }`,
and not again for each type it flows into. Impl where clauses are now
diagnosed like other where clauses, except that they may bound a
concrete type; an unknown trait in one was silently accepted. A where
clause on a parameter's projection, `<X as Ty>::A: Show`, requires
`X: Ty`.
Remove the fallback through path resolution's associated type search:
it found nothing the assumption and impl lookups don't.
A normalization was one fold with a cache, a cycle guard and one budget for every projection in the value, so whether a projection reached a limit depended on what else the value contained and in which order: two projections that each fit failed together. Each projection is now normalized by a tracked query keyed by the projection, the scope, the assumptions, whether impls may resolve it, and the nesting budget left. Its result is the normalized type and the projections resolved for it, so the work limit, the tree size of those projections each counted once, applies to each projection on its own and depends only on the key. The first limit reached stops a projection's resolution, so a definition that multiplies projections at each step can't run away. A definition that can't be normalized within the limits, whether through itself, as `type Out = <S as Tr>::Out`, which was left unresolved, through other impls, or through ever larger projections, is reported at the impl. A projection resolved through it is an invalid type that isn't reported again.
Four impl lookups (by self type, by trait and self type, by trait reference, and by self type with proved where clauses) each repeated the same header matching. They now share one, parameterized by what the header must match; the lookups that completed their impls still do. Method selection, associated consts and associated types each repeated the rule that a sole candidate is used wherever its trait is, but among several only those of traits in scope count. `visible_candidates` states it once; methods report the invisible traits for import, and paths keep every candidate when none is visible, as before.
The finalizer's written-type pass walked into items nested in a body and
checked their types under the enclosing function's bounds, so
`fn outer() { fn inner<T: Marker>(x: Foo<T>) {} }` reported a missing
`T: Marker`. A nested item is checked under its own bounds.
A type parameter's default was checked for errors only. Normalization picks an impl by its header without proving its where clauses, so `fn take<U = <W<u16> as Ty>::A>(_ x: U)` accepted a `u8` although `W<u16>: Ty` doesn't hold. Nothing is written where a default applies, so check its bounds where it is written, under the item's bounds.
A trait's `where Self: Bound` skipped every check of the bound, its argument types included. Normalization picks an impl by its header without proving it, so `trait Q where Self: Tr<<W<u16> as Ty>::A>` became `Self: Tr<u8>` and `impl Q for S` was accepted although `W<u16>: Ty` doesn't hold; `where Self: Gated<u16>` with `trait Gated<X: Gate>` was accepted too. Check the bound as an associated type's bound is checked: what its trait requires of `Self` falls to the implementors, and the rest must hold.
With `T: Tr<Out = <T as Tr>::Out>`, normalizing `T::Out` folded the assumption's binding, `T::Out` again, at a smaller nesting budget each time, until it reached the limit: a normalization limit error where master accepted. Mutual equalities like `A: Tr<Out = B::Out>, B: Tr<Out = A::Out>` reached it too. Before folding a binding, follow the projections the assumptions equate one to the next; if they lead back, they are one type, and the projection stays unresolved.
Normalization picked an impl by its header and refuted where clauses only to choose between several matching impls, so a lone impl whose where clauses don't hold still resolved the projection. Only checking the trait reference where a type is written kept that sound, and a written type that nothing checks, as generic defaults were, was accepted. Refute a lone impl's where clauses too, solved without impl normalization as rival impls' are: the projection stays unresolved, and its uses report a mismatch. A const parameter type reports its bound errors before its kind, which an unresolved projection never has.
A trait impl's self type was normalized only when it was a projection
itself, and an inherent impl's not at all. So
`impl Foo<<W<u32> as Ty>::A> { fn get(self) }` rejected `self` of type
`Foo<u8>`, and `impl Show for Foo<<W<u32> as Ty>::A>` didn't conflict
with `impl Show for Foo<u8>`. Normalize every projection in either
impl's self type. An inherent impl's header is checked where it is
written, as a trait impl's is, so the projection's trait reference is
still checked.
An init parameter's type was never checked where it is written: `init(a: Missing)` reported "type must be known", and `init(b: Foo<u8>)` with `struct Foo<X: Marker>` was accepted. Its size was taken from the type as written, so `init(a: <W<u32> as Ty>::A)` was "type must be known" though the projection is `u8`. Check the type as a function parameter's is checked, and size its normalized type.
A recv arm's return type was checked for errors only: its bounds were left to the body's written-type check, which doesn't see it, since the type is written outside the body. `Unbounded -> Foo<u8>` with `struct Foo<X: Marker>` reported only a mismatch with the message's return type, and `Unproved -> <W<u16> as Ty>::A` would have matched a `u8` return although `W<u16>: Ty` doesn't hold. Check its bounds where it is written; an ill-formed one isn't compared with the message's.
Each site that writes a type chose whether to check its bounds, and four were missed: generic defaults, a trait's `where Self:` bounds, contract `init` parameters and recv arm return types. Normalization picks an impl by its header without proving it, so a missed site accepted an ill-formed projection. `written_types`, the list of each item's written types that the requirement check walks, now drives the bounds check too: `written_type_bounds` checks every type an item writes outside its bodies, and the body finalizer reads the body's list instead of keeping its own. Sites report only errors, and `check_written_ty` takes no solve context. A bound's site checks what its trait requires of the arguments, whose own bounds the pass checks. A site whose later checks follow from the type asks `written_type_bounds` whether it is ill-formed. The separate check of alias arguments the alias drops is subsumed.
Refuting a rival impl's where clause treated any failed match that names a projection as undecided, which stops the search. With `U: Other<<V as Assoc>::A>` in scope, `impl<T: Never> Tr for W<T>` was never ruled out and `<W<T> as Tr>::Out` stayed unresolved. A mismatch is now undecided only if the two sides unify with each projection replaced by a fresh variable.
The bound check took each outermost written type and walked it again with the error checker, which skips parts the list includes: a trait path's arguments (`uses (e: Eff<Foo<Bad>>)`), binding values in a qualified path (`<S as Tr<A = Ignore<Foo<Bad>>>>::B`), and a `with` key with everything in it. Those went unchecked. Check each listed type instead, innermost first, as the const requirement check does, skipping a type with a failing or erroneous type in it. The error checker no longer takes a solver. A `with` key's own bounds are now checked too.
A qualified segment such as `<m::S as m::Private>` counted as invisible when its trait was, and reporting it unwrapped an identifier the segment doesn't have. Signature types and expression paths panicked on master; checking every body type made body annotations panic too. The segment names no item, so it is visible; its type and trait report their own visibility where they are written.
The helpers took a search's assumptions and whether it resolves projections through impls as two arguments. Pass them as one `TraitSolveCx`, which also has the origin ingot.
With `impl All for W<Nil>` and `impl<T: Seq> All for W<T> where W<T::Tail>: All`, the recursive impl answered `W<Nil>: All` by `W<<Nil as Seq>::Tail>: All`, though `Nil` isn't a `Seq`, and that goal by the next tail, until the table limit. The growth guard counted a projection as depth 1 whatever its arguments, so it never stopped the search. Require the trait of each projection a goal names before the where clauses of an impl that answers it, and count the nesting of a projection's arguments in the growth guard.
Normalization resolved a projection through the lone impl whose where clauses weren't refuted, and left a wrong pick to the bound check of the written type. A where clause in scope can answer that check instead:
impl Tr for W<Nil> { type Out = u8 }
impl<T: Mark> Tr for W<T> { type Out = bool }
fn h<T: Seq>(_ x: <W<T::Tail> as Tr>::Out) -> bool where W<T::Tail>: Tr { x }
`h` was checked with `Out = bool`, though `h<Cons<Nil>>` uses the other impl. Likewise `impl<T: Seq> Tr for W<T> where W<T::Tail>: Tr { type Out = <W<T::Tail> as Tr>::Out }` resolved its definition through itself up to the limit and was reported as divergent.
Solve an impl's where clauses to hold, refuted or undecided, and drop an undecided impl when an assumption answers the projection's trait. The search without impl normalization no longer stops at the first undecided candidate, tries the assumptions for a goal that names a projection, and takes a projection no impl header matches as it is.
With `impl Tr for W<Nil> { type Out = u8 }` and `impl<T: Mark> Tr for W<T> { type Out = bool }`, `<W<?T> as Tr>::Out` resolved to `bool`: the first impl was skipped because it would bind `?T`, which left the second as the only one. Once `?T` was inferred to be `Nil`, the body no longer matched its types, and the access checker reported an internal error.
Leave the projection unresolved while a candidate impl would bind an inference variable of its trait reference.
The trait of a projection a goal names was always a subgoal, whose search tries every assumption. For `M::Return: AbiSize` under `M: MsgVariant<Sol>` the subgoal is one of the assumptions, which was the case for all but 2 of the 779 in std and cost 3% of its check time. Skip those.
1a22502 to
d672da3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d672da3029
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.undecided = true; | ||
| return Ok(CallbackOutcome::Continue(assumption_clauses.collect())); |
There was a problem hiding this comment.
Keep projection-independent impls in non-normalizing searches
With a blanket impl<X> Mark for X {}, the bound <Wrap<X> as Seq>::Tail: Mark is provable without normalizing Tail, but this branch discards the blanket impl merely because the goal contains a resolvable projection. Given impl<X> Seq for Wrap<X> { type Tail = X } and impl<X> Tr for W<X> where <Wrap<X> as Seq>::Tail: Mark { type Out = u8 }, a previously valid fn f<X>(_ x: own <W<X> as Tr>::Out) -> u8 where W<X>: Tr { x } therefore stops compiling: the clause is classified as Undecided, and try_resolve_assoc_ty_from_impls removes the only Tr candidate because of the W<X>: Tr assumption, leaving Out unresolved and producing a type mismatch. Keep applicable projection-independent impls in this search rather than unconditionally limiting it to assumptions.
Useful? React with 👍 / 👎.
Follow-up to the #1794 review: written types get one checker, normalization no longer proves anything, and each projection normalizes on its own.
check_written_ty: path and lowering errors, invalid types, the normalization limit). Its bounds are checked type by type, innermost first, overwritten_types, the list of an item's written types the requirement check already walks: bywritten_type_boundsfor each item, and by the body finalizer for a body. No site checks bounds, so none can miss them: this adds bound checks where there were none (associated const types, const parameter types, generic parameter defaults, a trait'swhere Self:bounds, contractinitparameter types, recv arm return types,withkeys, a trait impl's self type, which was checked only after normalization). A bound's site checks only what its trait requires. Associated type defaults andinitparameter types are now checked at all:type B = Missingwas accepted, andinit(a: Missing)was "type must be known".<V<T> as Ty>::A { x: 1 }, and impl where clauses are now diagnosed. A where clause in scope can answer that check for any impl, so where one does, only an impl whose where clauses hold resolves the projection.impl<T: Seq> All for W<T> where W<T::Tail>: AllansweredW<Nil>: AllbyW<<Nil as Seq>::Tail>: Alland so on, until the table limit.T: Tr<Out = <T as Tr>::Out>, leave them unresolved, as before.impl Foo<<W<u32> as Ty>::A>isimpl Foo<u8>to itsselfparameters and overlap checks. Master rejected thoseselfparameters and missed thatimpl Show for Foo<<W<u32> as Ty>::A>overlapsimpl Show for Foo<u8>.visible_candidatesrule.Behavior changes:
<X as Ty>::A: Showon a parameter requiresX: Ty.impl Tr for S { type Out = <S as Tr>::Out }and mutually defined associated types are errors at the impl, where they were left unresolved. So is one defined through itself in a trait argument,type Out = <u8 as Conv<<A as Tr>::Out>>::Y, which resolved when the impl ignored that argument.impl Tr for W<u8>,impl<T: Foo> Tr for W<T> where <T as Foo>::X: Barleaves<W<u8> as Tr>::Outunresolved.impl<T> Tr for W<T> where <Wrap<T> as Seq>::Tail: Mark,<W<T> as Tr>::Outstays unresolved infn h<T: Mark>(..) where W<T>: Tr. With a secondimpl Tr for W<Nil>, master rejects the same body.W<Cons<Nil>>: Allabove, is checked; master hangs.letwith an initializer reports a bound error at its written type.<m::S as m::Private>::Item, is reported where it is written; master panicked.The branch's earlier backstop for a normalization limit reached only inside the trait solver is left out: it collected limits with a salsa accumulator, and accumulators are off since the salsa 0.28 upgrade. The case it covered is now rejected by the instantiation limit (16-0016).