-
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
Ensure borrows of fn/closure params do not outlive invocations #30341
Conversation
@nikomatsakis by the way, as previously discussed, this PR removed Anyway, we don't seem to need it right now, so I took it out. |
@@ -488,7 +481,10 @@ impl<'a> LifetimeContext<'a> { | |||
// `self.labels_in_fn`. | |||
extract_labels(self, fb); | |||
|
|||
self.visit_block(fb); | |||
self.with(FnScope { fn_id: fn_id, body_id: fb.id, s: self.scope }, | |||
move |_old_scope, this| { |
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.
do you need move
here? I wouldn't expect so...?
r+ modulo nits. |
c1deeb9
to
5299441
Compare
resolve_lifetime.rs: Switch from BlockScope to FnScope in ScopeChain construction. Lifetimes introduced by a fn signature are scoped to the call-site for that fn. (Note `add_scope_and_walk_fn` must only add FnScope for the walk of body, *not* of the fn signature.) region.rs: Introduce new CodeExtentData::CallSiteScope variant. Use CodeExtentData as the cx.parent, rather than just a NodeId. Change DestructionScopeData to CallSiteScopeData. regionck.rs: Thread call_site_scope via Rcx; constrain fn return values. (update; incorporated review feedback from niko.)
🙀 |
update: see barosl/homu#106 |
🙀 |
@bors r=nikomatsakis |
📌 Commit 882bca8 has been approved by |
Ensure borrows of fn/closure params do not outlive invocations. Does this by adding a new CallSiteScope to the region (or rather code extent) hierarchy, which outlives even the ParameterScope (which in turn outlives the DestructionScope of a fn/closure's body). Fix #29793 r? @nikomatsakis
Marking as relnotes since this is a soundness fix that did cause some amount of downstream fallout (e.g., #30519). |
Ensure borrows of fn/closure params do not outlive invocations.
Does this by adding a new CallSiteScope to the region (or rather code extent) hierarchy, which outlives even the ParameterScope (which in turn outlives the DestructionScope of a fn/closure's body).
Fix #29793
r? @nikomatsakis