Address review comments 2

This commit is contained in:
Aman Arora 2020-11-10 03:05:50 -05:00
parent 43423f67a0
commit deeb025f39
13 changed files with 28 additions and 28 deletions

View File

@ -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

View File

@ -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;
};

View File

@ -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.

View File

@ -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.

View File

@ -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);
};

View File

@ -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
};
}

View File

@ -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
);
}
}

View File

@ -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);
};

View File

@ -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`.

View File

@ -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);
};

View File

@ -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
};
}

View File

@ -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
};

View File

@ -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();