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

trait bounds on concrete types erase other trait implementations #132959

Closed
lolbinarycat opened this issue Nov 12, 2024 · 2 comments
Closed

trait bounds on concrete types erase other trait implementations #132959

lolbinarycat opened this issue Nov 12, 2024 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@lolbinarycat
Copy link
Contributor

I tried this code:

fn six<T>() -> usize where u8: Into<T> {
    6_u8.into()
}

I expected to see this happen: code compiles

Instead, this happened: type mismatch error

error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
1 | fn six<T>() -> usize where u8: Into<T> {
  |        -       ----- expected `usize` because of return type
  |        |
  |        found this type parameter
2 |     6_u8.into()
  |     ^^^^^^^^^^^ expected `usize`, found type parameter `T`
  |
  = note:        expected type `usize`
          found type parameter `T`

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (759e07f06 2024-10-30)
binary: rustc
commit-hash: 759e07f063fb8e6306ff1bdaeb70af56a878b415
commit-date: 2024-10-30
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
@lolbinarycat lolbinarycat added the C-bug Category: This is a bug. label Nov 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2024
@ChayimFriedman2
Copy link
Contributor

They are not erased, only preferred. And this is known. Use <u8 as Into<usize>>::into(v).

@fmease
Copy link
Member

fmease commented Nov 12, 2024

Duplicate of #24066.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2024
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