summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/issue_4110.rs
blob: d3734e90b7ffa97c47633d0a0b6909356ea26160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
fn bindings() {
    let err = match (place_desc, explanation) {
        (
            Some(ref name),
            BorrowExplanation::MustBeValidFor {
                category:
                    category @ (ConstraintCategory::Return
                    | ConstraintCategory::CallArgument
                    | ConstraintCategory::OpaqueType),
                from_closure: false,
                ref region_name,
                span,
                ..
            },
        ) if borrow_spans.for_generator() | borrow_spans.for_closure() => self
            .report_escaping_closure_capture(
                borrow_spans,
                borrow_span,
                region_name,
                category,
                span,
                &format!("`{}`", name),
                "function",
            ),
        (
            ref name,
            BorrowExplanation::MustBeValidFor {
                category: ConstraintCategory::Assignment,
                from_closure: false,
                region_name:
                    RegionName {
                        source: RegionNameSource::AnonRegionFromUpvar(upvar_span, ref upvar_name),
                        ..
                    },
                span,
                ..
            },
        ) => self.report_escaping_data(borrow_span, name, upvar_span, upvar_name, span),
        (Some(name), explanation) => self.report_local_value_does_not_live_long_enough(
            location,
            &name,
            &borrow,
            drop_span,
            borrow_spans,
            explanation,
        ),
        (None, explanation) => self.report_temporary_value_does_not_live_long_enough(
            location,
            &borrow,
            drop_span,
            borrow_spans,
            proper_span,
            explanation,
        ),
    };
}