-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Simplify memory categorization #66246
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @nikomatsakis or @pnkfelix |
This comment has been minimized.
This comment has been minimized.
0974f81
to
0ce49a5
Compare
☔ The latest upstream changes (presumably #66252) made this pull request unmergeable. Please resolve the merge conflicts. |
0ce49a5
to
3496922
Compare
☔ The latest upstream changes (presumably #66314) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage |
0de037c
to
17b6cd0
Compare
☔ The latest upstream changes (presumably #66671) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @pnkfelix |
@@ -899,10 +896,6 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { | |||
} | |||
|
|||
cmt = self.with_mc(|mc| mc.cat_expr_adjusted(expr, cmt, &adjustment))?; | |||
|
|||
if let Categorization::Deref(_, mc::BorrowedPtr(_, r_ptr)) = cmt.cat { | |||
self.mk_subregion_due_to_dereference(expr.span, expr_region, r_ptr); |
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 know what this was originally here for? I just want a note in this PR about why we don't need it, no need to add comments to the source code or anything.
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.
(is this a case where mir-borrowck (and/or nll/type-check) is imposing the same constraint and so we do not need to impose it here?)
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.
That's the case for most of the constraints in this file. This check specifically is to ensure, in the language of NLL, that 'a
is live at the point marked:
let x: &'a (i32, i32) = ...;
let _ = x.0; //here
This is redundant because:
- There's no longer any check that makes use of ReScopes (except for the leak check, but that's hopefully going away soon).
- NLL does is own region liveness inference.
- I think that we're already adding this relation because all of the regions in the unadjusted expression are already marked live.
This looks great! r=me once you have addressed the nits above. |
@bors r=pnkfelix |
📌 Commit 5bc1586 has been approved by |
⌛ Testing commit 5bc1586 with merge 223a873de4d7729c3869832b3189f8ddbd17b7c2... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
@bors retry |
Simplify memory categorization With AST borrowck gone, mem_categorization can be simplified, a lot. * `cmt_` is now called `Place`. Most local variable names have been updated to reflect this, but the `cat_*` methods retain their names. * `MemCategorizationContext` no longer needs a `ScopeTree` and always needs an `InferCtxt`. * `Place` now uses a similar representation to `mir::Place` with a `Vec` of projections. * `Upvar` places don't include the implicit environment and capture derefs. These are now handled by `regionck` when needed. * Various types, methods and variants only used by AST borrowck have been removed. * `ExprUseVisitor` now lives in `rustc_typeck::expr_use_visitor`. * `MemCategorizationContext` and `Place` live in `rustc_typeck::mem_categorization`. * `Place` is re-exported in `rustc_typeck::expr_use_visitor` so that Clippy can access it. The loss of an error in `issue-4335.rs` is due to a change in capture inference in ill-formed programs. If any projection from a variable is moved from then we capture that variable by move, whether or not the place being moved from allows this. Closes #66270
☀️ Test successful - checks-azure |
📣 Toolstate changed by #66246! Tested on commit 4752c05. 💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq, @rust-lang/infra). |
Tested on commit rust-lang/rust@4752c05. Direct link to PR: <rust-lang/rust#66246> 💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq, @rust-lang/infra). 💔 clippy-driver on linux: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq, @rust-lang/infra). 💔 rls on windows: test-pass → test-fail (cc @Xanewok, @rust-lang/infra).
@@ -83,6 +86,7 @@ mod collect; | |||
mod constrained_generic_params; | |||
mod structured_errors; | |||
mod impl_wf_check; | |||
mod mem_categorization; |
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.
Uh, this needs to be public too, Clippy can't use EUV without memcat
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.
In general we should be very careful about marking existing things as private
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.
Oh, I see, you want us to use Place from EUV, and Categorization isn't a thing anymore
Rustup From rust-lang/rust#66246 changelog: none
…-DPC Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#66868 (fixed by rust-lang#67071) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
…-DPC Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#66868 (fixed by rust-lang#67071) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
Add regression tests for fixed ICEs Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01)) Closes rust-lang#66270 (fixed by rust-lang#66246) Closes rust-lang#67424 (fixed by rust-lang#67160) Also picking a minor nit up from rust-lang#67071 with 101dd7b r? @Centril
With AST borrowck gone, mem_categorization can be simplified, a lot.
cmt_
is now calledPlace
. Most local variable names have been updated to reflect this, but thecat_*
methods retain their names.MemCategorizationContext
no longer needs aScopeTree
and always needs anInferCtxt
.Place
now uses a similar representation tomir::Place
with aVec
of projections.Upvar
places don't include the implicit environment and capture derefs. These are now handled byregionck
when needed.ExprUseVisitor
now lives inrustc_typeck::expr_use_visitor
.MemCategorizationContext
andPlace
live inrustc_typeck::mem_categorization
.Place
is re-exported inrustc_typeck::expr_use_visitor
so that Clippy can access it.The loss of an error in
issue-4335.rs
is due to a change in capture inference in ill-formed programs. If any projection from a variable is moved from then we capture that variable by move, whether or not the place being moved from allows this.Closes #66270