-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Check hidden types for well formedness at the definition site instead of only at the opaque type itself #96736
Conversation
LL | type X<T> = impl Clone; | ||
| ^^^^^^^^^^ the trait `Clone` is not implemented for `T` | ||
LL | t | ||
| ^ the trait `Clone` is not implemented for `T` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slightly confusing that we're talking about T
here and f
also has a T
, but considering the help
right below, that should be explanatory enough for this PR I think.
I want to add a new type-alias-impl-trait ObligationCause that we will then use to improve this diagnostic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, r=me after comment is addressed.
… of only at the opaque type itself
17fe901
to
f667e95
Compare
@bors r=davidtwco |
📌 Commit f667e95 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (eead58e): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
…komatsakis Check that closures satisfy their where bounds fixes rust-lang#53092 fixes rust-lang#90409 based on rust-lang#96736
It seems that [rust-lang/rust#96736][1] introduced checks for these missing bounds, resulting in the following compilation error: error[E0277]: expected a `FnOnce<(Output,)>` closure, found `Mapper` --> src/r3_core/src/bind.rs:1360:5 | 1360 | move || (mapper)(inner_bound_fn()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(Output,)>` closure, found `Mapper` | note: required by a bound in `map_bind_inner` --> src/r3_core/src/bind.rs:1358:13 | 1352 | const fn map_bind_inner<InnerBoundFn, Output, Mapper, NewOutput>( | -------------- required by a bound in this ... 1358 | Mapper: FnOnce(Output) -> NewOutput + Copy + Send + 'static, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map_bind_inner` help: consider further restricting this bound | 1349 | Mapper: Copy + Send + 'static + core::ops::FnOnce<(Output,)>, | ++++++++++++++++++++++++++++++ [1]: rust-lang/rust#96736
work towards #90409 . We'll need to look into closure and generator bodies of closures and generators nested inside the hidden type in order to fix that. In hindsight this PR is not necessary for that, but it may be a bit easier with it and we'll get better diagnostics from it on its own.