-
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
rustc: trait-level where clauses are mistakenly imposed when bounding by the trait #50792
Comments
Note: affects 1.26 and the current nightly. |
You can get it to work by repeating the where clause: struct Wrapper<T>(T);
trait Base {}
trait Wrapped: Sized where Wrapper<Self>: Base {}
fn wat<F: Wrapped>() where Wrapper<F>: Base {}
fn main() {} I think what is desired here is the implied bounds feature. |
This seems similar to #20671, though from a slightly different angle. Rust 1.3 has no complaint with the example. Rust 1.4 starts E0277 as a warning that "will become a HARD ERROR in the next release. See RFC 1214 for details." Rust 1.7 is where it actually became an error. |
Yes, rust-lang/rfcs#1214 improved the well-formedness check, and it states that for a trait reference to be WF all where clauses on the trait must be satisified. The implied bounds RFC says that functions can now assume those where clauses to be satifsfied, but that RFC is still being implemented so this is a dupe of #44491. And it's not "just a bug". |
I'm trying to use a
where
clause to define one trait in terms of another, as applied to a wrapper type:But when I try to bound by the new trait, I get a strange error:
The text was updated successfully, but these errors were encountered: