Reduce verbosity of capture analysis logs

Co-authored-by: Jenny Wills <wills.jenniferg@gmail.com>
Co-authored-by: Aman Arora <me@aman-arora.com>
This commit is contained in:
Roxane Fruytier 2020-10-27 23:41:52 -04:00 committed by Aman Arora
parent b16815b58d
commit 825e9e45d1
34 changed files with 297 additions and 909 deletions

View file

@ -46,22 +46,6 @@ use rustc_span::{Span, Symbol};
use std::env; use std::env;
macro_rules! log_capture_analysis {
($fcx:expr, $closure_def_id:expr, $fmt:literal) => {
if $fcx.should_log_capture_analysis($closure_def_id) {
print!("For closure={:?}: ", $closure_def_id);
println!($fmt);
}
};
($fcx:expr, $closure_def_id:expr, $fmt:literal, $($args:expr),*) => {
if $fcx.should_log_capture_analysis($closure_def_id) {
print!("For closure={:?}: ", $closure_def_id);
println!($fmt, $($args),*);
}
};
}
/// Describe the relationship between the paths of two places /// Describe the relationship between the paths of two places
/// eg: /// eg:
/// - foo is ancestor of foo.bar.baz /// - foo is ancestor of foo.bar.baz
@ -144,9 +128,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default(); let mut capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default();
if self.tcx.features().capture_disjoint_fields || matches!(env::var("SG_NEW"), Ok(_)) { if self.tcx.features().capture_disjoint_fields || matches!(env::var("SG_NEW"), Ok(_)) {
log_capture_analysis!(self, closure_def_id, "Using new-style capture analysis");
} else { } else {
log_capture_analysis!(self, closure_def_id, "Using old-style capture analysis");
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
for (&var_hir_id, _) in upvars.iter() { for (&var_hir_id, _) in upvars.iter() {
let place = self.place_for_root_variable(local_def_id, var_hir_id); let place = self.place_for_root_variable(local_def_id, var_hir_id);
@ -182,12 +164,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) )
.consume_body(body); .consume_body(body);
log_capture_analysis!( debug!(
self, "For closure={:?}, capture_information={:#?}",
closure_def_id, closure_def_id, delegate.capture_information
"capture information: {:#?}",
delegate.capture_information
); );
self.log_closure_capture_info(closure_def_id, &delegate.capture_information, span);
if let Some(closure_substs) = infer_kind { if let Some(closure_substs) = infer_kind {
// Unify the (as yet unbound) type variable in the closure // Unify the (as yet unbound) type variable in the closure
@ -206,6 +187,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
self.compute_min_captures(closure_def_id, delegate); self.compute_min_captures(closure_def_id, delegate);
self.log_closure_min_capture_info(closure_def_id, span);
self.set_closure_captures(closure_def_id); self.set_closure_captures(closure_def_id);
// Now that we've analyzed the closure, we know how each // Now that we've analyzed the closure, we know how each
@ -333,10 +316,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
} }
debug!( debug!("For closure_def_id={:?}, closure_captures={:#?}", closure_def_id, closure_captures);
"For closure_def_id={:?}, set_closure_captures={:#?}",
closure_def_id, closure_captures
);
debug!( debug!(
"For closure_def_id={:?}, upvar_capture_map={:#?}", "For closure_def_id={:?}, upvar_capture_map={:#?}",
closure_def_id, upvar_capture_map closure_def_id, upvar_capture_map
@ -478,12 +458,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
log_capture_analysis!( debug!("For closure={:?}, min_captures={:#?}", closure_def_id, root_var_min_capture_list);
self,
closure_def_id,
"min_captures={:#?}",
root_var_min_capture_list
);
if !root_var_min_capture_list.is_empty() { if !root_var_min_capture_list.is_empty() {
self.typeck_results self.typeck_results
@ -581,6 +556,46 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
} }
fn log_closure_capture_info(
&self,
closure_def_id: rustc_hir::def_id::DefId,
capture_information: &FxIndexMap<Place<'tcx>, ty::CaptureInfo<'tcx>>,
closure_span: Span,
) {
if self.should_log_capture_analysis(closure_def_id) {
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);
}
}
}
fn log_closure_min_capture_info(&self, closure_def_id: DefId, closure_span: Span) {
if self.should_log_capture_analysis(closure_def_id) {
if let Some(min_captures) =
self.typeck_results.borrow().closure_min_captures.get(&closure_def_id)
{
for (_, min_captures_for_var) in min_captures {
for capture in min_captures_for_var {
let place = &capture.place;
let capture_info = &capture.info;
let capture_str =
construct_capture_info_string(self.tcx, place, capture_info);
let output_str = format!("Min Capture {}", 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);
}
}
}
}
}
} }
struct InferBorrowKind<'a, 'tcx> { struct InferBorrowKind<'a, 'tcx> {
@ -917,6 +932,37 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
} }
} }
fn construct_capture_info_string(
tcx: TyCtxt<'_>,
place: &Place<'tcx>,
capture_info: &ty::CaptureInfo<'tcx>,
) -> String {
let variable_name = match place.base {
PlaceBase::Upvar(upvar_id) => var_name(tcx, upvar_id.var_path.hir_id).to_string(),
_ => bug!("Capture_information should only contain upvars"),
};
let mut projections_str = String::new();
for (i, item) in place.projections.iter().enumerate() {
let proj = match item.kind {
ProjectionKind::Field(a, b) => format!("({:?}, {:?})", a, b),
ProjectionKind::Deref => String::from("Deref"),
ProjectionKind::Index => String::from("Index"),
ProjectionKind::Subslice => String::from("Subslice"),
};
if i != 0 {
projections_str.push_str(",");
}
projections_str.push_str(proj.as_str());
}
let capture_kind_str = match capture_info.capture_kind {
ty::UpvarCapture::ByValue(_) => "ByValue".into(),
ty::UpvarCapture::ByRef(borrow) => format!("{:?}", borrow.kind),
};
format!("{}[{}] -> {}", variable_name, projections_str, capture_kind_str)
}
fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
tcx.hir().name(var_hir_id) tcx.hir().name(var_hir_id)
} }

View file

@ -10,6 +10,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
m[0] += 10; m[0] += 10;
//~^ ERROR: Capturing m[] -> MutBorrow
//~^^ ERROR: Min Capture m[] -> MutBorrow
m[1] += 40; m[1] += 40;
}; };

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing m[] -> MutBorrow
--> $DIR/arrays-completely-captured.rs:12:9
|
LL | m[0] += 10;
| ^
error: Min Capture m[] -> MutBorrow
--> $DIR/arrays-completely-captured.rs:12:9
|
LL | m[0] += 10;
| ^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,47 +0,0 @@
For closure=DefId(0:4 ~ arrays_completely_captured[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:4 ~ arrays_completely_captured[317d]::main::{closure#0}): capture information: {
Place {
base_ty: [i32; 5],
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ arrays_completely_captured[317d]::main), local_id: 1 };`m`;DefId(0:4 ~ arrays_completely_captured[317d]::main::{closure#0})),
),
projections: [],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ arrays_completely_captured[317d]::main),
local_id: 12,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#6r),
),
},
}
For closure=DefId(0:4 ~ arrays_completely_captured[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:3 ~ arrays_completely_captured[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: [i32; 5],
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ arrays_completely_captured[317d]::main), local_id: 1 };`m`;DefId(0:4 ~ arrays_completely_captured[317d]::main::{closure#0})),
),
projections: [],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ arrays_completely_captured[317d]::main),
local_id: 12,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#6r),
),
},
},
],
}

View file

@ -16,6 +16,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("{}", p.x); println!("{}", p.x);
//~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow
}; };
// `c` should only capture `p.x`, therefore mutating `p.y` is allowed. // `c` should only capture `p.x`, therefore mutating `p.y` is allowed.

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing p[(0, 0)] -> ImmBorrow
--> $DIR/capture-disjoint-field-struct.rs:18:24
|
LL | println!("{}", p.x);
| ^^^
error: Min Capture p[(0, 0)] -> ImmBorrow
--> $DIR/capture-disjoint-field-struct.rs:18:24
|
LL | println!("{}", p.x);
| ^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,63 +0,0 @@
For closure=DefId(0:7 ~ capture_disjoint_field_struct[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:7 ~ capture_disjoint_field_struct[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ capture_disjoint_field_struct[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ capture_disjoint_field_struct[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ capture_disjoint_field_struct[317d]::main),
local_id: 31,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
}
For closure=DefId(0:7 ~ capture_disjoint_field_struct[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:6 ~ capture_disjoint_field_struct[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ capture_disjoint_field_struct[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ capture_disjoint_field_struct[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ capture_disjoint_field_struct[317d]::main),
local_id: 31,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
},
],
}

View file

@ -11,6 +11,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("{}", t.0); println!("{}", t.0);
//~^ ERROR: Capturing t[(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture t[(0, 0)] -> ImmBorrow
}; };
// `c` only captures t.0, therefore mutating t.1 is allowed. // `c` only captures t.0, therefore mutating t.1 is allowed.

View file

@ -1,5 +1,5 @@
error[E0658]: attributes on expressions are experimental error[E0658]: attributes on expressions are experimental
--> $DIR/capture-disjoint-field-tuple.rs:8:13 --> $DIR/capture-disjoint-field-tuple.rs:10:13
| |
LL | let c = #[rustc_capture_analysis] 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 = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/capture-disjoint-field-tuple.rs:1:12 --> $DIR/capture-disjoint-field-tuple.rs:3:12
| |
LL | #![feature(capture_disjoint_fields)] LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing t[(0, 0)] -> ImmBorrow
--> $DIR/capture-disjoint-field-tuple.rs:13:24
|
LL | println!("{}", t.0);
| ^^^
error: Min Capture t[(0, 0)] -> ImmBorrow
--> $DIR/capture-disjoint-field-tuple.rs:13:24
|
LL | println!("{}", t.0);
| ^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,63 +0,0 @@
For closure=DefId(0:4 ~ capture_disjoint_field_tuple[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:4 ~ capture_disjoint_field_tuple[317d]::main::{closure#0}): capture information: {
Place {
base_ty: (i32, i32),
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ capture_disjoint_field_tuple[317d]::main), local_id: 1 };`t`;DefId(0:4 ~ capture_disjoint_field_tuple[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ capture_disjoint_field_tuple[317d]::main),
local_id: 28,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
}
For closure=DefId(0:4 ~ capture_disjoint_field_tuple[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:3 ~ capture_disjoint_field_tuple[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: (i32, i32),
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ capture_disjoint_field_tuple[317d]::main), local_id: 1 };`t`;DefId(0:4 ~ capture_disjoint_field_tuple[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ capture_disjoint_field_tuple[317d]::main),
local_id: 28,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
},
],
}

View file

@ -9,5 +9,7 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("This uses new capture analyysis to capture s={}", s); println!("This uses new capture analyysis to capture s={}", s);
//~^ ERROR: Capturing s[] -> ImmBorrow
//~^^ ERROR: Min Capture s[] -> ImmBorrow
}; };
} }

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing s[] -> ImmBorrow
--> $DIR/feature-gate-capture_disjoint_fields.rs:11: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
|
LL | println!("This uses new capture analyysis to capture s={}", s);
| ^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,47 +0,0 @@
For closure=DefId(0:4 ~ feature_gate_capture_disjoint_fields[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:4 ~ feature_gate_capture_disjoint_fields[317d]::main::{closure#0}): capture information: {
Place {
base_ty: std::string::String,
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ feature_gate_capture_disjoint_fields[317d]::main), local_id: 1 };`s`;DefId(0:4 ~ feature_gate_capture_disjoint_fields[317d]::main::{closure#0})),
),
projections: [],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ feature_gate_capture_disjoint_fields[317d]::main),
local_id: 52,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#50r),
),
},
}
For closure=DefId(0:4 ~ feature_gate_capture_disjoint_fields[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:3 ~ feature_gate_capture_disjoint_fields[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: std::string::String,
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ feature_gate_capture_disjoint_fields[317d]::main), local_id: 1 };`s`;DefId(0:4 ~ feature_gate_capture_disjoint_fields[317d]::main::{closure#0})),
),
projections: [],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ feature_gate_capture_disjoint_fields[317d]::main),
local_id: 52,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#50r),
),
},
},
],
}

