Skip to content
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

Merged
merged 1 commit into from
May 10, 2022

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented May 5, 2022

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.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 5, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2022
LL | type X<T> = impl Clone;
| ^^^^^^^^^^ the trait `Clone` is not implemented for `T`
LL | t
| ^ the trait `Clone` is not implemented for `T`
Copy link
Contributor Author

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.

Copy link
Member

@davidtwco davidtwco left a 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.

compiler/rustc_trait_selection/src/opaque_types.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor Author

oli-obk commented May 10, 2022

@bors r=davidtwco

@bors
Copy link
Contributor

bors commented May 10, 2022

📌 Commit f667e95 has been approved by davidtwco

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 10, 2022
@bors
Copy link
Contributor

bors commented May 10, 2022

⌛ Testing commit f667e95 with merge eead58e...

@bors
Copy link
Contributor

bors commented May 10, 2022

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing eead58e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 10, 2022
@bors bors merged commit eead58e into rust-lang:master May 10, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 10, 2022
@oli-obk oli-obk deleted the tait_missing_wf_check branch May 10, 2022 15:59
@rust-timer
Copy link
Collaborator

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

bors added a commit to rust-lang-ci/rust that referenced this pull request May 13, 2022
…komatsakis

Check that closures satisfy their where bounds

fixes rust-lang#53092
fixes rust-lang#90409

based on rust-lang#96736
yvt added a commit to r3-os/r3 that referenced this pull request May 14, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants