Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Handle patterns within closures with the feature gate enabled #24

@arora-aman

Description

@arora-aman
Contributor

When capture_disjoint_fields is enabled we see that the compiler ICEs when closure contains something like

let x = 10;
let tup = (1, 2);
let p = Point { x: 10, y: 20 };

let c = || {
    let _ = x;
    let Point { x, y } = p; // 1
    let (_, _) = tup; // 2
};

The problem here is that in case 1 p[0] and p[1] are captured, but when we build MIR we need to get information about the initializer which is p in this case which is missing since p itself isn't captured.

The issue with 2 is that since nothing from tup is used, nothing is captured. Nothing will be read when MIR is built either, but to build MIR we need access to tup, which we don't have.

Ensure ui/closures/2229_closure_analysis/wild_patterns passes

Activity

changed the title [-]Handle `let _ = x` within closures with the feature gate enabled[/-] [+]Handle Wildcard pattern within closures with the feature gate enabled[/+] on Dec 2, 2020
self-assigned this
on Dec 4, 2020
changed the title [-]Handle Wildcard pattern within closures with the feature gate enabled[/-] [+]Handle patterns within closures with the feature gate enabled[/+] on Dec 4, 2020
roxelo

roxelo commented on Jan 5, 2021

@roxelo

Once this is implemented, also modify the following test so the closure body is:

let SingleVariant::Point(ref mut x, _) = point;
*x += 1;
self-assigned this
on Jan 5, 2021
arora-aman

arora-aman commented on Jan 15, 2021

@arora-aman
ContributorAuthor
arora-aman

arora-aman commented on Jan 22, 2021

@arora-aman
ContributorAuthor

More detailed ideas using fake reads for "upvars": https://hackmd.io/fgc31ECfQnaxfP9DmjgVNw

added a commit that references this issue on Mar 16, 2021
f5d8117
added a commit that references this issue on Mar 25, 2021
846d4f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @nikomatsakis@arora-aman@roxelo

    Issue actions

      Handle patterns within closures with the feature gate enabled · Issue #24 · rust-lang/project-rfc-2229