-
Notifications
You must be signed in to change notification settings - Fork 13.6k
support non-defining uses of opaques in borrowck #145244
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
base: master
Are you sure you want to change the base?
support non-defining uses of opaques in borrowck #145244
Conversation
0d7a748
to
e276bbf
Compare
for error in errors { | ||
guar = Some(match error { | ||
DeferredOpaqueTypeError::InvalidOpaqueTypeArgs(err) => err.report(self.infcx), | ||
DeferredOpaqueTypeError::LifetimeMismatchOpaqueParam(err) => { | ||
self.infcx.dcx().emit_err(err) | ||
} | ||
DeferredOpaqueTypeError::UnexpectedHiddenRegion { |
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.
just moved from RegionErrorKind::UnexpectedHiddenRegion
14e5264
to
5536a31
Compare
This comment has been minimized.
This comment has been minimized.
5536a31
to
298629b
Compare
This comment has been minimized.
This comment has been minimized.
298629b
to
9af9a2c
Compare
This comment has been minimized.
This comment has been minimized.
// FIXME(-Znext-solver): enable this test | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver |
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.
idk why I've added this FIXME to these 3 tests, only one of them actually failed with the new solver before.
constraints, | ||
universal_region_relations, | ||
location_map, | ||
&mut opaque_types, |
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.
&opaque_types
:<
hidden_type.span, | ||
DefiningScopeKind::MirBorrowck, | ||
) { | ||
if tcx.use_typing_mode_borrowck() { |
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.
needs comment: a non-defining use
hidden_type: OpaqueHiddenType<'tcx>, | ||
} | ||
|
||
fn collect_defining_uses<'tcx>( |
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.
fn collect_defining_uses<'tcx>( | |
fn compute_hidden_types<'tcx>( |
and fn apply_computed_hidden_types
?
|
||
let mut defining_uses = vec![]; | ||
let mut errors = vec![]; | ||
for &(opaque_type_key, hidden_type) in opaque_types { |
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.
move this loopy loop into collect_defining_uses
sub-fn
rcx.scc_values.add_region(member, min_choice_scc); | ||
} | ||
|
||
struct CollectMemberConstraintsVisitor<'a, 'b, 'tcx> { |
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.
equiv to existing register_member_constraints
let mut decls_modulo_regions: FxIndexMap<OpaqueTypeKey<'tcx>, (OpaqueTypeKey<'tcx>, Span)> = | ||
FxIndexMap::default(); | ||
for &DefiningUse { opaque_type_key, ref arg_regions, hidden_type } in defining_uses { | ||
let opaque_type_key = opaque_type_key.fold_captured_lifetime_args(infcx.tcx, |r| { |
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.
store non_nll_opaque_type_key
in DefiningUse
let _span = debug_span!( | ||
"map_defining_uses_to_definition_site", | ||
?opaque_type_key, | ||
?arg_regions, | ||
?hidden_type | ||
); |
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.
let _span = debug_span!( | |
"map_defining_uses_to_definition_site", | |
?opaque_type_key, | |
?arg_regions, | |
?hidden_type | |
); |
Reimplements the first part of #139587, but limited to only the new solver.
member_constraints
shit out of the type checker and region inference context'erased
handlingapply_defining_uses
is the thing that actually mutates the constraintsopaque_types_added_since
add commentcheck_opaque_type_parameter_valid
needs to be renamed, it's not valid, it's defining?ToArgRegionsFolder
should be in a separate PRr? @ghost