-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constraint does not match because where clause hides blanket impl #37138
Labels
Comments
Changing the pub trait ProxiedBy<T> {}
impl<T> ProxiedBy<T> for T {}
// New subtrait:
pub trait ProxiedBySubtrait<T>: ProxiedBy<T> {}
impl<T> ProxiedBySubtrait<T> for T {}
pub trait SomeConstraint {}
struct Performer<OnT>(OnT);
impl<OnT> Performer<OnT> {
fn perform<QueryT, ProxyT>(&self, query: QueryT)
where QueryT: ProxiedBySubtrait<ProxyT>, // Was QueryT: ProxiedBy<ProxyT>
OnT: ProxiedBy<ProxyT>,
ProxyT: SomeConstraint {}
}
fn good_again<OnT, IrrelevantT>(performer: Performer<OnT>, on: OnT)
where OnT: SomeConstraint + ProxiedBy<IrrelevantT>,
OnT: ProxiedBy<OnT> // This constraint should be unnecessary!
{
performer.perform(on);
} |
This was referenced Oct 13, 2016
Mark-Simulacrum
changed the title
Inference failure when blanket impl would resolve constraint, but where clause takes priority
Constraint does not match because where clause hides blanket impl
May 14, 2017
Centril
added a commit
to Centril/rust
that referenced
this issue
Oct 19, 2019
…asper Use structured suggestion for restricting bounds When a trait bound is not met and restricting a type parameter would make the restriction hold, use a structured suggestion pointing at an appropriate place (type param in param list or `where` clause). Account for opaque parameters where instead of suggesting extending the `where` clause, we suggest appending the new restriction: `fn foo(impl Trait + UnmetTrait)`. Fix rust-lang#64565, fix rust-lang#41817, fix rust-lang#24354, cc rust-lang#26026, cc rust-lang#37808, cc rust-lang#24159, fix rust-lang#37138, fix rust-lang#24354, cc rust-lang#20671.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
playground
Sorry about the title gore, but I don't really know how to describe this:
Fails with (on both stable & nightliy):
The
ProxiedBy<IrrelevantT>
constraint is the only difference betweengood
andbad
. ButOnT: ProxiedBy<OnT> + HasConstraint
, thereforeProxyT = OnT
should still be a valid substitution.Since
IrrelevantT: !SomeConstraint
(as rustc helpfully explains) there also should be no problem.The text was updated successfully, but these errors were encountered: