-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed as not planned
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
pub trait BaseTrait {
type MyType;
}
pub trait BaseTraitExt: BaseTrait
where Self::MyType: std::fmt::Debug {}
pub trait Container {
type Extended: BaseTraitExt;
}
I expected the code to compile successfully.
Instead, compilation fails with the following error:
error[E0277]: `<<Self as Container>::Extended as BaseTrait>::MyType` doesn't implement `Debug`
--> src/main.rs:9:20
|
9 | type Extended: BaseTraitExt;
| ^^^^^^^^^^^^ `<<Self as Container>::Extended as BaseTrait>::MyType` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
= help: the trait `Debug` is not implemented for `<<Self as Container>::Extended as BaseTrait>::MyType`
note: required by a bound in `BaseTraitExt`
--> src/main.rs:6:21
|
5 | pub trait BaseTraitExt: BaseTrait
| ------------ required by a bound in this trait
6 | where Self::MyType: std::fmt::Debug {}
| ^^^^^^^^^^^^^^^ required by this bound in `BaseTraitExt`
help: consider further restricting the associated type
|
8 | pub trait Container where <<Self as Container>::Extended as BaseTrait>::MyType: Debug {
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Meta
rustc --version --verbose
:
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6
citizen-stig and cemozerr
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.