-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-edition-2021Area: The 2021 editionArea: The 2021 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.
Description
I tried this code:
#![warn(rust_2021_prelude_collisions)]
pub struct PyAny;
pub trait PyTryFrom<'v>: Sized {
fn try_from<V>(value: V) -> Result<&'v Self, ()>;
}
pub trait PyTryInto<T>: Sized {
fn try_into(&self) -> Result<&T, ()>;
}
struct Foo;
impl<U> PyTryInto<U> for Foo
where
U: for<'v> PyTryFrom<'v>,
{
fn try_into(&self) -> Result<&U, ()> {
U::try_from(self)
}
}
This generates a suggestion to avoid the prelude collision with:
<U as PyTryFrom<_>>::try_from(self)
However, that does not compile because the generics for PyTryFrom
is a lifetime parameter which should not be specified with _
. I believe the correct suggestion would be <U as PyTryFrom>::try_from(self)
without the generic args.
Found in the 2021 crater run for:
Meta
rustc --version --verbose
:
rustc 1.56.0-nightly (ac50a5335 2021-08-27)
binary: rustc
commit-hash: ac50a53359328a5d7f2f558833e63d59d372e4f7
commit-date: 2021-08-27
host: x86_64-apple-darwin
release: 1.56.0-nightly
LLVM version: 13.0.0
Metadata
Metadata
Assignees
Labels
A-edition-2021Area: The 2021 editionArea: The 2021 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.