Skip to content

Commit c053d96

Browse files
committed
Bors test
1 parent 4a19caf commit c053d96

File tree

8 files changed

+14
-45
lines changed

8 files changed

+14
-45
lines changed

compiler/rustc_typeck/src/check/upvar.rs

+1-32
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
122122
None
123123
};
124124

125-
let local_def_id = closure_def_id.expect_local();
126-
127-
let mut capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default();
128-
if !self.tcx.features().capture_disjoint_fields {
129-
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
130-
for (&var_hir_id, _) in upvars.iter() {
131-
let place = self.place_for_root_variable(local_def_id, var_hir_id);
132-
133-
debug!("seed place {:?}", place);
134-
135-
let upvar_id = ty::UpvarId::new(var_hir_id, local_def_id);
136-
let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span);
137-
let info = ty::CaptureInfo { expr_id: None, capture_kind };
138-
139-
capture_information.insert(place, info);
140-
}
141-
}
142-
}
125+
let capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default();
143126

144127
let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id());
145128
assert_eq!(body_owner_def_id.to_def_id(), closure_def_id);
@@ -482,20 +465,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
482465
}
483466
}
484467

485-
fn place_for_root_variable(
486-
&self,
487-
closure_def_id: LocalDefId,
488-
var_hir_id: hir::HirId,
489-
) -> Place<'tcx> {
490-
let upvar_id = ty::UpvarId::new(var_hir_id, closure_def_id);
491-
492-
Place {
493-
base_ty: self.node_ty(var_hir_id),
494-
base: PlaceBase::Upvar(upvar_id),
495-
projections: Default::default(),
496-
}
497-
}
498-
499468
fn should_log_capture_analysis(&self, closure_def_id: DefId) -> bool {
500469
self.tcx.has_attr(closure_def_id, sym::rustc_capture_analysis)
501470
}

src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn bar<F>(blk: F) where F: FnOnce() + 'static {
44
fn foo(x: &()) {
55
bar(|| {
66
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
7-
let _ = x;
7+
let _x = x;
88
})
99
}
1010

src/test/ui/consts/const-eval/ub-upvars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::mem;
55
const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value
66
let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
77
let another_var = 13;
8-
move || { let _ = bad_ref; let _ = another_var; }
8+
move || { let _b = bad_ref; let _a = another_var; }
99
};
1010

1111
fn main() {}

src/test/ui/consts/const-eval/ub-upvars.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0080]: it is undefined behavior to use this value
44
LL | / const BAD_UPVAR: &dyn FnOnce() = &{
55
LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
66
LL | | let another_var = 13;
7-
LL | | move || { let _ = bad_ref; let _ = another_var; }
7+
LL | | move || { let _b = bad_ref; let _a = another_var; }
88
LL | | };
99
| |__^ type validation failed: encountered a NULL reference at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>
1010
|

src/test/ui/generator/print/generator-print-verbose-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ LL | assert_send(|| {
88
| ^^^^^^^^^^^ `Cell<i32>` cannot be shared between threads safely
99
|
1010
= help: the trait `Sync` is not implemented for `Cell<i32>`
11-
= note: required because of the requirements on the impl of `Send` for `&'_#4r Cell<i32>`
12-
= note: required because it appears within the type `[main::{closure#1} upvar_tys=(&'_#4r Cell<i32>) _#17t]`
11+
= note: required because of the requirements on the impl of `Send` for `&'_#3r Cell<i32>`
12+
= note: required because it appears within the type `[main::{closure#1} upvar_tys=(&'_#3r Cell<i32>) _#17t]`
1313

1414
error: generator cannot be shared between threads safely
1515
--> $DIR/generator-print-verbose-2.rs:12:5

src/test/ui/issues/issue-29948.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
let mut ran_drop = false;
2323
{
2424
let x = Foo(&mut ran_drop);
25-
let x = move || { let _ = x; };
25+
let x = move || { let _x = x; };
2626
f(x);
2727
}
2828
assert!(ran_drop);
@@ -31,7 +31,7 @@ fn main() {
3131
{
3232
let x = Foo(&mut ran_drop);
3333
let result = panic::catch_unwind(move || {
34-
let x = move || { let _ = x; panic!() };
34+
let x = move || { let _x = x; panic!() };
3535
f(x);
3636
});
3737
assert!(result.is_err());

src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | let mut closure1 = || p = &y;
77
= note: defining type: test::{closure#0}::{closure#0} with closure substs [
88
i16,
99
extern "rust-call" fn(()),
10-
(&'_#1r i32, &'_#2r mut &'_#3r i32),
10+
(&'_#1r mut &'_#2r i32, &'_#3r i32),
1111
]
1212
= note: number of external vids: 4
13-
= note: where '_#1r: '_#3r
13+
= note: where '_#3r: '_#2r
1414

1515
note: external requirements
1616
--> $DIR/escape-upvar-nested.rs:20:27
@@ -25,10 +25,10 @@ LL | | };
2525
= note: defining type: test::{closure#0} with closure substs [
2626
i16,
2727
extern "rust-call" fn(()),
28-
(&'_#1r i32, &'_#2r mut &'_#3r i32),
28+
(&'_#1r mut &'_#2r i32, &'_#3r i32),
2929
]
3030
= note: number of external vids: 4
31-
= note: where '_#1r: '_#3r
31+
= note: where '_#3r: '_#2r
3232

3333
note: no external requirements
3434
--> $DIR/escape-upvar-nested.rs:13:1

src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | let mut closure = || p = &y;
77
= note: defining type: test::{closure#0} with closure substs [
88
i16,
99
extern "rust-call" fn(()),
10-
(&'_#1r i32, &'_#2r mut &'_#3r i32),
10+
(&'_#1r mut &'_#2r i32, &'_#3r i32),
1111
]
1212
= note: number of external vids: 4
13-
= note: where '_#1r: '_#3r
13+
= note: where '_#3r: '_#2r
1414

1515
note: no external requirements
1616
--> $DIR/escape-upvar-ref.rs:17:1

0 commit comments

Comments
 (0)