diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 87365de9047..e0bbe3cb079 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -166,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "For closure={:?}, capture_information={:#?}", closure_def_id, delegate.capture_information ); - self.log_closure_capture_info(closure_def_id, &delegate.capture_information, span); + self.log_capture_analysis_first_pass(closure_def_id, &delegate.capture_information, span); if let Some(closure_substs) = infer_kind { // Unify the (as yet unbound) type variable in the closure @@ -499,20 +499,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.has_attr(closure_def_id, sym::rustc_capture_analysis) } - fn log_closure_capture_info( + fn log_capture_analysis_first_pass( &self, closure_def_id: rustc_hir::def_id::DefId, capture_information: &FxIndexMap, ty::CaptureInfo<'tcx>>, closure_span: Span, ) { if self.should_log_capture_analysis(closure_def_id) { + let mut diag = + self.tcx.sess.struct_span_err(closure_span, "First Pass analysis includes:"); for (place, capture_info) in capture_information { let capture_str = construct_capture_info_string(self.tcx, place, capture_info); let output_str = format!("Capturing {}", capture_str); let span = capture_info.expr_id.map_or(closure_span, |e| self.tcx.hir().span(e)); - self.tcx.sess.span_err(span, &output_str); + diag.span_note(span, &output_str); } + diag.emit(); } } @@ -521,6 +524,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(min_captures) = self.typeck_results.borrow().closure_min_captures.get(&closure_def_id) { + let mut diag = + self.tcx.sess.struct_span_err(closure_span, "Min Capture analysis includes:"); + for (_, min_captures_for_var) in min_captures { for capture in min_captures_for_var { let place = &capture.place; @@ -532,9 +538,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let span = capture_info.expr_id.map_or(closure_span, |e| self.tcx.hir().span(e)); - self.tcx.sess.span_err(span, &output_str); + diag.span_note(span, &output_str); } } + diag.emit(); } } } 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 01c28aa29fb..131af6a10c8 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 @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| `#[warn(incomplete_features)]` on by default +//~| see issue #53488 #![feature(rustc_attrs)] // Ensure that capture analysis results in arrays being completely captured. @@ -8,10 +10,13 @@ fn main() { let mut c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: m[0] += 10; - //~^ ERROR: Capturing m[] -> MutBorrow - //~| ERROR: Min Capture m[] -> MutBorrow + //~^ NOTE: Capturing m[] -> MutBorrow + //~| NOTE: Min Capture m[] -> MutBorrow m[1] += 40; }; diff --git a/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.stderr b/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.stderr index 228682caad7..2a350f30331 100644 --- a/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.stderr +++ b/src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/arrays-completely-captured.rs:9:17 + --> $DIR/arrays-completely-captured.rs:11:17 | LL | let mut c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing m[] -> MutBorrow - --> $DIR/arrays-completely-captured.rs:12:9 +error: First Pass analysis includes: + --> $DIR/arrays-completely-captured.rs:14:5 + | +LL | / || { +LL | | +LL | | +LL | | m[0] += 10; +... | +LL | | m[1] += 40; +LL | | }; + | |_____^ + | +note: Capturing m[] -> MutBorrow + --> $DIR/arrays-completely-captured.rs:17:9 | LL | m[0] += 10; | ^ -error: Min Capture m[] -> MutBorrow - --> $DIR/arrays-completely-captured.rs:12:9 +error: Min Capture analysis includes: + --> $DIR/arrays-completely-captured.rs:14:5 + | +LL | / || { +LL | | +LL | | +LL | | m[0] += 10; +... | +LL | | m[1] += 40; +LL | | }; + | |_____^ + | +note: Min Capture m[] -> MutBorrow + --> $DIR/arrays-completely-captured.rs:17:9 | LL | m[0] += 10; | ^ 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 b50c2d66d94..ba495508537 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 @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] struct Point { @@ -14,10 +16,13 @@ fn main() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: println!("{}", p.x); - //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow + //~| NOTE: 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-struct.stderr b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.stderr index 41e641f3564..5fac6963afd 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.stderr +++ b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/capture-disjoint-field-struct.rs:15:13 + --> $DIR/capture-disjoint-field-struct.rs:17:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing p[(0, 0)] -> ImmBorrow - --> $DIR/capture-disjoint-field-struct.rs:18:24 +error: First Pass analysis includes: + --> $DIR/capture-disjoint-field-struct.rs:20:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", p.x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Capturing p[(0, 0)] -> ImmBorrow + --> $DIR/capture-disjoint-field-struct.rs:23:24 | LL | println!("{}", p.x); | ^^^ -error: Min Capture p[(0, 0)] -> ImmBorrow - --> $DIR/capture-disjoint-field-struct.rs:18:24 +error: Min Capture analysis includes: + --> $DIR/capture-disjoint-field-struct.rs:20:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", p.x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture p[(0, 0)] -> ImmBorrow + --> $DIR/capture-disjoint-field-struct.rs:23:24 | LL | println!("{}", p.x); | ^^^ 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 99095c71986..c1693fbad79 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 @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] fn main() { @@ -9,10 +11,13 @@ fn main() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: println!("{}", t.0); - //~^ ERROR: Capturing t[(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture t[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing t[(0, 0)] -> ImmBorrow + //~| NOTE: 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/capture-disjoint-field-tuple.stderr b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.stderr index 47470bb9646..1bfd63f2ace 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.stderr +++ b/src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-tuple.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/capture-disjoint-field-tuple.rs:10:13 + --> $DIR/capture-disjoint-field-tuple.rs:12:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing t[(0, 0)] -> ImmBorrow - --> $DIR/capture-disjoint-field-tuple.rs:13:24 +error: First Pass analysis includes: + --> $DIR/capture-disjoint-field-tuple.rs:15:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", t.0); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Capturing t[(0, 0)] -> ImmBorrow + --> $DIR/capture-disjoint-field-tuple.rs:18:24 | LL | println!("{}", t.0); | ^^^ -error: Min Capture t[(0, 0)] -> ImmBorrow - --> $DIR/capture-disjoint-field-tuple.rs:13:24 +error: Min Capture analysis includes: + --> $DIR/capture-disjoint-field-tuple.rs:15:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", t.0); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture t[(0, 0)] -> ImmBorrow + --> $DIR/capture-disjoint-field-tuple.rs:18:24 | LL | println!("{}", t.0); | ^^^ diff --git a/src/test/ui/closures/2229_closure_analysis/capture-enums.rs b/src/test/ui/closures/2229_closure_analysis/capture-enums.rs index 175fd790124..8fb2f7f16d6 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-enums.rs +++ b/src/test/ui/closures/2229_closure_analysis/capture-enums.rs @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] enum Info { @@ -15,18 +17,21 @@ fn multi_variant_enum() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: if let Info::Point(_, _, str) = point { - //~^ Capturing point[] -> ImmBorrow - //~| Capturing point[(2, 0)] -> ByValue - //~| Min Capture point[] -> ByValue + //~^ NOTE: Capturing point[] -> ImmBorrow + //~| NOTE: Capturing point[(2, 0)] -> ByValue + //~| NOTE: Min Capture point[] -> ByValue println!("{}", str); } if let Info::Meta(_, v) = meta { - //~^ Capturing meta[] -> ImmBorrow - //~| Capturing meta[(1, 1)] -> ByValue - //~| Min Capture meta[] -> ByValue + //~^ NOTE: Capturing meta[] -> ImmBorrow + //~| NOTE: Capturing meta[(1, 1)] -> ByValue + //~| NOTE: Min Capture meta[] -> ByValue println!("{:?}", v); } }; @@ -43,10 +48,13 @@ fn single_variant_enum() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { - let SingleVariant::Point(_, _, str) = point; - //~^ Capturing point[(2, 0)] -> ByValue - //~| Min Capture point[(2, 0)] -> ByValue + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: + let SingleVariant::Point(_, _, str) = point; + //~^ NOTE: Capturing point[(2, 0)] -> ByValue + //~| NOTE: Min Capture point[(2, 0)] -> ByValue println!("{}", str); }; diff --git a/src/test/ui/closures/2229_closure_analysis/capture-enums.stderr b/src/test/ui/closures/2229_closure_analysis/capture-enums.stderr index 76a2de2faf9..ebe1dcb9884 100644 --- a/src/test/ui/closures/2229_closure_analysis/capture-enums.stderr +++ b/src/test/ui/closures/2229_closure_analysis/capture-enums.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/capture-enums.rs:16:13 + --> $DIR/capture-enums.rs:18:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/capture-enums.rs:44:13 + --> $DIR/capture-enums.rs:49:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,54 +25,98 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing point[] -> ImmBorrow - --> $DIR/capture-enums.rs:19:41 +error: First Pass analysis includes: + --> $DIR/capture-enums.rs:21:5 + | +LL | / || { +LL | | +LL | | +LL | | if let Info::Point(_, _, str) = point { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Capturing point[] -> ImmBorrow + --> $DIR/capture-enums.rs:24:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ - -error: Capturing point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:19:41 +note: Capturing point[(2, 0)] -> ByValue + --> $DIR/capture-enums.rs:24:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ - -error: Capturing meta[] -> ImmBorrow - --> $DIR/capture-enums.rs:26:35 +note: Capturing meta[] -> ImmBorrow + --> $DIR/capture-enums.rs:31:35 + | +LL | if let Info::Meta(_, v) = meta { + | ^^^^ +note: Capturing meta[(1, 1)] -> ByValue + --> $DIR/capture-enums.rs:31:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ -error: Capturing meta[(1, 1)] -> ByValue - --> $DIR/capture-enums.rs:26:35 +error: Min Capture analysis includes: + --> $DIR/capture-enums.rs:21:5 | -LL | if let Info::Meta(_, v) = meta { - | ^^^^ - -error: Min Capture point[] -> ByValue - --> $DIR/capture-enums.rs:19:41 +LL | / || { +LL | | +LL | | +LL | | if let Info::Point(_, _, str) = point { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Min Capture point[] -> ByValue + --> $DIR/capture-enums.rs:24:41 | LL | if let Info::Point(_, _, str) = point { | ^^^^^ - -error: Min Capture meta[] -> ByValue - --> $DIR/capture-enums.rs:26:35 +note: Min Capture meta[] -> ByValue + --> $DIR/capture-enums.rs:31:35 | LL | if let Info::Meta(_, v) = meta { | ^^^^ -error: Capturing point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:47:43 +error: First Pass analysis includes: + --> $DIR/capture-enums.rs:52:5 | -LL | let SingleVariant::Point(_, _, str) = point; - | ^^^^^ - -error: Min Capture point[(2, 0)] -> ByValue - --> $DIR/capture-enums.rs:47:43 +LL | / || { +LL | | +LL | | +LL | | let SingleVariant::Point(_, _, str) = point; +... | +LL | | println!("{}", str); +LL | | }; + | |_____^ | -LL | let SingleVariant::Point(_, _, str) = point; - | ^^^^^ +note: Capturing point[(2, 0)] -> ByValue + --> $DIR/capture-enums.rs:55:47 + | +LL | let SingleVariant::Point(_, _, str) = point; + | ^^^^^ -error: aborting due to 10 previous errors; 1 warning emitted +error: Min Capture analysis includes: + --> $DIR/capture-enums.rs:52:5 + | +LL | / || { +LL | | +LL | | +LL | | let SingleVariant::Point(_, _, str) = point; +... | +LL | | println!("{}", str); +LL | | }; + | |_____^ + | +note: Min Capture point[(2, 0)] -> ByValue + --> $DIR/capture-enums.rs:55:47 + | +LL | let SingleVariant::Point(_, _, str) = point; + | ^^^^^ + +error: aborting due to 6 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. 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 eef8fd6e557..080ca0405b4 100644 --- a/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs +++ b/src/test/ui/closures/2229_closure_analysis/destructure_patterns.rs @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] // Test to ensure Index projections are handled properly during capture analysis @@ -9,10 +11,13 @@ fn arrays() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: let [a, b, .., e] = arr; - //~^ ERROR: Capturing arr[Index] -> ByValue - //~| ERROR: Min Capture arr[] -> ByValue + //~^ NOTE: Capturing arr[Index] -> ByValue + //~| NOTE: Min Capture arr[] -> ByValue assert_eq!(a, "A"); assert_eq!(b, "B"); assert_eq!(e, "E"); @@ -32,12 +37,15 @@ fn structs() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: 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 + //~^ NOTE: Capturing p[(0, 0)] -> MutBorrow + //~| NOTE: Capturing p[(2, 0)] -> ByValue + //~| NOTE: Min Capture p[(0, 0)] -> MutBorrow + //~| NOTE: Min Capture p[(2, 0)] -> ByValue println!("{}, {}", x, moved_id); }; @@ -49,14 +57,17 @@ fn tuples() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: 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 + //~^ NOTE: Capturing t[(0, 0)] -> MutBorrow + //~| NOTE: Capturing t[(1, 0)] -> ImmBorrow + //~| NOTE: Capturing t[(2, 0),(0, 0)] -> ByValue + //~| NOTE: Min Capture t[(0, 0)] -> MutBorrow + //~| NOTE: Min Capture t[(1, 0)] -> ImmBorrow + //~| NOTE: Min Capture t[(2, 0),(0, 0)] -> ByValue println!("{}, {} {}", x, ref_str, moved_s); }; diff --git a/src/test/ui/closures/2229_closure_analysis/destructure_patterns.stderr b/src/test/ui/closures/2229_closure_analysis/destructure_patterns.stderr index 388cfd3da92..06ccc2d7a88 100644 --- a/src/test/ui/closures/2229_closure_analysis/destructure_patterns.stderr +++ b/src/test/ui/closures/2229_closure_analysis/destructure_patterns.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/destructure_patterns.rs:10:13 + --> $DIR/destructure_patterns.rs:12:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/destructure_patterns.rs:33:13 + --> $DIR/destructure_patterns.rs:38:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/destructure_patterns.rs:50:13 + --> $DIR/destructure_patterns.rs:58:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,78 +34,144 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing arr[Index] -> ByValue - --> $DIR/destructure_patterns.rs:13:29 +error: First Pass analysis includes: + --> $DIR/destructure_patterns.rs:15:5 + | +LL | / || { +LL | | +LL | | +LL | | let [a, b, .., e] = arr; +... | +LL | | assert_eq!(e, "E"); +LL | | }; + | |_____^ + | +note: Capturing arr[Index] -> ByValue + --> $DIR/destructure_patterns.rs:18:29 | LL | let [a, b, .., e] = arr; | ^^^ -error: Min Capture arr[] -> ByValue - --> $DIR/destructure_patterns.rs:13:29 +error: Min Capture analysis includes: + --> $DIR/destructure_patterns.rs:15:5 + | +LL | / || { +LL | | +LL | | +LL | | let [a, b, .., e] = arr; +... | +LL | | assert_eq!(e, "E"); +LL | | }; + | |_____^ + | +note: Min Capture arr[] -> ByValue + --> $DIR/destructure_patterns.rs:18:29 | LL | let [a, b, .., e] = arr; | ^^^ -error: Capturing p[(0, 0)] -> MutBorrow - --> $DIR/destructure_patterns.rs:36:58 +error: First Pass analysis includes: + --> $DIR/destructure_patterns.rs:41:5 + | +LL | / || { +LL | | +LL | | +LL | | let Point { x: ref mut x, y: _, id: moved_id } = p; +... | +LL | | println!("{}, {}", x, moved_id); +LL | | }; + | |_____^ + | +note: Capturing p[(0, 0)] -> MutBorrow + --> $DIR/destructure_patterns.rs:44:58 + | +LL | let Point { x: ref mut x, y: _, id: moved_id } = p; + | ^ +note: Capturing p[(2, 0)] -> ByValue + --> $DIR/destructure_patterns.rs:44:58 | LL | let Point { x: ref mut x, y: _, id: moved_id } = p; | ^ -error: Capturing p[(2, 0)] -> ByValue - --> $DIR/destructure_patterns.rs:36:58 +error: Min Capture analysis includes: + --> $DIR/destructure_patterns.rs:41:5 + | +LL | / || { +LL | | +LL | | +LL | | let Point { x: ref mut x, y: _, id: moved_id } = p; +... | +LL | | println!("{}, {}", x, moved_id); +LL | | }; + | |_____^ + | +note: Min Capture p[(0, 0)] -> MutBorrow + --> $DIR/destructure_patterns.rs:44:58 + | +LL | let Point { x: ref mut x, y: _, id: moved_id } = p; + | ^ +note: Min Capture p[(2, 0)] -> ByValue + --> $DIR/destructure_patterns.rs:44:58 | LL | let Point { x: ref mut x, y: _, id: moved_id } = p; | ^ -error: Min Capture p[(0, 0)] -> MutBorrow - --> $DIR/destructure_patterns.rs:36:58 +error: First Pass analysis includes: + --> $DIR/destructure_patterns.rs:61:5 | -LL | let Point { x: ref mut x, y: _, id: moved_id } = p; - | ^ - -error: Min Capture p[(2, 0)] -> ByValue - --> $DIR/destructure_patterns.rs:36:58 +LL | / || { +LL | | +LL | | +LL | | let (ref mut x, ref ref_str, (moved_s, _)) = t; +... | +LL | | println!("{}, {} {}", x, ref_str, moved_s); +LL | | }; + | |_____^ | -LL | let Point { x: ref mut x, y: _, id: moved_id } = p; - | ^ - -error: Capturing t[(0, 0)] -> MutBorrow - --> $DIR/destructure_patterns.rs:53:54 +note: Capturing t[(0, 0)] -> MutBorrow + --> $DIR/destructure_patterns.rs:64:54 + | +LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; + | ^ +note: Capturing t[(1, 0)] -> ImmBorrow + --> $DIR/destructure_patterns.rs:64:54 + | +LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; + | ^ +note: Capturing t[(2, 0),(0, 0)] -> ByValue + --> $DIR/destructure_patterns.rs:64:54 | LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; | ^ -error: Capturing t[(1, 0)] -> ImmBorrow - --> $DIR/destructure_patterns.rs:53:54 +error: Min Capture analysis includes: + --> $DIR/destructure_patterns.rs:61:5 + | +LL | / || { +LL | | +LL | | +LL | | let (ref mut x, ref ref_str, (moved_s, _)) = t; +... | +LL | | println!("{}, {} {}", x, ref_str, moved_s); +LL | | }; + | |_____^ + | +note: Min Capture t[(0, 0)] -> MutBorrow + --> $DIR/destructure_patterns.rs:64:54 + | +LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; + | ^ +note: Min Capture t[(1, 0)] -> ImmBorrow + --> $DIR/destructure_patterns.rs:64:54 + | +LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; + | ^ +note: Min Capture t[(2, 0),(0, 0)] -> ByValue + --> $DIR/destructure_patterns.rs:64:54 | LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; | ^ -error: Capturing t[(2, 0),(0, 0)] -> ByValue - --> $DIR/destructure_patterns.rs:53:54 - | -LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; - | ^ - -error: Min Capture t[(0, 0)] -> MutBorrow - --> $DIR/destructure_patterns.rs:53:54 - | -LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; - | ^ - -error: Min Capture t[(1, 0)] -> ImmBorrow - --> $DIR/destructure_patterns.rs:53:54 - | -LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; - | ^ - -error: Min Capture t[(2, 0),(0, 0)] -> ByValue - --> $DIR/destructure_patterns.rs:53:54 - | -LL | let (ref mut x, ref ref_str, (moved_s, _)) = t; - | ^ - -error: aborting due to 15 previous errors; 1 warning emitted +error: aborting due to 9 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. 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 ee55e3a3f21..a3222635b62 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 @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] fn main() { @@ -7,9 +9,12 @@ fn main() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: println!("This uses new capture analyysis to capture s={}", s); - //~^ ERROR: Capturing s[] -> ImmBorrow - //~| ERROR: Min Capture s[] -> ImmBorrow + //~^ NOTE: Capturing s[] -> ImmBorrow + //~| NOTE: Min Capture s[] -> ImmBorrow }; } diff --git a/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.stderr b/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.stderr index 6d4d7ee5fbe..a031360ed34 100644 --- a/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.stderr +++ b/src/test/ui/closures/2229_closure_analysis/feature-gate-capture_disjoint_fields.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/feature-gate-capture_disjoint_fields.rs:8:13 + --> $DIR/feature-gate-capture_disjoint_fields.rs:10:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing s[] -> ImmBorrow - --> $DIR/feature-gate-capture_disjoint_fields.rs:11:69 +error: First Pass analysis includes: + --> $DIR/feature-gate-capture_disjoint_fields.rs:13:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("This uses new capture analyysis to capture s={}", s); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Capturing s[] -> ImmBorrow + --> $DIR/feature-gate-capture_disjoint_fields.rs:16:69 | LL | println!("This uses new capture analyysis to capture s={}", s); | ^ -error: Min Capture s[] -> ImmBorrow - --> $DIR/feature-gate-capture_disjoint_fields.rs:11:69 +error: Min Capture analysis includes: + --> $DIR/feature-gate-capture_disjoint_fields.rs:13:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("This uses new capture analyysis to capture s={}", s); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture s[] -> ImmBorrow + --> $DIR/feature-gate-capture_disjoint_fields.rs:16:69 | LL | println!("This uses new capture analyysis to capture s={}", s); | ^ 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 d526934271c..9466e103897 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 @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ warning the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] struct Filter { @@ -24,8 +26,10 @@ impl Data { self.list.retain( #[rustc_capture_analysis] |v| self.filter.allowed(*v), - //~^ ERROR: Capturing self[Deref,(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture self[Deref,(0, 0)] -> ImmBorrow + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: + //~| NOTE: Capturing self[Deref,(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture self[Deref,(0, 0)] -> ImmBorrow ); } } diff --git a/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.stderr b/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.stderr index 452ba5c6545..e9420fe5a0c 100644 --- a/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.stderr +++ b/src/test/ui/closures/2229_closure_analysis/filter-on-struct-member.stderr @@ -7,14 +7,26 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing self[Deref,(0, 0)] -> ImmBorrow - --> $DIR/filter-on-struct-member.rs:26:17 +error: First Pass analysis includes: + --> $DIR/filter-on-struct-member.rs:28:13 + | +LL | |v| self.filter.allowed(*v), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Capturing self[Deref,(0, 0)] -> ImmBorrow + --> $DIR/filter-on-struct-member.rs:28:17 | LL | |v| self.filter.allowed(*v), | ^^^^^^^^^^^ -error: Min Capture self[Deref,(0, 0)] -> ImmBorrow - --> $DIR/filter-on-struct-member.rs:26:17 +error: Min Capture analysis includes: + --> $DIR/filter-on-struct-member.rs:28:13 + | +LL | |v| self.filter.allowed(*v), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Min Capture self[Deref,(0, 0)] -> ImmBorrow + --> $DIR/filter-on-struct-member.rs:28:17 | LL | |v| self.filter.allowed(*v), | ^^^^^^^^^^^ 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 08c9aa8eff8..7d2d4c104d4 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 @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ warning the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] #![allow(unused)] @@ -21,10 +23,13 @@ fn main() { // Note that `wp.x` doesn't start off a variable defined outside the closure. let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: let wp = &w.p; - //~^ ERROR: Capturing w[(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture w[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing w[(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture w[(0, 0)] -> ImmBorrow println!("{}", wp.x); }; diff --git a/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.stderr b/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.stderr index e8368201ede..1c8db7952af 100644 --- a/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.stderr +++ b/src/test/ui/closures/2229_closure_analysis/multilevel-path-1.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/multilevel-path-1.rs:22:13 + --> $DIR/multilevel-path-1.rs:24:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing w[(0, 0)] -> ImmBorrow - --> $DIR/multilevel-path-1.rs:25:19 +error: First Pass analysis includes: + --> $DIR/multilevel-path-1.rs:27:5 + | +LL | / || { +LL | | +LL | | +LL | | let wp = &w.p; +... | +LL | | println!("{}", wp.x); +LL | | }; + | |_____^ + | +note: Capturing w[(0, 0)] -> ImmBorrow + --> $DIR/multilevel-path-1.rs:30:19 | LL | let wp = &w.p; | ^^^ -error: Min Capture w[(0, 0)] -> ImmBorrow - --> $DIR/multilevel-path-1.rs:25:19 +error: Min Capture analysis includes: + --> $DIR/multilevel-path-1.rs:27:5 + | +LL | / || { +LL | | +LL | | +LL | | let wp = &w.p; +... | +LL | | println!("{}", wp.x); +LL | | }; + | |_____^ + | +note: Min Capture w[(0, 0)] -> ImmBorrow + --> $DIR/multilevel-path-1.rs:30:19 | LL | let wp = &w.p; | ^^^ 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 020753a71bf..540e70138e5 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 @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ warning the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] #![allow(unused)] @@ -18,10 +20,13 @@ fn main() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: println!("{}", w.p.x); - //~^ ERROR: Capturing w[(0, 0),(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing w[(0, 0),(0, 0)] -> ImmBorrow + //~| NOTE: 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/multilevel-path-2.stderr b/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.stderr index dfcd2c7a088..37287f6b3bc 100644 --- a/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.stderr +++ b/src/test/ui/closures/2229_closure_analysis/multilevel-path-2.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/multilevel-path-2.rs:19:13 + --> $DIR/multilevel-path-2.rs:21:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing w[(0, 0),(0, 0)] -> ImmBorrow - --> $DIR/multilevel-path-2.rs:22:24 +error: First Pass analysis includes: + --> $DIR/multilevel-path-2.rs:24:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", w.p.x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Capturing w[(0, 0),(0, 0)] -> ImmBorrow + --> $DIR/multilevel-path-2.rs:27:24 | LL | println!("{}", w.p.x); | ^^^^^ -error: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow - --> $DIR/multilevel-path-2.rs:22:24 +error: Min Capture analysis includes: + --> $DIR/multilevel-path-2.rs:24:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", w.p.x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow + --> $DIR/multilevel-path-2.rs:27:24 | LL | println!("{}", w.p.x); | ^^^^^ 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 d2e99fe4acc..88620550f2e 100644 --- a/src/test/ui/closures/2229_closure_analysis/nested-closure.rs +++ b/src/test/ui/closures/2229_closure_analysis/nested-closure.rs @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ warning the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] struct Point { @@ -20,20 +22,26 @@ fn main() { let mut c1 = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: println!("{}", p.x); - //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture p[(0, 0)] -> ImmBorrow let incr = 10; let mut c2 = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || 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: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: + //~| NOTE: Capturing p[(1, 0)] -> MutBorrow + //~| NOTE: Capturing incr[] -> ImmBorrow + //~| NOTE: Min Capture p[(1, 0)] -> MutBorrow + //~| NOTE: Min Capture incr[] -> ImmBorrow + //~| NOTE: Capturing p[(1, 0)] -> MutBorrow + //~| NOTE: Min Capture p[(1, 0)] -> MutBorrow c2(); println!("{}", p.y); }; diff --git a/src/test/ui/closures/2229_closure_analysis/nested-closure.stderr b/src/test/ui/closures/2229_closure_analysis/nested-closure.stderr index 2368a450bc6..21147be3f1d 100644 --- a/src/test/ui/closures/2229_closure_analysis/nested-closure.stderr +++ b/src/test/ui/closures/2229_closure_analysis/nested-closure.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/nested-closure.rs:21:18 + --> $DIR/nested-closure.rs:23:18 | LL | let mut c1 = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let mut c1 = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/nested-closure.rs:28:22 + --> $DIR/nested-closure.rs:33:22 | LL | let mut c2 = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,54 +25,86 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing p[(1, 0)] -> MutBorrow - --> $DIR/nested-closure.rs:30:12 +error: First Pass analysis includes: + --> $DIR/nested-closure.rs:36:9 + | +LL | || p.y += incr; + | ^^^^^^^^^^^^^^ + | +note: Capturing p[(1, 0)] -> MutBorrow + --> $DIR/nested-closure.rs:36:12 | LL | || p.y += incr; | ^^^ - -error: Capturing incr[] -> ImmBorrow - --> $DIR/nested-closure.rs:30:19 +note: Capturing incr[] -> ImmBorrow + --> $DIR/nested-closure.rs:36:19 | LL | || p.y += incr; | ^^^^ -error: Min Capture p[(1, 0)] -> MutBorrow - --> $DIR/nested-closure.rs:30:12 +error: Min Capture analysis includes: + --> $DIR/nested-closure.rs:36:9 + | +LL | || p.y += incr; + | ^^^^^^^^^^^^^^ + | +note: Min Capture p[(1, 0)] -> MutBorrow + --> $DIR/nested-closure.rs:36:12 | LL | || p.y += incr; | ^^^ - -error: Min Capture incr[] -> ImmBorrow - --> $DIR/nested-closure.rs:30:19 +note: Min Capture incr[] -> ImmBorrow + --> $DIR/nested-closure.rs:36:19 | LL | || p.y += incr; | ^^^^ -error: Capturing p[(0, 0)] -> ImmBorrow - --> $DIR/nested-closure.rs:24:24 +error: First Pass analysis includes: + --> $DIR/nested-closure.rs:26:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", p.x); +... | +LL | | println!("{}", p.y); +LL | | }; + | |_____^ + | +note: Capturing p[(0, 0)] -> ImmBorrow + --> $DIR/nested-closure.rs:29:24 | LL | println!("{}", p.x); | ^^^ - -error: Capturing p[(1, 0)] -> MutBorrow - --> $DIR/nested-closure.rs:30:12 +note: Capturing p[(1, 0)] -> MutBorrow + --> $DIR/nested-closure.rs:36:12 | LL | || p.y += incr; | ^^^ -error: Min Capture p[(0, 0)] -> ImmBorrow - --> $DIR/nested-closure.rs:24:24 +error: Min Capture analysis includes: + --> $DIR/nested-closure.rs:26:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", p.x); +... | +LL | | println!("{}", p.y); +LL | | }; + | |_____^ + | +note: Min Capture p[(0, 0)] -> ImmBorrow + --> $DIR/nested-closure.rs:29:24 | LL | println!("{}", p.x); | ^^^ - -error: Min Capture p[(1, 0)] -> MutBorrow - --> $DIR/nested-closure.rs:30:12 +note: Min Capture p[(1, 0)] -> MutBorrow + --> $DIR/nested-closure.rs:36:12 | LL | || p.y += incr; | ^^^ -error: aborting due to 10 previous errors; 1 warning emitted +error: aborting due to 6 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. 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 4a42970137f..16acd2f3206 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 @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] struct Point { @@ -22,9 +24,12 @@ fn main() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: println!("{}", pent.points[5].x); - //~^ ERROR: Capturing pent[(0, 0)] -> ImmBorrow - //~| ERROR: Min Capture pent[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing pent[(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture pent[(0, 0)] -> ImmBorrow }; } diff --git a/src/test/ui/closures/2229_closure_analysis/path-with-array-access.stderr b/src/test/ui/closures/2229_closure_analysis/path-with-array-access.stderr index 7507e550ade..3c8d07ed9ba 100644 --- a/src/test/ui/closures/2229_closure_analysis/path-with-array-access.stderr +++ b/src/test/ui/closures/2229_closure_analysis/path-with-array-access.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/path-with-array-access.rs:23:13 + --> $DIR/path-with-array-access.rs:25:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,14 +16,38 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing pent[(0, 0)] -> ImmBorrow - --> $DIR/path-with-array-access.rs:26:24 +error: First Pass analysis includes: + --> $DIR/path-with-array-access.rs:28:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", pent.points[5].x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Capturing pent[(0, 0)] -> ImmBorrow + --> $DIR/path-with-array-access.rs:31:24 | LL | println!("{}", pent.points[5].x); | ^^^^^^^^^^^ -error: Min Capture pent[(0, 0)] -> ImmBorrow - --> $DIR/path-with-array-access.rs:26:24 +error: Min Capture analysis includes: + --> $DIR/path-with-array-access.rs:28:5 + | +LL | / || { +LL | | +LL | | +LL | | println!("{}", pent.points[5].x); +LL | | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture pent[(0, 0)] -> ImmBorrow + --> $DIR/path-with-array-access.rs:31:24 | LL | println!("{}", pent.points[5].x); | ^^^^^^^^^^^ 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 68c18eac804..aaff3531e58 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 @@ -1,7 +1,9 @@ // FIXME(arora-aman) add run-pass once 2229 is implemented #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] // Test to ensure that min analysis meets capture kind for all paths captured. @@ -24,12 +26,15 @@ fn main() { // let mut c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: p.x += 10; - //~^ ERROR: Capturing p[(0, 0)] -> MutBorrow - //~| ERROR: Min Capture p[] -> MutBorrow + //~^ NOTE: Capturing p[(0, 0)] -> MutBorrow + //~| NOTE: Min Capture p[] -> MutBorrow println!("{:?}", p); - //~^ ERROR: Capturing p[] -> ImmBorrow + //~^ NOTE: Capturing p[] -> ImmBorrow }; c(); diff --git a/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.stderr b/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.stderr index 53cc681969a..30d3d5f504e 100644 --- a/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.stderr +++ b/src/test/ui/closures/2229_closure_analysis/simple-struct-min-capture.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/simple-struct-min-capture.rs:25:17 + --> $DIR/simple-struct-min-capture.rs:27:17 | LL | let mut c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,24 +16,47 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing p[(0, 0)] -> MutBorrow - --> $DIR/simple-struct-min-capture.rs:28:9 +error: First Pass analysis includes: + --> $DIR/simple-struct-min-capture.rs:30:5 + | +LL | / || { +LL | | +LL | | +LL | | p.x += 10; +... | +LL | | +LL | | }; + | |_____^ + | +note: Capturing p[(0, 0)] -> MutBorrow + --> $DIR/simple-struct-min-capture.rs:33:9 | LL | p.x += 10; | ^^^ - -error: Capturing p[] -> ImmBorrow - --> $DIR/simple-struct-min-capture.rs:31:26 +note: Capturing p[] -> ImmBorrow + --> $DIR/simple-struct-min-capture.rs:36:26 | LL | println!("{:?}", p); | ^ -error: Min Capture p[] -> MutBorrow - --> $DIR/simple-struct-min-capture.rs:28:9 +error: Min Capture analysis includes: + --> $DIR/simple-struct-min-capture.rs:30:5 + | +LL | / || { +LL | | +LL | | +LL | | p.x += 10; +... | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture p[] -> MutBorrow + --> $DIR/simple-struct-min-capture.rs:33:9 | LL | p.x += 10; | ^^^ -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 3 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. 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 889836c11ce..90b8033d074 100644 --- a/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs +++ b/src/test/ui/closures/2229_closure_analysis/wild_patterns.rs @@ -1,5 +1,7 @@ #![feature(capture_disjoint_fields)] -//~^ WARNING the feature `capture_disjoint_fields` is incomplete +//~^ WARNING: the feature `capture_disjoint_fields` is incomplete +//~| NOTE: `#[warn(incomplete_features)]` on by default +//~| NOTE: see issue #53488 #![feature(rustc_attrs)] // Test to ensure that we can handle cases where @@ -7,7 +9,9 @@ // using a Place expression // // Note: Currently when feature `capture_disjoint_fields` is enabled -// we can't handle such cases. So the test so the test +// we can't handle such cases. So the test current use `_x` instead of +// `_` until the issue is resolved. +// Check rust-lang/project-rfc-2229#24 for status. struct Point { x: i32, @@ -19,11 +23,14 @@ fn wild_struct() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: // 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 + //~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture p[(0, 0)] -> ImmBorrow }; c(); @@ -34,11 +41,14 @@ fn wild_tuple() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: // FIXME(arora-aman): Change `_x` to `_` let (_x, _) = t; - //~^ ERROR: Capturing t[(0, 0)] -> ByValue - //~| ERROR: Min Capture t[(0, 0)] -> ByValue + //~^ NOTE: Capturing t[(0, 0)] -> ByValue + //~| NOTE: Min Capture t[(0, 0)] -> ByValue }; c(); @@ -49,11 +59,14 @@ fn wild_arr() { let c = #[rustc_capture_analysis] //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 || { + //~^ ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: // FIXME(arora-aman): Change `_x` to `_` let [_x, _] = arr; - //~^ ERROR: Capturing arr[Index] -> ByValue - //~| ERROR: Min Capture arr[] -> ByValue + //~^ NOTE: Capturing arr[Index] -> ByValue + //~| NOTE: Min Capture arr[] -> ByValue }; c(); diff --git a/src/test/ui/closures/2229_closure_analysis/wild_patterns.stderr b/src/test/ui/closures/2229_closure_analysis/wild_patterns.stderr index 621c8aeb790..36be8431be5 100644 --- a/src/test/ui/closures/2229_closure_analysis/wild_patterns.stderr +++ b/src/test/ui/closures/2229_closure_analysis/wild_patterns.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/wild_patterns.rs:20:13 + --> $DIR/wild_patterns.rs:24:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/wild_patterns.rs:35:13 + --> $DIR/wild_patterns.rs:42:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental - --> $DIR/wild_patterns.rs:50:13 + --> $DIR/wild_patterns.rs:60:13 | LL | let c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,38 +34,110 @@ LL | #![feature(capture_disjoint_fields)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #53488 for more information -error: Capturing p[(0, 0)] -> ImmBorrow - --> $DIR/wild_patterns.rs:24:37 +error: First Pass analysis includes: + --> $DIR/wild_patterns.rs:27:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Capturing p[(0, 0)] -> ImmBorrow + --> $DIR/wild_patterns.rs:31:37 | LL | let Point { x: _x, y: _ } = p; | ^ -error: Min Capture p[(0, 0)] -> ImmBorrow - --> $DIR/wild_patterns.rs:24:37 +error: Min Capture analysis includes: + --> $DIR/wild_patterns.rs:27:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture p[(0, 0)] -> ImmBorrow + --> $DIR/wild_patterns.rs:31:37 | LL | let Point { x: _x, y: _ } = p; | ^ -error: Capturing t[(0, 0)] -> ByValue - --> $DIR/wild_patterns.rs:39:23 +error: First Pass analysis includes: + --> $DIR/wild_patterns.rs:45:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Capturing t[(0, 0)] -> ByValue + --> $DIR/wild_patterns.rs:49:23 | LL | let (_x, _) = t; | ^ -error: Min Capture t[(0, 0)] -> ByValue - --> $DIR/wild_patterns.rs:39:23 +error: Min Capture analysis includes: + --> $DIR/wild_patterns.rs:45:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture t[(0, 0)] -> ByValue + --> $DIR/wild_patterns.rs:49:23 | LL | let (_x, _) = t; | ^ -error: Capturing arr[Index] -> ByValue - --> $DIR/wild_patterns.rs:54:23 +error: First Pass analysis includes: + --> $DIR/wild_patterns.rs:63:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Capturing arr[Index] -> ByValue + --> $DIR/wild_patterns.rs:67:23 | LL | let [_x, _] = arr; | ^^^ -error: Min Capture arr[] -> ByValue - --> $DIR/wild_patterns.rs:54:23 +error: Min Capture analysis includes: + --> $DIR/wild_patterns.rs:63:5 + | +LL | / || { +LL | | +LL | | +LL | | // FIXME(arora-aman): Change `_x` to `_` +... | +LL | | +LL | | }; + | |_____^ + | +note: Min Capture arr[] -> ByValue + --> $DIR/wild_patterns.rs:67:23 | LL | let [_x, _] = arr; | ^^^