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

Confusion about future_prelude_collision #86633

Closed
ehuss opened this issue Jun 25, 2021 · 4 comments · Fixed by #86657
Closed

Confusion about future_prelude_collision #86633

ehuss opened this issue Jun 25, 2021 · 4 comments · Fixed by #86657
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jun 25, 2021

I tried this code:

#![allow(unused)]
#![warn(future_prelude_collision)]

struct S;

impl S {
    fn try_into(self) -> S { S }
}

fn main() {
    let s = S;
    let s2 = s.try_into();
}

I expected to see this happen: No warning

Instead, this happened: Got the warning:

warning: trait method `try_into` will become ambiguous in Rust 2021
  --> src/main.rs:12:14
   |
12 |     let s2 = s.try_into();
   |              ^ help: disambiguate the method call: `(s)`
   |
note: the lint level is defined here
  --> src/main.rs:2:9
   |
2  | #![warn(future_prelude_collision)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
   = note: for more information, see issue #85684 <https://github.com/rust-lang/rust/issues/85684>

AFAIK, this should not be ambiguous, since it is an inherent method, which should take priority over the TryInto trait. Also, the suggestion doesn't make much sense, since it just surrounds the variable with parenthesis, which have no effect (and indeed, can be removed even on 2021).

Meta

rustc 1.55.0-nightly (7c3872e6b 2021-06-24)

cc @m-ou-se

@ehuss ehuss added the C-bug Category: This is a bug. label Jun 25, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Jun 25, 2021

cc @jam1garner

@jam1garner
Copy link
Contributor

I'll look into it, in some cases inherent methods do collide but this is definitely a false positive, might just be checking the number of derefs.

@jam1garner
Copy link
Contributor

@rustbot claim

@inquisitivecrystal
Copy link
Contributor

inquisitivecrystal commented Jun 25, 2021

@rustbot label +A-diagnostics +A-edition-2021 +D-incorrect +T-compiler

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2021 Area: The 2021 edition T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Jun 25, 2021
@bors bors closed this as completed in 5028581 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants