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

type annotations required with -Znew-solver strsim:0.10.0 #119607

Closed
weiznich opened this issue Jan 5, 2024 · 1 comment · Fixed by #122171
Closed

type annotations required with -Znew-solver strsim:0.10.0 #119607

weiznich opened this issue Jan 5, 2024 · 1 comment · Fixed by #122171
Labels
A-traits Area: Trait system C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example WG-trait-system-refactor The Rustc Trait System Refactor Initiative

Comments

@weiznich
Copy link
Contributor

weiznich commented Jan 5, 2024

I tried this code:

cargo +nightly new test_strsim
cd test_strsim
cargo +nightly add strsim@0.10.0
RUSTFLAGS="-Znext-solver" cargo +nightly check

I expected to see this happen: Code compiles (as without the -Znew-solver flag)

Instead, this happened: Compilation failed

error[E0282]: type annotations needed
  --> /home/weiznich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strsim-0.10.0/src/lib.rs:93:13
   |
93 |     for (i, a_elem) in a.into_iter().enumerate() {
   |             ^^^^^^ cannot infer type for associated type `<<&'a Iter1 as IntoIterator>::IntoIter as Iterator>::Item`

error[E0282]: type annotations needed
   --> /home/weiznich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strsim-0.10.0/src/lib.rs:212:13
    |
212 |     for (i, a_elem) in a.into_iter().enumerate() {
    |             ^^^^^^ cannot infer type for associated type `<<&'a Iter1 as IntoIterator>::IntoIter as Iterator>::Item`

For more information about this error, try `rustc --explain E0282`.

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (f688dd684 2024-01-04)
binary: rustc
commit-hash: f688dd684faca5b31b156fac2c6e0ae81fc9bc90
commit-date: 2024-01-04
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
@weiznich weiznich added the C-bug Category: This is a bug. label Jan 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 5, 2024
@Noratrieb Noratrieb added A-traits Area: Trait system WG-trait-system-refactor The Rustc Trait System Refactor Initiative and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 5, 2024
@compiler-errors compiler-errors added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 5, 2024
@Skepfyr
Copy link
Contributor

Skepfyr commented Jan 6, 2024

This feels like it should be possible to get smaller:

pub trait IntoFoo {
    type Item;
    type IntoIter: Foo<Item = Self::Item>;

    fn into_iter(self) -> Self::IntoIter;
}

pub trait Foo {
    type Item;

    fn next(self) -> Option<Self::Item>;
}

pub fn foo<'a, Iter1, Elem1>(a: &'a Iter1)
where
    &'a Iter1: IntoFoo<Item = Elem1>,
{
    a.into_iter().next();
}

@bors bors closed this as completed in 9829ff6 Mar 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 8, 2024
Rollup merge of rust-lang#122171 - compiler-errors:next-solver-tests, r=lcnr

Add some new solver tests

Fixes rust-lang#119607
Fixes rust-lang#119608

r? lcnr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants