-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tracking issue for future-incompatbility lint ambiguous_associated_items
#57644
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-future-incompatibility
Category: Future-incompatibility lints
C-tracking-issue
Category: An issue tracking the progress of sth. like the implementation of an RFC
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Comments
This was referenced Apr 30, 2019
kennytm
added a commit
to kennytm/rust
that referenced
this issue
May 2, 2019
Make deprecation lint `ambiguous_associated_items` deny-by-default As requested by r? @Centril cc rust-lang#57644
Centril
added a commit
to Centril/rust
that referenced
this issue
May 2, 2019
Make deprecation lint `ambiguous_associated_items` deny-by-default As requested by r? @Centril cc rust-lang#57644
Centril
added a commit
to Centril/rust
that referenced
this issue
May 3, 2019
Make deprecation lint `ambiguous_associated_items` deny-by-default As requested by r? @Centril cc rust-lang#57644
illicitonion
pushed a commit
to illicitonion/num_enum
that referenced
this issue
Jun 30, 2019
Hello, my enum looks like that: ```rust #[derive(IntoPrimitive, TryFromPrimitive, Copy, Clone, PartialEq, Debug)] #[repr(u8)] pub enum BasicTokenNoPrefix { EndOfTokenisedLine = 0, StatementSeparator = 1, [...] Error, [...] } ``` and I obtain this compilation error when using it: ``` error: ambiguous associated item --> src/basic/tokens.rs:7:10 | 7 | #[derive(IntoPrimitive, TryFromPrimitive, Copy, Clone, PartialEq, Debug)] | ^^^^^^^^^^^^^^^^ | = note: #[deny(ambiguous_associated_items)] on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644> note: `Error` could refer to variant defined here --> src/basic/tokens.rs:145:5 | 14| Error, | ^^^^^ note: `Error` could also refer to associated type defined here ``` This patch allows to fix this issue.
How is a variant present in type namespace? Syntactically only type is possible in that position, a function can't return a variant of an enum. |
tylerwhall
added a commit
to tylerwhall/strum
that referenced
this issue
Nov 18, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
tylerwhall
added a commit
to tylerwhall/strum
that referenced
this issue
Nov 18, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
tylerwhall
added a commit
to tylerwhall/strum
that referenced
this issue
Nov 18, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust #[derive(EnumString)] pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
tylerwhall
added a commit
to tylerwhall/strum
that referenced
this issue
Nov 18, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust #[derive(EnumString)] pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
tylerwhall
added a commit
to tylerwhall/strum
that referenced
this issue
Nov 19, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
Peternator7
pushed a commit
to Peternator7/strum
that referenced
this issue
Nov 19, 2021
The addition of TryFrom<&str> for EnumString breaks for enums that have a variant called "Error". Rewrite as <Self as Trait> where associated types are used as the return type for trait functions. Example: ```rust pub enum Test { Error, } ``` error: ambiguous associated item --> src/lib.rs:3:10 | 3 | #[derive(EnumString)] | ^^^^^^^^^^ | = note: `#[deny(ambiguous_associated_items)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644>
hunts
pushed a commit
to hunts/capnproto-rust
that referenced
this issue
Jan 30, 2023
This was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! See also: rust-lang/rust#57644
hunts
added a commit
to hunts/capnproto-rust
that referenced
this issue
Jan 30, 2023
This was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! See also: rust-lang/rust#57644
hunts
added a commit
to hunts/capnproto-rust
that referenced
this issue
Jan 30, 2023
This was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! See also: rust-lang/rust#57644
hunts
added a commit
to hunts/capnproto-rust
that referenced
this issue
Jan 30, 2023
This was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! See also: rust-lang/rust#57644
caspermeijn
added a commit
to caspermeijn/prost
that referenced
this issue
Jul 9, 2024
The generated code uses `Self::Error` to refer to `::prost::UnknownEnumValue`, but the term `Error` is not unique when an enum variant is called `Error`. Use the full type name to resolve the ambiguity. The compiler reported: ``` error: ambiguous associated item --> /home/ircdev/src/prost/target/debug/build/tests-no-std-e27db7197924752f/out/enum_keyword_variant.rs:2:68 | 2 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] | ^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644> note: `Error` could refer to the variant defined here --> /home/ircdev/src/prost/target/debug/build/tests-no-std-e27db7197924752f/out/enum_keyword_variant.rs:10:5 | 10 | Error = 4, | ^^^^^ note: `Error` could also refer to the associated type defined here --> /home/ircdev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:682:5 | 682 | type Error; | ^^^^^^^^^^ = note: `#[deny(ambiguous_associated_items)]` on by default = note: this error originates in the derive macro `::prost::Enumeration` (in Nightly builds, run with -Z macro-backtrace for more info) ```
github-merge-queue bot
pushed a commit
to tokio-rs/prost
that referenced
this issue
Jul 9, 2024
The generated code uses `Self::Error` to refer to `::prost::UnknownEnumValue`, but the term `Error` is not unique when an enum variant is called `Error`. Use the full type name to resolve the ambiguity. The compiler reported: ``` error: ambiguous associated item --> /home/ircdev/src/prost/target/debug/build/tests-no-std-e27db7197924752f/out/enum_keyword_variant.rs:2:68 | 2 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] | ^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57644 <rust-lang/rust#57644> note: `Error` could refer to the variant defined here --> /home/ircdev/src/prost/target/debug/build/tests-no-std-e27db7197924752f/out/enum_keyword_variant.rs:10:5 | 10 | Error = 4, | ^^^^^ note: `Error` could also refer to the associated type defined here --> /home/ircdev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:682:5 | 682 | type Error; | ^^^^^^^^^^ = note: `#[deny(ambiguous_associated_items)]` on by default = note: this error originates in the derive macro `::prost::Enumeration` (in Nightly builds, run with -Z macro-backtrace for more info) ```
ambiguous_associated_items
compatibility lintambiguous_associated_items
LilyFoote
added a commit
to PyO3/pyo3
that referenced
this issue
Nov 21, 2024
This uses the fix described in rust-lang/rust#57644
LilyFoote
added a commit
to PyO3/pyo3
that referenced
this issue
Nov 22, 2024
This uses the fix described in rust-lang/rust#57644
LilyFoote
added a commit
to PyO3/pyo3
that referenced
this issue
Nov 22, 2024
This uses the fix described in rust-lang/rust#57644
LilyFoote
added a commit
to PyO3/pyo3
that referenced
this issue
Nov 23, 2024
This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
LilyFoote
added a commit
to PyO3/pyo3
that referenced
this issue
Nov 23, 2024
This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
github-merge-queue bot
pushed a commit
to PyO3/pyo3
that referenced
this issue
Nov 23, 2024
* Add test for ambiguous associated item The `#[pyclass]` macro implements `IntoPyObject` for the annotated enum. When the enum has any of `Error`, `Output` or `Target` as members, this clashes with the associated types of `IntoPyObject`. This also happens when deriving `IntoPyObject` directly. * Fix #4723: ambiguous associated item in #[pyclass] This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
davidhewitt
pushed a commit
to PyO3/pyo3
that referenced
this issue
Nov 25, 2024
* Add test for ambiguous associated item The `#[pyclass]` macro implements `IntoPyObject` for the annotated enum. When the enum has any of `Error`, `Output` or `Target` as members, this clashes with the associated types of `IntoPyObject`. This also happens when deriving `IntoPyObject` directly. * Fix #4723: ambiguous associated item in #[pyclass] This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
davidhewitt
pushed a commit
to PyO3/pyo3
that referenced
this issue
Nov 25, 2024
* Add test for ambiguous associated item The `#[pyclass]` macro implements `IntoPyObject` for the annotated enum. When the enum has any of `Error`, `Output` or `Target` as members, this clashes with the associated types of `IntoPyObject`. This also happens when deriving `IntoPyObject` directly. * Fix #4723: ambiguous associated item in #[pyclass] This uses the fix described in rust-lang/rust#57644 Also apply fix to `#[derive(IntoPyObject)]`.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-future-incompatibility
Category: Future-incompatibility lints
C-tracking-issue
Category: An issue tracking the progress of sth. like the implementation of an RFC
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
What is this lint about
With variants being resolved as inherent associated items (rust-lang/rfcs#2338) code like this become ambiguous:
This is not a problem right now, because variants cannot be used in type positions, but it may become a problem in the future if rust-lang/rfcs#2593 is accepted.
So this lints warns against cases like this and recommends to rewrite them as
<Self as Tr>::V
.How to fix this warning/error
Explicitly disambiguate in favor of associated types from traits:
<Type as Trait>::Ambiguous
.Current status
ambiguous_associated_items
lint as warn-by-defaultambiguous_associated_items
deny-by-default #59928 makes theambiguous_associated_items
lint deny-by-defaultambiguous_associated_items
lint a hard errorThe text was updated successfully, but these errors were encountered: