Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #17498
The above issue is due to formatting self referencing, recursive bound like
Implemented(^0.0: TraitId(0)<[?0 := ^0.0]>)
on the codes like;When lowering predicate
impl Foo<impl Bar>
intrait_environment_query
, the outerimpl Foo<...>
is treated as predicates, so the firstTypeRef
that passes the following code isimpl Bar
;rust-analyzer/crates/hir-ty/src/lower.rs
Lines 376 to 400 in cae997e
and thus the
idx
is0
in the above context.But the following code sets
self_ty
as theBoundVar
withidx = 0
because the target param id for predicateimpl Foo<...>
is0
sinceimpl Foo
is the first generic-like parameter offn test
;rust-analyzer/crates/hir-ty/src/lower.rs
Lines 998 to 1025 in cae997e
For the codes like;
similar recursive bound doesn't happen because the following codes "count the number of
impl Trait
things that appear before the target of ourbound
."rust-analyzer/crates/hir-ty/src/lower.rs
Lines 1168 to 1199 in cae997e
Instead of doing similar thing like nested
impl Foo<impl Bar>
thing, this PR lowers such nested impl traits into error types in the similar manner as the rustc does in the following lines (and of course, allows lowering and inferencing nested impl traits for the cases that rustc permits);(Though rustc emits E0666😈, I skipped diagnostics since gathering diagnostics in
hir-def
has no conventions so far 😅)