Skip to content

Commit 1ca505a

Browse files
committed
capture_disjoint_fields(rust-lang#53488)
Just running RustFmt on upvar.rs
1 parent 6f244c9 commit 1ca505a

File tree

1 file changed

+72
-72
lines changed

1 file changed

+72
-72
lines changed

src/librustc_typeck/check/upvar.rs

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ use super::FnCtxt;
4545
use middle::expr_use_visitor as euv;
4646
use middle::mem_categorization as mc;
4747
use middle::mem_categorization::Categorization;
48+
use rustc::hir;
4849
use rustc::hir::def_id::DefId;
49-
use rustc::ty::{self, Ty, TyCtxt, UpvarSubsts};
50+
use rustc::hir::def_id::LocalDefId;
51+
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
5052
use rustc::infer::UpvarRegion;
53+
use rustc::ty::{self, Ty, TyCtxt, UpvarSubsts};
5154
use syntax::ast;
5255
use syntax_pos::Span;
53-
use rustc::hir;
54-
use rustc::hir::def_id::LocalDefId;
55-
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
5656

5757
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5858
pub fn closure_analyze(&self, body: &'gcx hir::Body) {
@@ -121,7 +121,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
121121
}
122122
};
123123

124-
let infer_kind = if let UpvarSubsts::Closure(closure_substs) = substs{
124+
let infer_kind = if let UpvarSubsts::Closure(closure_substs) = substs {
125125
if self.closure_kind(closure_def_id, closure_substs).is_none() {
126126
Some(closure_substs)
127127
} else {
@@ -213,12 +213,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
213213
let final_upvar_tys = self.final_upvar_tys(closure_node_id);
214214
debug!(
215215
"analyze_closure: id={:?} substs={:?} final_upvar_tys={:?}",
216-
closure_node_id,
217-
substs,
218-
final_upvar_tys
216+
closure_node_id, substs, final_upvar_tys
219217
);
220-
for (upvar_ty, final_upvar_ty) in substs.upvar_tys(closure_def_id, self.tcx)
221-
.zip(final_upvar_tys)
218+
for (upvar_ty, final_upvar_ty) in substs
219+
.upvar_tys(closure_def_id, self.tcx)
220+
.zip(final_upvar_tys)
222221
{
223222
self.demand_suptype(span, upvar_ty, final_upvar_ty);
224223
}
@@ -256,9 +255,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
256255

257256
debug!(
258257
"var_id={:?} freevar_ty={:?} capture={:?}",
259-
var_node_id,
260-
freevar_ty,
261-
capture
258+
var_node_id, freevar_ty, capture
262259
);
263260

264261
match capture {
@@ -271,8 +268,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
271268
},
272269
),
273270
}
274-
})
275-
.collect()
271+
}).collect()
276272
})
277273
}
278274
}
@@ -301,12 +297,14 @@ struct InferBorrowKind<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
301297
}
302298

303299
impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
304-
fn adjust_upvar_borrow_kind_for_consume(&mut self, cmt: &mc::cmt_<'tcx>,
305-
mode: euv::ConsumeMode) {
300+
fn adjust_upvar_borrow_kind_for_consume(
301+
&mut self,
302+
cmt: &mc::cmt_<'tcx>,
303+
mode: euv::ConsumeMode,
304+
) {
306305
debug!(
307306
"adjust_upvar_borrow_kind_for_consume(cmt={:?}, mode={:?})",
308-
cmt,
309-
mode
307+
cmt, mode
310308
);
311309

312310
// we only care about moves
@@ -381,9 +379,9 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
381379
debug!("adjust_upvar_borrow_kind_for_mut(cmt={:?})", cmt);
382380

383381
match cmt.cat.clone() {
384-
Categorization::Deref(base, mc::Unique) |
385-
Categorization::Interior(base, _) |
386-
Categorization::Downcast(base, _) => {
382+
Categorization::Deref(base, mc::Unique)
383+
| Categorization::Interior(base, _)
384+
| Categorization::Downcast(base, _) => {
387385
// Interior or owned data is mutable if base is
388386
// mutable, so iterate to the base.
389387
self.adjust_upvar_borrow_kind_for_mut(&base);
@@ -399,12 +397,12 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
399397
}
400398
}
401399

402-
Categorization::Deref(_, mc::UnsafePtr(..)) |
403-
Categorization::StaticItem |
404-
Categorization::ThreadLocal(..) |
405-
Categorization::Rvalue(..) |
406-
Categorization::Local(_) |
407-
Categorization::Upvar(..) => {
400+
Categorization::Deref(_, mc::UnsafePtr(..))
401+
| Categorization::StaticItem
402+
| Categorization::ThreadLocal(..)
403+
| Categorization::Rvalue(..)
404+
| Categorization::Local(_)
405+
| Categorization::Upvar(..) => {
408406
return;
409407
}
410408
}
@@ -414,9 +412,9 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
414412
debug!("adjust_upvar_borrow_kind_for_unique(cmt={:?})", cmt);
415413

416414
match cmt.cat.clone() {
417-
Categorization::Deref(base, mc::Unique) |
418-
Categorization::Interior(base, _) |
419-
Categorization::Downcast(base, _) => {
415+
Categorization::Deref(base, mc::Unique)
416+
| Categorization::Interior(base, _)
417+
| Categorization::Downcast(base, _) => {
420418
// Interior or owned data is unique if base is
421419
// unique.
422420
self.adjust_upvar_borrow_kind_for_unique(&base);
@@ -430,18 +428,20 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
430428
}
431429
}
432430

433-
Categorization::Deref(_, mc::UnsafePtr(..)) |
434-
Categorization::StaticItem |
435-
Categorization::ThreadLocal(..) |
436-
Categorization::Rvalue(..) |
437-
Categorization::Local(_) |
438-
Categorization::Upvar(..) => {}
431+
Categorization::Deref(_, mc::UnsafePtr(..))
432+
| Categorization::StaticItem
433+
| Categorization::ThreadLocal(..)
434+
| Categorization::Rvalue(..)
435+
| Categorization::Local(_)
436+
| Categorization::Upvar(..) => {}
439437
}
440438
}
441439

442-
fn try_adjust_upvar_deref(&mut self, cmt: &mc::cmt_<'tcx>, borrow_kind: ty::BorrowKind)
443-
-> bool
444-
{
440+
fn try_adjust_upvar_deref(
441+
&mut self,
442+
cmt: &mc::cmt_<'tcx>,
443+
borrow_kind: ty::BorrowKind,
444+
) -> bool {
445445
assert!(match borrow_kind {
446446
ty::MutBorrow => true,
447447
ty::UniqueImmBorrow => true,
@@ -493,15 +493,14 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
493493
/// Here the argument `mutbl` is the borrow_kind that is required by
494494
/// some particular use.
495495
fn adjust_upvar_borrow_kind(&mut self, upvar_id: ty::UpvarId, kind: ty::BorrowKind) {
496-
let upvar_capture = self.adjust_upvar_captures
496+
let upvar_capture = self
497+
.adjust_upvar_captures
497498
.get(&upvar_id)
498499
.cloned()
499500
.unwrap_or_else(|| self.fcx.tables.borrow().upvar_capture(upvar_id));
500501
debug!(
501502
"adjust_upvar_borrow_kind(upvar_id={:?}, upvar_capture={:?}, kind={:?})",
502-
upvar_id,
503-
upvar_capture,
504-
kind
503+
upvar_id, upvar_capture, kind
505504
);
506505

507506
match upvar_capture {
@@ -511,18 +510,18 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
511510
ty::UpvarCapture::ByRef(mut upvar_borrow) => {
512511
match (upvar_borrow.kind, kind) {
513512
// Take RHS:
514-
(ty::ImmBorrow, ty::UniqueImmBorrow) |
515-
(ty::ImmBorrow, ty::MutBorrow) |
516-
(ty::UniqueImmBorrow, ty::MutBorrow) => {
513+
(ty::ImmBorrow, ty::UniqueImmBorrow)
514+
| (ty::ImmBorrow, ty::MutBorrow)
515+
| (ty::UniqueImmBorrow, ty::MutBorrow) => {
517516
upvar_borrow.kind = kind;
518517
self.adjust_upvar_captures
519518
.insert(upvar_id, ty::UpvarCapture::ByRef(upvar_borrow));
520519
}
521520
// Take LHS:
522-
(ty::ImmBorrow, ty::ImmBorrow) |
523-
(ty::UniqueImmBorrow, ty::ImmBorrow) |
524-
(ty::UniqueImmBorrow, ty::UniqueImmBorrow) |
525-
(ty::MutBorrow, _) => {}
521+
(ty::ImmBorrow, ty::ImmBorrow)
522+
| (ty::UniqueImmBorrow, ty::ImmBorrow)
523+
| (ty::UniqueImmBorrow, ty::UniqueImmBorrow)
524+
| (ty::MutBorrow, _) => {}
526525
}
527526
}
528527
}
@@ -537,10 +536,7 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
537536
) {
538537
debug!(
539538
"adjust_closure_kind(closure_id={:?}, new_kind={:?}, upvar_span={:?}, var_name={})",
540-
closure_id,
541-
new_kind,
542-
upvar_span,
543-
var_name
539+
closure_id, new_kind, upvar_span, var_name
544540
);
545541

546542
// Is this the closure whose kind is currently being inferred?
@@ -554,22 +550,20 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
554550

555551
debug!(
556552
"adjust_closure_kind: closure_id={:?}, existing_kind={:?}, new_kind={:?}",
557-
closure_id,
558-
existing_kind,
559-
new_kind
553+
closure_id, existing_kind, new_kind
560554
);
561555

562556
match (existing_kind, new_kind) {
563-
(ty::ClosureKind::Fn, ty::ClosureKind::Fn) |
564-
(ty::ClosureKind::FnMut, ty::ClosureKind::Fn) |
565-
(ty::ClosureKind::FnMut, ty::ClosureKind::FnMut) |
566-
(ty::ClosureKind::FnOnce, _) => {
557+
(ty::ClosureKind::Fn, ty::ClosureKind::Fn)
558+
| (ty::ClosureKind::FnMut, ty::ClosureKind::Fn)
559+
| (ty::ClosureKind::FnMut, ty::ClosureKind::FnMut)
560+
| (ty::ClosureKind::FnOnce, _) => {
567561
// no change needed
568562
}
569563

570-
(ty::ClosureKind::Fn, ty::ClosureKind::FnMut) |
571-
(ty::ClosureKind::Fn, ty::ClosureKind::FnOnce) |
572-
(ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => {
564+
(ty::ClosureKind::Fn, ty::ClosureKind::FnMut)
565+
| (ty::ClosureKind::Fn, ty::ClosureKind::FnOnce)
566+
| (ty::ClosureKind::FnMut, ty::ClosureKind::FnOnce) => {
573567
// new kind is stronger than the old kind
574568
self.current_closure_kind = new_kind;
575569
self.current_origin = Some((upvar_span, var_name));
@@ -590,12 +584,20 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
590584
self.adjust_upvar_borrow_kind_for_consume(cmt, mode);
591585
}
592586

593-
fn matched_pat(&mut self, _matched_pat: &hir::Pat, _cmt: &mc::cmt_<'tcx>,
594-
_mode: euv::MatchMode) {
587+
fn matched_pat(
588+
&mut self,
589+
_matched_pat: &hir::Pat,
590+
_cmt: &mc::cmt_<'tcx>,
591+
_mode: euv::MatchMode,
592+
) {
595593
}
596594

597-
fn consume_pat(&mut self, _consume_pat: &hir::Pat, cmt: &mc::cmt_<'tcx>,
598-
mode: euv::ConsumeMode) {
595+
fn consume_pat(
596+
&mut self,
597+
_consume_pat: &hir::Pat,
598+
cmt: &mc::cmt_<'tcx>,
599+
mode: euv::ConsumeMode,
600+
) {
599601
debug!("consume_pat(cmt={:?},mode={:?})", cmt, mode);
600602
self.adjust_upvar_borrow_kind_for_consume(cmt, mode);
601603
}
@@ -611,9 +613,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
611613
) {
612614
debug!(
613615
"borrow(borrow_id={}, cmt={:?}, bk={:?})",
614-
borrow_id,
615-
cmt,
616-
bk
616+
borrow_id, cmt, bk
617617
);
618618

619619
match bk {

0 commit comments

Comments
 (0)