-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as not planned
Closed as not planned
Copy link
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.T-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.T-langRelevant to the language teamRelevant to the language team
Description
Example (playground):
pub trait Foo {
type Bar: std::ops::Add<Self::Bar>;
fn bar(self) -> Self::Bar;
}
impl<T: std::ops::Add<T>> Foo for T {
type Bar = T;
fn bar(self) -> Self::Bar {
self
}
}
pub fn foo() -> impl Foo<Bar = impl std::ops::Sub<usize>> {
5usize
}
fn main() {
foo().bar() - 4usize;
}
This should error at the definition of foo
since impl std::ops::Sub<usize>
does not satisfy the std::ops::Add
bound required by Foo::Bar
. Instead it errors at the use-site in main
, and if that line is deleted (e.g. if this is a pub fn
in a library) there is no error.
error[E0277]: cannot add `impl std::ops::Sub<usize>` to `impl std::ops::Sub<usize>`
--> src/main.rs:18:11
|
18 | foo().bar() - 4usize;
| ^^^ no implementation for `impl std::ops::Sub<usize> + impl std::ops::Sub<usize>`
|
= help: the trait `std::ops::Add` is not implemented for `impl std::ops::Sub<usize>`
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.T-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.T-langRelevant to the language teamRelevant to the language team