-
Notifications
You must be signed in to change notification settings - Fork 0
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
Handle patterns within closures #45
Conversation
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 things that I feel need to chage. Will do nits later
194b37d
to
cadf23b
Compare
cadf23b
to
92ae1ce
Compare
92ae1ce
to
5f854d3
Compare
let fake_read_upvar = this.hir.mirror(thir_place); | ||
let mir_place = unpack!(block = this.as_place(block, fake_read_upvar)); | ||
debug!("RFC2229 = as_rvalue pushing following mir_place {:?}", mir_place); | ||
this.cfg.push_fake_read(block, source_info, FakeReadCause::ForLet, mir_place); |
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.
There are two fake read causes. One ForLet
and one ForMatch
. We probably should capture the correct one. I don't think it will be too much work to do that, but I think if this works fine for now, we should delay that until we fix bugs/ we get close to getting this to work.
751a599
to
84157b4
Compare
src/test/ui/closures/2229_closure_analysis/run_pass/destructure_patterns-1.rs
Outdated
Show resolved
Hide resolved
523a104
to
31e3451
Compare
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.
initial set of comments
@@ -1102,6 +1108,7 @@ struct InferBorrowKind<'a, 'tcx> { | |||
/// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow } | |||
/// ``` | |||
capture_information: InferredCaptureInformation<'tcx>, | |||
fake_reads: Vec<(Place<'tcx>, FakeReadCause)>, |
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.
Did you get a chance to try HashSet, because in case of
let c = || {
let (t1, _) = t;
let (_, t2) = t;
}
we will introduce 2 fake reads, when one should suffice
@@ -608,6 +645,30 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { | |||
ty::Closure(..) | ty::Generator(..) | |||
); | |||
|
|||
if let Some(fake_reads) = self.mc.typeck_results.closure_fake_reads.get(&closure_def_id) { |
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.
Note to self: Read this logic properly
@@ -62,7 +62,7 @@ | |||
|
|||
mod as_constant; | |||
mod as_operand; | |||
mod as_place; | |||
pub mod as_place; |
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 needed?
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.
Yes,
error[E0603]: module `as_place` is private
--> compiler/rustc_mir_build/src/build/mod.rs:2:25
|
2 | use crate::build::expr::as_place::PlaceBuilder;
| ^^^^^^^^ private module
|
note: the module `as_place` is defined here
--> compiler/rustc_mir_build/src/build/expr/mod.rs:65:1
|
65 | mod as_place;
| ^^^^^^^^^^^^^
error[E0603]: module `as_place` is private
--> compiler/rustc_mir_build/src/build/matches/mod.rs:8:25
|
8 | use crate::build::expr::as_place::PlaceBuilder;
| ^^^^^^^^ private module
|
note: the module `as_place` is defined here
--> compiler/rustc_mir_build/src/build/expr/mod.rs:65:1
|
65 | mod as_place;
| ^^^^^^^^^^^^^
error[E0603]: module `as_place` is private
--> compiler/rustc_mir_build/src/build/matches/simplify.rs:15:25
|
15 | use crate::build::expr::as_place::PlaceBuilder;
| ^^^^^^^^ private module
|
note: the module `as_place` is defined here
--> compiler/rustc_mir_build/src/build/expr/mod.rs:65:1
|
65 | mod as_place;
| ^^^^^^^^^^^^^
error[E0603]: module `as_place` is private
--> compiler/rustc_mir_build/src/build/matches/test.rs:8:25
|
8 | use crate::build::expr::as_place::PlaceBuilder;
| ^^^^^^^^ private module
|
note: the module `as_place` is defined here
--> compiler/rustc_mir_build/src/build/expr/mod.rs:65:1
|
65 | mod as_place;
| ^^^^^^^^^^^^^
error[E0603]: module `as_place` is private
--> compiler/rustc_mir_build/src/build/matches/util.rs:1:25
|
1 | use crate::build::expr::as_place::PlaceBuilder;
| ^^^^^^^^ private module
|
note: the module `as_place` is defined here
--> compiler/rustc_mir_build/src/build/expr/mod.rs:65:1
|
65 | mod as_place;
| ^^^^^^^^^^^^^
error: aborting due to 5 previous errors
Opened PR on rust-lang rust-lang#82536 |
d566cb4
to
9aca998
Compare
06ff810
to
459ebf8
Compare
459ebf8
to
88de9c2
Compare
88de9c2
to
189d206
Compare
Using the following test:
The relevant log output is as follows: