-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
Description
In certain cases, rustc
will emit an error message on what appears to be valid code, claiming that
- a bound that is present is not present, and must be present
- but the bound is present and must not be present
Here is a MWE (or playground):
trait Foo<T> { type Quux; }
trait Bar<B> {
type Baz;
fn arthur() where B: Foo<Self::Baz>, B::Quux: Send;
}
impl<B> Bar<B> for () {
type Baz = ();
fn arthur() where B: Foo<()>, B::Quux: Send { }
}
This produces the pair of errors:
rustc 1.16.0 (30cf806ef 2017-03-10)
error[E0277]: the trait bound `B: Foo<()>` is not satisfied
--> <anon>:8:5
|
8 | fn arthur() where B: Foo<()>, B::Quux: Send { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo<()>` is not implemented for `B`
|
= help: consider adding a `where B: Foo<()>` bound
error[E0276]: impl has stricter requirements than trait
--> <anon>:8:5
|
4 | fn arthur() where B: Foo<Self::Baz>, B::Quux: Send;
| --------------------------------------------------- definition of `arthur` from trait
...
8 | fn arthur() where B: Foo<()>, B::Quux: Send { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `B: Foo<()>`
error: aborting due to 2 previous errors
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.