Skip to content

Confusion about future_prelude_collision #86633

Closed
@ehuss

Description

@ehuss

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-edition-2021Area: The 2021 editionC-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions