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

Incorrect handling of trait associated type #114926

Closed
xlc opened this issue Aug 17, 2023 · 3 comments
Closed

Incorrect handling of trait associated type #114926

xlc opened this issue Aug 17, 2023 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@xlc
Copy link

xlc commented Aug 17, 2023

I tried this code:

https://github.com/xlc/trait-bug

I expected to see this happen: compiles

Instead, this happened:

   Checking foo v0.1.0 (/Users/xiliangchen/projects/acala/trait-bug/foo)
error[E0119]: conflicting implementations of trait `From<Foo>` for type `Foo`
  --> foo/src/lib.rs:11:1
   |
11 | impl From<<baz::Baz as ::baz::BazTrait>::BazType> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: conflicting implementation in crate `core`:
           - impl<T> From<T> for T;

For more information about this error, try `rustc --explain E0119`.
error: could not compile `foo` (lib) due to previous error

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (07438b092 2023-08-16)
binary: rustc
commit-hash: 07438b0928c6691d6ee734a5a77823ec143be94d
commit-date: 2023-08-16
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 17.0.0

Note that the code will compile if all the types are in a single crate.

@xlc xlc added the C-bug Category: This is a bug. label Aug 17, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2023
@eval-exec
Copy link
Contributor

@xlc
Copy link
Author

xlc commented Aug 19, 2023

Not exactly. <baz::Baz as ::baz::BazTrait>::BazType> is a concrete type that is always u32. Also the code compiles if baz::Baz is defined in the same crate.

@xlc
Copy link
Author

xlc commented Aug 26, 2023

Dup of #51445

@xlc xlc closed this as completed Aug 26, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants