Conversation
|
This PR changes a file inside |
This comment has been minimized.
This comment has been minimized.
| @@ -803,9 +778,12 @@ fn field_tys_satisfy_relation_after_normalization_and_resolution<'tcx>( | |||
| else { | |||
| return false; | |||
| }; | |||
| if source_region != target_region { | |||
| return false; | |||
| } | |||
| infcx.sub_regions( | |||
| SubregionOrigin::RelateObjectBound(span), | |||
| target_region, | |||
| source_region, | |||
| ty::VisibleForLeakCheck::Yes, | |||
| ); | |||
| if ocx.sup(&cause, param_env, target_referent_ty, source_referent_ty).is_err() { | |||
| return false; | |||
| } | |||
There was a problem hiding this comment.
I couldn't find any in-tree docs about the lifetime handling. Should probably add some now that you aren't requiring equality anymore. I had to grab a variance table and poke at the code and tests here until I was sure it was all in the right direction 😆
There was a problem hiding this comment.
Where should they be located in? Just here in the code?
| if trait_impl_lifetime_params_count(tcx, impl_did) != 1 { | ||
| if trait_impl_lifetime_params_count(tcx, impl_did) == 0 { | ||
| return Err(tcx | ||
| .dcx() | ||
| .emit_err(diagnostics::CoerceSharedNotSingleLifetimeParam { span, trait_name })); |
There was a problem hiding this comment.
probably needs updating of the diagnostic (and at minimum of the diagnostic struct name)
|
|
||
| let Some(last) = path.segments.last_mut() else { | ||
| // FIXME(reborrow): we might want to support CoerceShared<Foo> for Bar at some point. | ||
| cx.dcx().emit_err(MalformedTarget { span: attr.span }); |
There was a problem hiding this comment.
probably want to use more precise span for all the MalformedTarget errors, usually you have a specific item available which has its own span
|
Reminder, once the PR becomes ready for a review, use |
| .filter_map(|param| match param.kind { | ||
| GenericParamKind::Lifetime => { | ||
| GenericArg::Lifetime(cx.lifetime(param.span(), param.ident)) | ||
| if trait_name == sym::CoerceShared && !param.ident.as_str().ends_with("_") { |
There was a problem hiding this comment.
What would happen if the lifetime generic already has a _ suffix?
00337c0 to
fb3a7fd
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
The
Reborrow/CoerceSharedborrow checking code is now robust enough to properly handle multiple lifetimes, and for that we can allow multiple lifetimes in the traits. This requires making theCoerceSharedderive macro produce multiple lifetimes and in particular produce'a_ where'a: 'a_` additions to the generics, and removing some now-unnecessary checks from the wf-checks.The derive trait code is some of the uglies stuff I've ever written.
r? @oli-obk