Commit Graph

15 Commits

Author SHA1 Message Date
Oli Scherer 9a2362e5a9 Shrink the size of Rvalue by 16 bytes 2021-03-05 09:33:01 +00:00
Mark Rousskov d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Yuki Okushi 7fa991fb85
Rollup merge of #81291 - sexxi-goose:fix-struct-update-functional-record-update-syntax-error, r=nikomatsakis
Support FRU pattern with `[feature(capture_disjoint_fields)]`

In case of a functional record update syntax for creating a structure, `ExprUseVisitor` to only detect the precise use of some of the field in the `..x` part of the syntax. However, when we start building MIR, we
1. First, build the place for `x`
2. and then, add precise field projections so that only some parts of `x` end up getting read.

When `capture_disjoint_fields` is enabled, and FRU is used within a closure `x` won't be completely captured, and therefore the first step will fail. This PR updates `mir_build` to create a place builder in the first step and then create place from the builder only after applying the field projection.

Closes https://github.com/rust-lang/project-rfc-2229/issues/32
r? ``````@nikomatsakis``````
2021-01-30 13:36:46 +09:00
Dhruv Jauhar e94cf57c3e Make functional record update/struct update syntax works inside closures when feature capture_disjoint_fields is enabled 2021-01-22 23:10:24 -05:00
Caio f85fc264fe Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
Matthias Krüger bdc9291ed9 where possible, pass slices instead of &Vec or &String (clippy::ptr_arg) 2020-12-30 13:11:52 +01:00
Aman Arora e2efdd156b Use precise places when lowering Closures in THIR
- Closures now use closure_min_captures to figure out captured paths
- Build upvar_mutbls using closure_min_captures
- Change logic in limit_capture_mutability to differentiate b/w
  capturing parent's local variable or capturing a variable that is
  captured by the parent (in case of nested closure) using PlaceBase.

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09 22:34:15 -05:00
Aman Arora 6a1d0699a4 Use Places for captures in MIR
- Use closure_min_capture maps to capture precise paths
- PlaceBuilder now searches for ancestors in min_capture list
- Add API to `Ty` to allow access to the n-th element in a
  tuple in O(1) time.

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-09 22:33:33 -05:00
Aman Arora d9523622ff Move handling UpvarRef to PlaceBuilder
- This allows us to delay figuring out the index of a capture
  in the closure structure when all projections to atleast form
  a capture have been applied to the builder

Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-12-06 18:30:23 -05:00
Aman Arora 9f70e782f7 Remove THIR::ExprKind::SelfRef
ExprKind::SelfRef was used to express accessing `self` in
the desugared Closure/Generator struct when lowering captures in THIR.

Since we handle captures in MIR now, we don't need `ExprKind::Self`.
2020-11-17 17:49:42 -05:00
Aman Arora 7faebe57b2 Move capture lowering from THIR to MIR
This allows us to:
- Handle precise Places captured by a closure directly in MIR. Handling
captures in MIR is easier since we can rely on/ tweak PlaceBuilder to
generate `mir::Place`s that resemble how we store captures (`hir::Place`).
- Allows us to handle `let _ = x` case when feature `capture_disjoint_fields`
is enabled directly in MIR. This is required to be done in MIR since
patterns are desugared in MIR.
2020-11-17 17:49:42 -05:00
Joshua Nelson 57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
Santiago Pastorino fe922e567f
Lower inline const down to MIR 2020-10-16 15:21:18 -03:00
LeSeulArtichaut 3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00