diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 90e021ae592a..87365de90470 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -938,7 +938,7 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { /// } /// ``` /// `CaptureKind` associated with both `E1` and `E2` will be ByRef(MutBorrow), -/// and both have an expression associated, however for diagnostics we prfer reporting +/// and both have an expression associated, however for diagnostics we prefer reporting /// `E1` since it appears earlier in the closure body. When `E2` is being processed we /// would've already handled `E1`, and have an existing capture_information for it. /// Calling `determine_capture_info(existing_info_e1, current_info_e2)` will return diff --git a/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.rs b/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.rs index e144cce54ec2..01c28aa29fb8 100644 --- a/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.rs +++ b/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.rs @@ -11,7 +11,7 @@ fn main() { || { m[0] += 10; //~^ ERROR: Capturing m[] -> MutBorrow - //~^^ ERROR: Min Capture m[] -> MutBorrow + //~| ERROR: Min Capture m[] -> MutBorrow m[1] += 40; }; diff --git a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs index 3f2e16725dc3..b50c2d66d94b 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs +++ b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs @@ -17,7 +17,7 @@ fn main() { || { println!("{}", p.x); //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow }; // `c` should only capture `p.x`, therefore mutating `p.y` is allowed. diff --git a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.rs b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.rs index 5db1c9c0683e..99095c719866 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.rs +++ b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.rs @@ -12,7 +12,7 @@ fn main() { || { println!("{}", t.0); //~^ ERROR: Capturing t[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture t[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture t[(0, 0)] -> ImmBorrow }; // `c` only captures t.0, therefore mutating t.1 is allowed. diff --git a/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs b/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs index 36f258f950f4..eef8fd6e5574 100644 --- a/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs +++ b/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs @@ -12,7 +12,7 @@ fn arrays() { || { let [a, b, .., e] = arr; //~^ ERROR: Capturing arr[Index] -> ByValue - //~^^ ERROR: Min Capture arr[] -> ByValue + //~| ERROR: Min Capture arr[] -> ByValue assert_eq!(a, "A"); assert_eq!(b, "B"); assert_eq!(e, "E"); @@ -35,9 +35,9 @@ fn structs() { || { let Point { x: ref mut x, y: _, id: moved_id } = p; //~^ ERROR: Capturing p[(0, 0)] -> MutBorrow - //~^^ ERROR: Capturing p[(2, 0)] -> ByValue - //~^^^ ERROR: Min Capture p[(0, 0)] -> MutBorrow - //~^^^^ ERROR: Min Capture p[(2, 0)] -> ByValue + //~| ERROR: Capturing p[(2, 0)] -> ByValue + //~| ERROR: Min Capture p[(0, 0)] -> MutBorrow + //~| ERROR: Min Capture p[(2, 0)] -> ByValue println!("{}, {}", x, moved_id); }; @@ -52,11 +52,11 @@ fn tuples() { || { let (ref mut x, ref ref_str, (moved_s, _)) = t; //~^ ERROR: Capturing t[(0, 0)] -> MutBorrow - //~^^ ERROR: Capturing t[(1, 0)] -> ImmBorrow - //~^^^ ERROR: Capturing t[(2, 0),(0, 0)] -> ByValue - //~^^^^ ERROR: Min Capture t[(0, 0)] -> MutBorrow - //~^^^^^ ERROR: Min Capture t[(1, 0)] -> ImmBorrow - //~^^^^^^ ERROR: Min Capture t[(2, 0),(0, 0)] -> ByValue + //~| ERROR: Capturing t[(1, 0)] -> ImmBorrow + //~| ERROR: Capturing t[(2, 0),(0, 0)] -> ByValue + //~| ERROR: Min Capture t[(0, 0)] -> MutBorrow + //~| ERROR: Min Capture t[(1, 0)] -> ImmBorrow + //~| ERROR: Min Capture t[(2, 0),(0, 0)] -> ByValue println!("{}, {} {}", x, ref_str, moved_s); }; diff --git a/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.rs b/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.rs index 3713abe52df2..ee55e3a3f218 100644 --- a/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.rs +++ b/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.rs @@ -10,6 +10,6 @@ fn main() { || { println!("This uses new capture analyysis to capture s={}", s); //~^ ERROR: Capturing s[] -> ImmBorrow - //~^^ ERROR: Min Capture s[] -> ImmBorrow + //~| ERROR: Min Capture s[] -> ImmBorrow }; } diff --git a/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.rs b/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.rs index 3ef8b4acf978..d526934271c4 100644 --- a/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.rs +++ b/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.rs @@ -25,7 +25,7 @@ impl Data { #[rustc_capture_analysis] |v| self.filter.allowed(*v), //~^ ERROR: Capturing self[Deref,(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture self[Deref,(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture self[Deref,(0, 0)] -> ImmBorrow ); } } diff --git a/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.rs b/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.rs index a6793a43488e..08c9aa8eff84 100644 --- a/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.rs +++ b/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.rs @@ -24,7 +24,7 @@ fn main() { || { let wp = &w.p; //~^ ERROR: Capturing w[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture w[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture w[(0, 0)] -> ImmBorrow println!("{}", wp.x); }; diff --git a/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.rs b/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.rs index 994e2530f782..020753a71bf3 100644 --- a/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.rs +++ b/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.rs @@ -21,7 +21,7 @@ fn main() { || { println!("{}", w.p.x); //~^ ERROR: Capturing w[(0, 0),(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow }; // `c` only captures `w.p.x`, therefore it's safe to mutate `w.p.y`. diff --git a/src/test/ui/closures/2229_closure_analysis/nested-closure.rs b/src/test/ui/closures/2229_closure_analysis/nested-closure.rs index 8641d6b4f59f..d2e99fe4accf 100644 --- a/src/test/ui/closures/2229_closure_analysis/nested-closure.rs +++ b/src/test/ui/closures/2229_closure_analysis/nested-closure.rs @@ -23,17 +23,17 @@ fn main() { || { println!("{}", p.x); //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow let incr = 10; let mut c2 = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental || p.y += incr; //~^ ERROR: Capturing p[(1, 0)] -> MutBorrow - //~^^ ERROR: Capturing incr[] -> ImmBorrow - //~^^^ ERROR: Min Capture p[(1, 0)] -> MutBorrow - //~^^^^ ERROR: Min Capture incr[] -> ImmBorrow - //~^^^^^ ERROR: Capturing p[(1, 0)] -> MutBorrow - //~^^^^^^ ERROR: Min Capture p[(1, 0)] -> MutBorrow + //~| ERROR: Capturing incr[] -> ImmBorrow + //~| ERROR: Min Capture p[(1, 0)] -> MutBorrow + //~| ERROR: Min Capture incr[] -> ImmBorrow + //~| ERROR: Capturing p[(1, 0)] -> MutBorrow + //~| ERROR: Min Capture p[(1, 0)] -> MutBorrow c2(); println!("{}", p.y); }; diff --git a/src/test/ui/closures/2229_closure_analysis/path-with-array-access.rs b/src/test/ui/closures/2229_closure_analysis/path-with-array-access.rs index 48e0698b4a75..4a42970137ff 100644 --- a/src/test/ui/closures/2229_closure_analysis/path-with-array-access.rs +++ b/src/test/ui/closures/2229_closure_analysis/path-with-array-access.rs @@ -25,6 +25,6 @@ fn main() { || { println!("{}", pent.points[5].x); //~^ ERROR: Capturing pent[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture pent[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture pent[(0, 0)] -> ImmBorrow }; } diff --git a/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.rs b/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.rs index 3d5a08344b72..68c18eac8048 100644 --- a/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.rs +++ b/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.rs @@ -27,7 +27,7 @@ fn main() { || { p.x += 10; //~^ ERROR: Capturing p[(0, 0)] -> MutBorrow - //~^^ ERROR: Min Capture p[] -> MutBorrow + //~| ERROR: Min Capture p[] -> MutBorrow println!("{:?}", p); //~^ ERROR: Capturing p[] -> ImmBorrow }; diff --git a/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs b/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs index d17af7cc79a4..889836c11ce8 100644 --- a/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs +++ b/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs @@ -23,7 +23,7 @@ fn wild_struct() { // FIXME(arora-aman): Change `_x` to `_` let Point { x: _x, y: _ } = p; //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow - //~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow + //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow }; c(); @@ -38,7 +38,7 @@ fn wild_tuple() { // FIXME(arora-aman): Change `_x` to `_` let (_x, _) = t; //~^ ERROR: Capturing t[(0, 0)] -> ByValue - //~^^ ERROR: Min Capture t[(0, 0)] -> ByValue + //~| ERROR: Min Capture t[(0, 0)] -> ByValue }; c(); @@ -53,7 +53,7 @@ fn wild_arr() { // FIXME(arora-aman): Change `_x` to `_` let [_x, _] = arr; //~^ ERROR: Capturing arr[Index] -> ByValue - //~^^ ERROR: Min Capture arr[] -> ByValue + //~| ERROR: Min Capture arr[] -> ByValue }; c();