Skip to content

Commit

Permalink
Bors test
Browse files Browse the repository at this point in the history
  • Loading branch information
arora-aman committed Nov 5, 2020
1 parent 4a19caf commit c053d96
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 45 deletions.
33 changes: 1 addition & 32 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None
};

let local_def_id = closure_def_id.expect_local();

let mut capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default();
if !self.tcx.features().capture_disjoint_fields {
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
for (&var_hir_id, _) in upvars.iter() {
let place = self.place_for_root_variable(local_def_id, var_hir_id);

debug!("seed place {:?}", place);

let upvar_id = ty::UpvarId::new(var_hir_id, local_def_id);
let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span);
let info = ty::CaptureInfo { expr_id: None, capture_kind };

capture_information.insert(place, info);
}
}
}
let capture_information = FxIndexMap::<Place<'tcx>, ty::CaptureInfo<'tcx>>::default();

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

fn place_for_root_variable(
&self,
closure_def_id: LocalDefId,
var_hir_id: hir::HirId,
) -> Place<'tcx> {
let upvar_id = ty::UpvarId::new(var_hir_id, closure_def_id);

Place {
base_ty: self.node_ty(var_hir_id),
base: PlaceBase::Upvar(upvar_id),
projections: Default::default(),
}
}

fn should_log_capture_analysis(&self, closure_def_id: DefId) -> bool {
self.tcx.has_attr(closure_def_id, sym::rustc_capture_analysis)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn bar<F>(blk: F) where F: FnOnce() + 'static {
fn foo(x: &()) {
bar(|| {
//~^ ERROR explicit lifetime required in the type of `x` [E0621]
let _ = x;
let _x = x;
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/ub-upvars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::mem;
const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value
let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
let another_var = 13;
move || { let _ = bad_ref; let _ = another_var; }
move || { let _b = bad_ref; let _a = another_var; }
};

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/ub-upvars.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0080]: it is undefined behavior to use this value
LL | / const BAD_UPVAR: &dyn FnOnce() = &{
LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
LL | | let another_var = 13;
LL | | move || { let _ = bad_ref; let _ = another_var; }
LL | | move || { let _b = bad_ref; let _a = another_var; }
LL | | };
| |__^ type validation failed: encountered a NULL reference at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generator/print/generator-print-verbose-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ LL | assert_send(|| {
| ^^^^^^^^^^^ `Cell<i32>` cannot be shared between threads safely
|
= help: the trait `Sync` is not implemented for `Cell<i32>`
= note: required because of the requirements on the impl of `Send` for `&'_#4r Cell<i32>`
= note: required because it appears within the type `[main::{closure#1} upvar_tys=(&'_#4r Cell<i32>) _#17t]`
= note: required because of the requirements on the impl of `Send` for `&'_#3r Cell<i32>`
= note: required because it appears within the type `[main::{closure#1} upvar_tys=(&'_#3r Cell<i32>) _#17t]`

error: generator cannot be shared between threads safely
--> $DIR/generator-print-verbose-2.rs:12:5
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-29948.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
let mut ran_drop = false;
{
let x = Foo(&mut ran_drop);
let x = move || { let _ = x; };
let x = move || { let _x = x; };
f(x);
}
assert!(ran_drop);
Expand All @@ -31,7 +31,7 @@ fn main() {
{
let x = Foo(&mut ran_drop);
let result = panic::catch_unwind(move || {
let x = move || { let _ = x; panic!() };
let x = move || { let _x = x; panic!() };
f(x);
});
assert!(result.is_err());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LL | let mut closure1 = || p = &y;
= note: defining type: test::{closure#0}::{closure#0} with closure substs [
i16,
extern "rust-call" fn(()),
(&'_#1r i32, &'_#2r mut &'_#3r i32),
(&'_#1r mut &'_#2r i32, &'_#3r i32),
]
= note: number of external vids: 4
= note: where '_#1r: '_#3r
= note: where '_#3r: '_#2r

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

note: no external requirements
--> $DIR/escape-upvar-nested.rs:13:1
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LL | let mut closure = || p = &y;
= note: defining type: test::{closure#0} with closure substs [
i16,
extern "rust-call" fn(()),
(&'_#1r i32, &'_#2r mut &'_#3r i32),
(&'_#1r mut &'_#2r i32, &'_#3r i32),
]
= note: number of external vids: 4
= note: where '_#1r: '_#3r
= note: where '_#3r: '_#2r

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

0 comments on commit c053d96

Please sign in to comment.