Closed
Description
I tried this code:
use crate_b::{Foo, Super, Unsatisfied};
fn foo<T: Foo>() {
unsatisfied::<<T::FooAssoc as Super>::SuperAssoc>()
}
fn unsatisfied<B: Unsatisfied>() {}
pub mod crate_b {
pub trait Foo {
type FooAssoc: Bar;
}
pub trait Bar: Super<SuperAssoc: Bound> {}
pub trait Super {
type SuperAssoc;
}
pub trait Bound: Unsatisfied {}
pub trait Unsatisfied {}
}
This compiles fine, however if crate_b is a separate crate instead of a local module, it errors with:
error[E0277]: the trait bound `<<T as Foo>::FooAssoc as Super>::SuperAssoc: Unsatisfied` is not satisfied
--> src/main.rs:4:19
|
4 | unsatisfied::<<T::FooAssoc as Super>::SuperAssoc>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unsatisfied` is not implemented for `<<T as Foo>::FooAssoc as Super>::SuperAssoc`
|
note: required by a bound in `unsatisfied`
--> src/main.rs:7:19
|
7 | fn unsatisfied<B: Unsatisfied>() {}
| ^^^^^^^^^^^ required by this bound in `unsatisfied`
help: consider further restricting the associated type
|
3 | fn foo<T: Foo>() where <<T as Foo>::FooAssoc as Super>::SuperAssoc: Unsatisfied {
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error
This is not fixed by the next solver (-Znext-solver
).
Meta
rustc --version --verbose
:
rustc 1.79.0-nightly (1388d7a06 2024-03-20)
binary: rustc
commit-hash: 1388d7a069d872bcfe5e5dd97ef61fa0a586fac0
commit-date: 2024-03-20
host: aarch64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2