View file

@ -22,9 +22,10 @@ impl Data {
// The closure passed to filter only captures self.filter, // The closure passed to filter only captures self.filter,
// therefore mutating self.list is allowed. // therefore mutating self.list is allowed.
self.list.retain( self.list.retain(
//~^ cannot borrow `self.list` as mutable because it is also borrowed as immutable
#[rustc_capture_analysis] #[rustc_capture_analysis]
|v| self.filter.allowed(*v), |v| self.filter.allowed(*v),
//~^ ERROR: Capturing self[Deref,(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture self[Deref,(0, 0)] -> ImmBorrow
); );
} }
} }

View file

@ -1,5 +1,5 @@
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/filter-on-struct-member.rs:1:12 --> $DIR/filter-on-struct-member.rs:3:12
| |
LL | #![feature(capture_disjoint_fields)] LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -7,22 +7,17 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error[E0502]: cannot borrow `self.list` as mutable because it is also borrowed as immutable error: Capturing self[Deref,(0, 0)] -> ImmBorrow
--> $DIR/filter-on-struct-member.rs:22:9 --> $DIR/filter-on-struct-member.rs:26:17
| |
LL | self.list.retain( LL | |v| self.filter.allowed(*v),
| ^ ------ immutable borrow later used by call | ^^^^^^^^^^^
| _________|
| |
LL | |
LL | | #[rustc_capture_analysis]
LL | | |v| self.filter.allowed(*v),
| | --- ---- first borrow occurs due to use of `self` in closure
| | |
| | immutable borrow occurs here
LL | | );
| |_________^ mutable borrow occurs here
error: aborting due to previous error; 1 warning emitted error: Min Capture self[Deref,(0, 0)] -> ImmBorrow
--> $DIR/filter-on-struct-member.rs:26:17
|
LL | |v| self.filter.allowed(*v),
| ^^^^^^^^^^^
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0502`.

View file

@ -1,71 +0,0 @@
For closure=DefId(0:12 ~ filter_on_struct_member[317d]::{impl#1}::update::{closure#0}): Using new-style capture analysis
For closure=DefId(0:12 ~ filter_on_struct_member[317d]::{impl#1}::update::{closure#0}): capture information: {
Place {
base_ty: &mut Data,
base: Upvar(
UpvarId(HirId { owner: DefId(0:11 ~ filter_on_struct_member[317d]::{impl#1}::update), local_id: 1 };`self`;DefId(0:12 ~ filter_on_struct_member[317d]::{impl#1}::update::{closure#0})),
),
projections: [
Projection {
ty: Data,
kind: Deref,
},
Projection {
ty: Filter,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:11 ~ filter_on_struct_member[317d]::{impl#1}::update),
local_id: 13,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#7r),
),
},
}
For closure=DefId(0:12 ~ filter_on_struct_member[317d]::{impl#1}::update::{closure#0}): min_captures={
HirId {
owner: DefId(0:11 ~ filter_on_struct_member[317d]::{impl#1}::update),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: &mut Data,
base: Upvar(
UpvarId(HirId { owner: DefId(0:11 ~ filter_on_struct_member[317d]::{impl#1}::update), local_id: 1 };`self`;DefId(0:12 ~ filter_on_struct_member[317d]::{impl#1}::update::{closure#0})),
),
projections: [
Projection {
ty: Data,
kind: Deref,
},
Projection {
ty: Filter,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:11 ~ filter_on_struct_member[317d]::{impl#1}::update),
local_id: 13,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#7r),
),
},
},
],
}

View file

@ -23,6 +23,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
let wp = &w.p; let wp = &w.p;
//~^ ERROR: Capturing w[(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture w[(0, 0)] -> ImmBorrow
println!("{}", wp.x); println!("{}", wp.x);
}; };

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing w[(0, 0)] -> ImmBorrow
--> $DIR/multilevel-path-1.rs:25:19
|
LL | let wp = &w.p;
| ^^^
error: Min Capture w[(0, 0)] -> ImmBorrow
--> $DIR/multilevel-path-1.rs:25:19
|
LL | let wp = &w.p;
| ^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,63 +0,0 @@
For closure=DefId(0:9 ~ multilevel_path_1[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:9 ~ multilevel_path_1[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Wrapper,
base: Upvar(
UpvarId(HirId { owner: DefId(0:8 ~ multilevel_path_1[317d]::main), local_id: 1 };`w`;DefId(0:9 ~ multilevel_path_1[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: Point,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:8 ~ multilevel_path_1[317d]::main),
local_id: 20,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#37r),
),
},
}
For closure=DefId(0:9 ~ multilevel_path_1[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:8 ~ multilevel_path_1[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Wrapper,
base: Upvar(
UpvarId(HirId { owner: DefId(0:8 ~ multilevel_path_1[317d]::main), local_id: 1 };`w`;DefId(0:9 ~ multilevel_path_1[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: Point,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:8 ~ multilevel_path_1[317d]::main),
local_id: 20,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#37r),
),
},
},
],
}

View file

@ -20,6 +20,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("{}", w.p.x); println!("{}", w.p.x);
//~^ ERROR: Capturing 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`. // `c` only captures `w.p.x`, therefore it's safe to mutate `w.p.y`.

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing w[(0, 0),(0, 0)] -> ImmBorrow
--> $DIR/multilevel-path-2.rs:22:24
|
LL | println!("{}", w.p.x);
| ^^^^^
error: Min Capture w[(0, 0),(0, 0)] -> ImmBorrow
--> $DIR/multilevel-path-2.rs:22:24
|
LL | println!("{}", w.p.x);
| ^^^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,77 +0,0 @@
For closure=DefId(0:9 ~ multilevel_path_2[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:9 ~ multilevel_path_2[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Wrapper,
base: Upvar(
UpvarId(HirId { owner: DefId(0:8 ~ multilevel_path_2[317d]::main), local_id: 1 };`w`;DefId(0:9 ~ multilevel_path_2[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: Point,
kind: Field(
0,
0,
),
},
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:8 ~ multilevel_path_2[317d]::main),
local_id: 35,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
}
For closure=DefId(0:9 ~ multilevel_path_2[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:8 ~ multilevel_path_2[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Wrapper,
base: Upvar(
UpvarId(HirId { owner: DefId(0:8 ~ multilevel_path_2[317d]::main), local_id: 1 };`w`;DefId(0:9 ~ multilevel_path_2[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: Point,
kind: Field(
0,
0,
),
},
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:8 ~ multilevel_path_2[317d]::main),
local_id: 35,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
},
],
}

View file

@ -22,10 +22,18 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("{}", p.x); println!("{}", p.x);
//~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow
let incr = 10; let incr = 10;
let mut c2 = #[rustc_capture_analysis] let mut c2 = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| p.y += incr; || 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
c2(); c2();
println!("{}", p.y); println!("{}", p.y);
}; };

View file

@ -1,5 +1,5 @@
error[E0658]: attributes on expressions are experimental error[E0658]: attributes on expressions are experimental
--> $DIR/nested-closure.rs:19:18 --> $DIR/nested-closure.rs:21:18
| |
LL | let mut c1 = #[rustc_capture_analysis] 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 = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
error[E0658]: attributes on expressions are experimental error[E0658]: attributes on expressions are experimental
--> $DIR/nested-closure.rs:24:22 --> $DIR/nested-closure.rs:28:22
| |
LL | let mut c2 = #[rustc_capture_analysis] LL | let mut c2 = #[rustc_capture_analysis]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL | let mut c2 = #[rustc_capture_analysis]
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/nested-closure.rs:1:12 --> $DIR/nested-closure.rs:3:12
| |
LL | #![feature(capture_disjoint_fields)] LL | #![feature(capture_disjoint_fields)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
@ -25,6 +25,54 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to 2 previous errors; 1 warning emitted error: Capturing p[(1, 0)] -> MutBorrow
--> $DIR/nested-closure.rs:30:12
|
LL | || p.y += incr;
| ^^^
error: Capturing incr[] -> ImmBorrow
--> $DIR/nested-closure.rs:30:19
|
LL | || p.y += incr;
| ^^^^
error: Min Capture p[(1, 0)] -> MutBorrow
--> $DIR/nested-closure.rs:30:12
|
LL | || p.y += incr;
| ^^^
error: Min Capture incr[] -> ImmBorrow
--> $DIR/nested-closure.rs:30:19
|
LL | || p.y += incr;
| ^^^^
error: Capturing p[(0, 0)] -> ImmBorrow
--> $DIR/nested-closure.rs:24:24
|
LL | println!("{}", p.x);
| ^^^
error: Capturing p[(1, 0)] -> MutBorrow
--> $DIR/nested-closure.rs:30:12
|
LL | || p.y += incr;
| ^^^
error: Min Capture p[(0, 0)] -> ImmBorrow
--> $DIR/nested-closure.rs:24:24
|
LL | println!("{}", p.x);
| ^^^
error: Min Capture p[(1, 0)] -> MutBorrow
--> $DIR/nested-closure.rs:30:12
|
LL | || p.y += incr;
| ^^^
error: aborting due to 10 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,221 +0,0 @@
For closure=DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0}): Using new-style capture analysis
For closure=DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0}): capture information: {
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
1,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 70,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#109r),
),
},
Place {
base_ty: i32,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 5 };`incr`;DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0})),
),
projections: [],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 72,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#110r),
),
},
}
For closure=DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0}): min_captures={
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
1,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 70,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#109r),
),
},
},
],
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 5,
}: [
CapturedPlace {
place: Place {
base_ty: i32,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 5 };`incr`;DefId(0:8 ~ nested_closure[317d]::main::{closure#0}::{closure#0})),
),
projections: [],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 72,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#110r),
),
},
},
],
}
For closure=DefId(0:7 ~ nested_closure[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:7 ~ nested_closure[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ nested_closure[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 37,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#114r),
),
},
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ nested_closure[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
1,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 70,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#115r),
),
},
}
For closure=DefId(0:7 ~ nested_closure[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ nested_closure[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 37,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#114r),
),
},
},
CapturedPlace {
place: Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:6 ~ nested_closure[317d]::main), local_id: 1 };`p`;DefId(0:7 ~ nested_closure[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
1,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:6 ~ nested_closure[317d]::main),
local_id: 70,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#115r),
),
},
},
],
}

View file

@ -24,5 +24,7 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
println!("{}", pent.points[5].x); println!("{}", pent.points[5].x);
//~^ ERROR: Capturing pent[(0, 0)] -> ImmBorrow
//~^^ ERROR: Min Capture pent[(0, 0)] -> ImmBorrow
}; };
} }

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing pent[(0, 0)] -> ImmBorrow
--> $DIR/path-with-array-access.rs:26:24
|
LL | println!("{}", pent.points[5].x);
| ^^^^^^^^^^^
error: Min Capture pent[(0, 0)] -> ImmBorrow
--> $DIR/path-with-array-access.rs:26:24
|
LL | println!("{}", pent.points[5].x);
| ^^^^^^^^^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,63 +0,0 @@
For closure=DefId(0:10 ~ path_with_array_access[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:10 ~ path_with_array_access[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Pentagon,
base: Upvar(
UpvarId(HirId { owner: DefId(0:9 ~ path_with_array_access[317d]::main), local_id: 6 };`pent`;DefId(0:10 ~ path_with_array_access[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: [Point; 5],
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:9 ~ path_with_array_access[317d]::main),
local_id: 83,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#34r),
),
},
}
For closure=DefId(0:10 ~ path_with_array_access[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:9 ~ path_with_array_access[317d]::main),
local_id: 6,
}: [
CapturedPlace {
place: Place {
base_ty: Pentagon,
base: Upvar(
UpvarId(HirId { owner: DefId(0:9 ~ path_with_array_access[317d]::main), local_id: 6 };`pent`;DefId(0:10 ~ path_with_array_access[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: [Point; 5],
kind: Field(
0,
0,
),
},
],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:9 ~ path_with_array_access[317d]::main),
local_id: 83,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#34r),
),
},
},
],
}

View file

@ -26,7 +26,10 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
p.x += 10; p.x += 10;
//~^ ERROR: Capturing p[(0, 0)] -> MutBorrow
//~^^ ERROR: Min Capture p[] -> MutBorrow
println!("{:?}", p); println!("{:?}", p);
//~^ ERROR: Capturing p[] -> ImmBorrow
}; };
c(); c();

View file

@ -16,6 +16,24 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing p[(0, 0)] -> MutBorrow
--> $DIR/simple-struct-min-capture.rs:28:9
|
LL | p.x += 10;
| ^^^
error: Capturing p[] -> ImmBorrow
--> $DIR/simple-struct-min-capture.rs:31:26
|
LL | println!("{:?}", p);
| ^
error: Min Capture p[] -> MutBorrow
--> $DIR/simple-struct-min-capture.rs:28:9
|
LL | p.x += 10;
| ^^^
error: aborting due to 4 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,72 +0,0 @@
For closure=DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0}): capture information: {
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main), local_id: 1 };`p`;DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: i32,
kind: Field(
0,
0,
),
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main),
local_id: 15,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#34r),
),
},
Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main), local_id: 1 };`p`;DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0})),
),
projections: [],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main),
local_id: 35,
},
),
capture_kind: ByRef(
UpvarBorrow(ImmBorrow, '_#35r),
),
},
}
For closure=DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: Point,
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main), local_id: 1 };`p`;DefId(0:4 ~ simple_struct_min_capture[317d]::main::{closure#0})),
),
projections: [],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ simple_struct_min_capture[317d]::main),
local_id: 15,
},
),
capture_kind: ByRef(
UpvarBorrow(MutBorrow, '_#34r),
),
},
},
],
}

