Skip to content

Check FromIterator trait impl in prelude collision check. #86904

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

Merged
merged 5 commits into from
Jul 9, 2021

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Jul 6, 2021

Fixes #86902.

@m-ou-se m-ou-se added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-edition Diagnostics: An error or lint that should account for edition differences. A-edition-2021 Area: The 2021 edition labels Jul 6, 2021
@rust-highfive
Copy link
Contributor

r? @jackh726

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2021
@m-ou-se m-ou-se marked this pull request as ready for review July 6, 2021 13:55
@m-ou-se
Copy link
Member Author

m-ou-se commented Jul 6, 2021

Oh, looks like this actually explodes if the type is generic. :(

@m-ou-se m-ou-se marked this pull request as draft July 6, 2021 13:57
@m-ou-se
Copy link
Member Author

m-ou-se commented Jul 6, 2021

struct X<T>(T);

trait Hey {
    fn from_iter(_: i32) -> Self;
}

impl Hey for X<i32> {
    fn from_iter(x: i32) -> Self {
        X(x)
    }
}

fn main() {
    X::from_iter(1);
}

It works for X::<i32>::from_iter(1). But it doesn't like X::from_iter(1):

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/mara/.cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

I'm guessing I need to fill something in for the T of X.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 7, 2021

☔ The latest upstream changes (presumably #86920) made this pull request unmergeable. Please resolve the merge conflicts.

@m-ou-se m-ou-se force-pushed the prelude-collision-check-trait branch from c3903c9 to 10d6b34 Compare July 7, 2021 13:27
@m-ou-se
Copy link
Member Author

m-ou-se commented Jul 7, 2021

Updated! Let's see if it works now.. :)

Also found a bug in the suggestion for Z::from_iter() when Z is generic. Filing an issue for that. (Edit: #86940)

@m-ou-se m-ou-se marked this pull request as ready for review July 7, 2021 14:46
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one nit

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 8, 2021

📌 Commit 2083207 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2021
@bors
Copy link
Collaborator

bors commented Jul 9, 2021

⌛ Testing commit 2083207 with merge 95fb131...

@bors
Copy link
Collaborator

bors commented Jul 9, 2021

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 95fb131 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2021
@bors bors merged commit 95fb131 into rust-lang:master Jul 9, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 9, 2021
@m-ou-se m-ou-se deleted the prelude-collision-check-trait branch July 12, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2021 Area: The 2021 edition D-edition Diagnostics: An error or lint that should account for edition differences. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2021 prelude migration lint: Check if trait is actually implemented
8 participants