Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested projection normalization results in ambiguity #13

Closed
compiler-errors opened this issue Mar 29, 2023 · 6 comments
Closed

Nested projection normalization results in ambiguity #13

compiler-errors opened this issue Mar 29, 2023 · 6 comments
Labels
fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level needs-further-investigation Needs to be root-caused

Comments

@compiler-errors
Copy link
Owner

fn needs_iter(_: impl Iterator<Item = i32>) {}

fn main() {
    needs_iter(IntoIterator::into_iter([0i32; 32]))
}
error[E0284]: type annotations needed: cannot satisfy `<<[i32; 32] as IntoIterator>::IntoIter as Iterator>::Item == i32`
 --> <source>:4:16
  |
4 |     needs_iter(IntoIterator::into_iter([0i32; 32]))
  |     ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<<[i32; 32] as IntoIterator>::IntoIter as Iterator>::Item == i32`
  |     |
  |     required by a bound introduced by this call
  |
note: required by a bound in `needs_iter`
 --> <source>:1:32
  |
1 | fn needs_iter(_: impl Iterator<Item = i32>) {}
  |                                ^^^^^^^^^^ required by this bound in `needs_iter`

This may be due to us assembling two candidates -- one via the alias bound for IntoIter and one via the normalized self type <[i32; 32] as IntoIterator>::IntoIter which is std::array::IntoIter<i32, 32>...

I'm surprised we're not combining these because they should have the same constraints -- none at all.

@compiler-errors compiler-errors added needs-further-investigation Needs to be root-caused fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level labels Mar 29, 2023
@compiler-errors
Copy link
Owner Author

compiler-errors commented Mar 29, 2023

Marking this as a "fundamental" issue because we're going to have to hack around it at the solver level, possibly by not preferring alias bounds over impl bounds (or perhaps getting rid of alias bounds altogether)

@lcnr
Copy link

lcnr commented Mar 30, 2023

I'm surprised we're not combining these because they should have the same constraints -- none at all.

i don't think we combine candidates yet until rust-lang/rust#109724 so i think at least this specific case should be fixed with that?

@compiler-errors
Copy link
Owner Author

oh you're right, duh. well glad it's fixed by that.

@compiler-errors
Copy link
Owner Author

@lcnr this doesn't seem to be fixed by your pr

@lcnr
Copy link

lcnr commented Apr 12, 2023

inside of the normalizes-to rhs infer hack:

  Candidate { source: Impl(DefId(2:3663 ~ core[523c]::array::iter::{impl#2})), result: Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [i32] }, external_constraints: ExternalConstraints(Interned(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }, PrivateZst)) }, max_universe: U0, variables: [] } },
  Candidate { source: AliasBound, result: Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [<[i32; 32] as std::iter::IntoIterator>::Item] }, external_constraints: ExternalConstraints(Interned(ExternalConstraintsData { region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, opaque_types: [] }, PrivateZst)) }, max_universe: U0, variables: [] } }]

normalizing to either i32 or <[i32; 32] as std::iter::IntoIterator>::Item 😅 have a few different ideas here, can chat about them in sync 😁

@compiler-errors
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level needs-further-investigation Needs to be root-caused
Projects
None yet
Development

No branches or pull requests

2 participants