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

Warn when [T; N].into_iter() is ambiguous in the new edition. #88503

Merged
merged 3 commits into from Aug 31, 2021

Conversation

@m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Aug 30, 2021

Fixes #88475

In #88475, a situation was found where [T; N].into_iter() becomes ambiguous in the new edition. This is different than the case where (&[T; N]).into_iter() resolves differently, which was the only case handled by the array_into_iter lint. This is almost identical to the new-traits-in-the-prelude problem. Effectively, due to the array-into-iter hack disappearing in Rust 2021, we effectively added IntoIterator to the 'prelude' in Rust 2021 specifically for arrays.

This modifies the prelude collisions lint to detect that case and emit a array_into_iter lint in that case.

@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Aug 30, 2021

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

return;
}

let prelude_or_array_lint = if segment.ident.name == sym::into_iter {

This comment has been minimized.

@cjgillot

cjgillot Aug 30, 2021
Contributor

Can this test be merged with the previous one, for instance as a match?

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Aug 30, 2021

r=me with nit fixed.

@m-ou-se
Copy link
Member Author

@m-ou-se m-ou-se commented Aug 30, 2021

@bors r=cjgillot

@bors
Copy link
Contributor

@bors bors commented Aug 30, 2021

📌 Commit ac93ca3 has been approved by cjgillot

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 31, 2021
Rollup of 14 pull requests

Successful merges:

 - rust-lang#88394 (Document `std::env::current_exe` possible rename behaviour)
 - rust-lang#88406 (Tait nest infer test)
 - rust-lang#88408 (Add inference cycle TAIT test)
 - rust-lang#88409 (Add auto trait leakage TAIT test)
 - rust-lang#88413 (Add weird return types TAIT test)
 - rust-lang#88450 (fix(rustc_parse): correct span in `maybe_whole_expr!`)
 - rust-lang#88462 (rustdoc: Stop using resolver for macro loading)
 - rust-lang#88465 (Adding examples to docs of `std::time` module)
 - rust-lang#88486 (Remove unused arena macro args)
 - rust-lang#88492 (Use MaybeUninit::write in functor.rs)
 - rust-lang#88496 (Fix prelude collision lint suggestion for generics with lifetimes)
 - rust-lang#88497 (Fix prelude collision suggestions for glob imported traits. )
 - rust-lang#88503 (Warn when [T; N].into_iter() is ambiguous in the new edition. )
 - rust-lang#88509 (Don't suggest extra <> in dyn suggestion.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit caca256 into rust-lang:master Aug 31, 2021
10 checks passed
10 checks passed
@github-actions
PR (mingw-check, ubuntu-latest-xl)
Details
@github-actions
PR (x86_64-gnu-llvm-10, ubuntu-latest-xl)
Details
@github-actions
PR (x86_64-gnu-tools, 1, ubuntu-latest-xl)
Details
@github-actions
auto
Details
@github-actions
master
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@rustbot rustbot added this to the 1.56.0 milestone Aug 31, 2021
@m-ou-se m-ou-se added this to Completed items in 2021 Edition Blockers Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2021 Edition Blockers
  
Completed items
Linked issues

Successfully merging this pull request may close these issues.

5 participants