Closed
Description
I tried this code:
#![feature(marker_trait_attr)]
#[marker] trait Trait<U> {}
impl<T, U> Trait<U> for T {}
impl<T, U> Trait<U> for T {}
fn check<T, U>(_: T, _: U) where T: Trait<U> {}
trait Foo { type Assoc; }
impl Foo for () {
type Assoc = &'static u8; // changing this to a type without a lifetime fixes the bug
}
fn infer<T: Foo>(_: T) -> T::Assoc { loop {} }
fn f() {
check((), infer(()));
}
This should compile normally, as it does if &'static u8
is replaced with, say, u8
, but instead I get:
error[E0283]: type annotations needed: cannot satisfy `(): Trait<&u8>`
--> src/lib.rs:18:5
|
18 | check((), infer(()));
| ^^^^^^^^^^^^^^^^^^^^
|
note: multiple `impl`s satisfying `(): Trait<&u8>` found
--> src/lib.rs:5:1
|
5 | impl<T, U> Trait<U> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6 | impl<T, U> Trait<U> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `check`
--> src/lib.rs:8:37
|
8 | fn check<T, U>(_: T, _: U) where T: Trait<U> {}
| ^^^^^^^^ required by this bound in `check`
Meta
rustc --version --verbose
:
rustc 1.85.0-nightly (d49be02cf 2024-12-02)
binary: rustc
commit-hash: d49be02cf6d2e2a01264fcdef1e20c826710c0f5
commit-date: 2024-12-02
host: x86_64-pc-windows-msvc
release: 1.85.0-nightly
LLVM version: 19.1.4