View file

@ -19,6 +19,8 @@ fn main() {
//~^ ERROR: attributes on expressions are experimental //~^ ERROR: attributes on expressions are experimental
|| { || {
let [a, b, .., e] = arr; let [a, b, .., e] = arr;
//~^ ERROR: Capturing arr[Index] -> ByValue
//~^^ ERROR: Min Capture arr[] -> ByValue
assert_eq!(a, "A"); assert_eq!(a, "A");
assert_eq!(b, "B"); assert_eq!(b, "B");
assert_eq!(e, "E"); assert_eq!(e, "E");

View file

@ -16,6 +16,18 @@ LL | #![feature(capture_disjoint_fields)]
= note: `#[warn(incomplete_features)]` on by default = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
error: aborting due to previous error; 1 warning emitted error: Capturing arr[Index] -> ByValue
--> $DIR/slice-pat.rs:21:33
|
LL | let [a, b, .., e] = arr;
| ^^^
error: Min Capture arr[] -> ByValue
--> $DIR/slice-pat.rs:21:33
|
LL | let [a, b, .., e] = arr;
| ^^^
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,56 +0,0 @@
For closure=DefId(0:5 ~ slice_pat[317d]::main::{closure#0}): Using new-style capture analysis
For closure=DefId(0:5 ~ slice_pat[317d]::main::{closure#0}): capture information: {
Place {
base_ty: [std::string::String; 5],
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ slice_pat[317d]::main), local_id: 1 };`arr`;DefId(0:5 ~ slice_pat[317d]::main::{closure#0})),
),
projections: [
Projection {
ty: std::string::String,
kind: Index,
},
],
}: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ slice_pat[317d]::main),
local_id: 179,
},
),
capture_kind: ByValue(
Some(
$DIR/slice-pat.rs:21:33: 21:36 (#0),
),
),
},
}
For closure=DefId(0:5 ~ slice_pat[317d]::main::{closure#0}): min_captures={
HirId {
owner: DefId(0:3 ~ slice_pat[317d]::main),
local_id: 1,
}: [
CapturedPlace {
place: Place {
base_ty: [std::string::String; 5],
base: Upvar(
UpvarId(HirId { owner: DefId(0:3 ~ slice_pat[317d]::main), local_id: 1 };`arr`;DefId(0:5 ~ slice_pat[317d]::main::{closure#0})),
),
projections: [],
},
info: CaptureInfo {
expr_id: Some(
HirId {
owner: DefId(0:3 ~ slice_pat[317d]::main),
local_id: 179,
},
),
capture_kind: ByValue(
Some(
$DIR/slice-pat.rs:21:33: 21:36 (#0),
),
),
},
},
],
}