Skip to content

Commit 7440125

Browse files
52985: formatting PR files
1 parent 3045ffa commit 7440125

File tree

2 files changed

+58
-46
lines changed

2 files changed

+58
-46
lines changed

src/librustc/traits/query/normalize.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
//! which folds deeply, invoking the underlying
1313
//! `normalize_projection_ty` query when it encounters projections.
1414
15-
use infer::{InferCtxt, InferOk};
1615
use infer::at::At;
17-
use mir::interpret::{GlobalId, ConstValue};
16+
use infer::{InferCtxt, InferOk};
17+
use mir::interpret::{ConstValue, GlobalId};
1818
use rustc_data_structures::small_vec::SmallVec;
19-
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
2019
use traits::project::Normalized;
21-
use ty::{self, Ty, TyCtxt};
20+
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
2221
use ty::fold::{TypeFoldable, TypeFolder};
2322
use ty::subst::{Subst, Substs};
23+
use ty::{self, Ty, TyCtxt};
2424

2525
use super::NoSolution;
2626

@@ -121,9 +121,14 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
121121
let concrete_ty = generic_ty.subst(self.tcx(), substs);
122122
self.anon_depth += 1;
123123
if concrete_ty == ty {
124-
bug!("infinite recursion generic_ty: {:#?}, substs: {:#?}, \
125-
concrete_ty: {:#?}, ty: {:#?}", generic_ty, substs, concrete_ty,
126-
ty);
124+
bug!(
125+
"infinite recursion generic_ty: {:#?}, substs: {:#?}, \
126+
concrete_ty: {:#?}, ty: {:#?}",
127+
generic_ty,
128+
substs,
129+
concrete_ty,
130+
ty
131+
);
127132
}
128133
let folded_ty = self.fold_ty(concrete_ty);
129134
self.anon_depth -= 1;
@@ -149,8 +154,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
149154
let gcx = self.infcx.tcx.global_tcx();
150155

151156
let mut orig_values = SmallVec::new();
152-
let c_data =
153-
self.infcx.canonicalize_query(&self.param_env.and(*data), &mut orig_values);
157+
let c_data = self.infcx
158+
.canonicalize_query(&self.param_env.and(*data), &mut orig_values);
154159
debug!("QueryNormalizer: c_data = {:#?}", c_data);
155160
debug!("QueryNormalizer: orig_values = {:#?}", orig_values);
156161
match gcx.normalize_projection_ty(c_data) {

src/librustc_typeck/check/writeback.rs

+44-37
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ use rustc::hir;
1717
use rustc::hir::def_id::{DefId, DefIndex};
1818
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
1919
use rustc::infer::InferCtxt;
20+
use rustc::ty::adjustment::{Adjust, Adjustment};
21+
use rustc::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder};
2022
use rustc::ty::subst::UnpackedKind;
2123
use rustc::ty::{self, Ty, TyCtxt};
22-
use rustc::ty::adjustment::{Adjust, Adjustment};
23-
use rustc::ty::fold::{TypeFoldable, TypeFolder, BottomUpFolder};
2424
use rustc::util::nodemap::DefIdSet;
25+
use rustc_data_structures::sync::Lrc;
26+
use std::mem;
2527
use syntax::ast;
2628
use syntax_pos::Span;
27-
use std::mem;
28-
use rustc_data_structures::sync::Lrc;
2929

3030
///////////////////////////////////////////////////////////////////////////
3131
// Entry point
@@ -55,17 +55,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5555
);
5656
debug!(
5757
"used_trait_imports({:?}) = {:?}",
58-
item_def_id,
59-
used_trait_imports
58+
item_def_id, used_trait_imports
6059
);
6160
wbcx.tables.used_trait_imports = used_trait_imports;
6261

6362
wbcx.tables.tainted_by_errors = self.is_tainted_by_errors();
6463

6564
debug!(
6665
"writeback: tables for {:?} are {:#?}",
67-
item_def_id,
68-
wbcx.tables
66+
item_def_id, wbcx.tables
6967
);
7068

7169
self.tcx.alloc_tables(wbcx.tables)
@@ -118,8 +116,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
118116
// operating on scalars, we clear the overload.
119117
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
120118
match e.node {
121-
hir::ExprKind::Unary(hir::UnNeg, ref inner) |
122-
hir::ExprKind::Unary(hir::UnNot, ref inner) => {
119+
hir::ExprKind::Unary(hir::UnNeg, ref inner)
120+
| hir::ExprKind::Unary(hir::UnNot, ref inner) => {
123121
let inner_ty = self.fcx.node_ty(inner.hir_id);
124122
let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);
125123

@@ -178,8 +176,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
178176
let index_ty = tables.expr_ty_adjusted(&index);
179177
let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty);
180178

181-
if base_ty.builtin_index().is_some()
182-
&& index_ty == self.fcx.tcx.types.usize {
179+
if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize {
183180
// Remove the method call record
184181
tables.type_dependent_defs_mut().remove(e.hir_id);
185182
tables.node_substs_mut().remove(e.hir_id);
@@ -191,24 +188,26 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
191188
// of size information - we need to get rid of it
192189
// Since this is "after" the other adjustment to be
193190
// discarded, we do an extra `pop()`
194-
Some(Adjustment { kind: Adjust::Unsize, .. }) => {
191+
Some(Adjustment {
192+
kind: Adjust::Unsize,
193+
..
194+
}) => {
195195
// So the borrow discard actually happens here
196196
a.pop();
197-
},
197+
}
198198
_ => {}
199199
}
200200
});
201201
}
202-
},
202+
}
203203
// Might encounter non-valid indexes at this point, so there
204204
// has to be a fall-through
205-
_ => {},
205+
_ => {}
206206
}
207207
}
208208
}
209209
}
210210

211-
212211
///////////////////////////////////////////////////////////////////////////
213212
// Impl of Visitor for Resolver
214213
//
@@ -262,7 +261,9 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
262261
if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) {
263262
self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);
264263
} else {
265-
self.tcx().sess.delay_span_bug(p.span, "missing binding mode");
264+
self.tcx()
265+
.sess
266+
.delay_span_bug(p.span, "missing binding mode");
266267
}
267268
}
268269
hir::PatKind::Struct(_, ref fields, _) => {
@@ -310,8 +311,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
310311
};
311312
debug!(
312313
"Upvar capture for {:?} resolved to {:?}",
313-
upvar_id,
314-
new_upvar_capture
314+
upvar_id, new_upvar_capture
315315
);
316316
self.tables
317317
.upvar_capture_map
@@ -425,8 +425,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
425425
if subst == ty {
426426
// found it in the substitution list, replace with the
427427
// parameter from the existential type
428-
return self
429-
.tcx()
428+
return self.tcx()
430429
.global_tcx()
431430
.mk_ty_param(param.index, param.name);
432431
}
@@ -464,14 +463,16 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
464463
name: p.name,
465464
};
466465
trace!("replace {:?} with {:?}", region, reg);
467-
return self.tcx().global_tcx()
466+
return self.tcx()
467+
.global_tcx()
468468
.mk_region(ty::ReEarlyBound(reg));
469469
}
470470
}
471471
}
472472
trace!("anon_defn: {:#?}", anon_defn);
473473
trace!("generics: {:#?}", generics);
474-
self.tcx().sess
474+
self.tcx()
475+
.sess
475476
.struct_span_err(
476477
span,
477478
"non-defining existential type use in defining scope",
@@ -480,33 +481,35 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
480481
span,
481482
format!(
482483
"lifetime `{}` is part of concrete type but not used \
483-
in parameter list of existential type",
484+
in parameter list of existential type",
484485
region,
485486
),
486487
)
487488
.emit();
488489
self.tcx().global_tcx().mk_region(ty::ReStatic)
489490
}
490491
}
491-
}
492+
},
492493
})
493494
};
494495

495496
if let ty::Anon(defin_ty_def_id, _substs) = definition_ty.sty {
496497
if def_id == defin_ty_def_id {
497-
// Concrete type resolved to the existential type itself
498-
// Force a cycle error
499-
self.tcx().at(span).type_of(defin_ty_def_id);
498+
// Concrete type resolved to the existential type itself
499+
// Force a cycle error
500+
self.tcx().at(span).type_of(defin_ty_def_id);
500501
}
501502
}
502503

503-
let old = self.tables.concrete_existential_types.insert(def_id, definition_ty);
504+
let old = self.tables
505+
.concrete_existential_types
506+
.insert(def_id, definition_ty);
504507
if let Some(old) = old {
505508
if old != definition_ty {
506509
span_bug!(
507510
span,
508511
"visit_anon_types tried to write \
509-
different types for the same existential type: {:?}, {:?}, {:?}",
512+
different types for the same existential type: {:?}, {:?}, {:?}",
510513
def_id,
511514
definition_ty,
512515
old,
@@ -518,7 +521,12 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
518521

519522
fn visit_field_id(&mut self, node_id: ast::NodeId) {
520523
let hir_id = self.tcx().hir.node_to_hir_id(node_id);
521-
if let Some(index) = self.fcx.tables.borrow_mut().field_indices_mut().remove(hir_id) {
524+
if let Some(index) = self.fcx
525+
.tables
526+
.borrow_mut()
527+
.field_indices_mut()
528+
.remove(hir_id)
529+
{
522530
self.tables.field_indices_mut().insert(hir_id, index);
523531
}
524532
}
@@ -567,8 +575,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
567575
let resolved_adjustment = self.resolve(&adjustment, &span);
568576
debug!(
569577
"Adjustments for node {:?}: {:?}",
570-
hir_id,
571-
resolved_adjustment
578+
hir_id, resolved_adjustment
572579
);
573580
self.tables
574581
.adjustments_mut()
@@ -592,8 +599,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
592599
let resolved_adjustment = self.resolve(&adjustment, &span);
593600
debug!(
594601
"pat_adjustments for node {:?}: {:?}",
595-
hir_id,
596-
resolved_adjustment
602+
hir_id, resolved_adjustment
597603
);
598604
self.tables
599605
.pat_adjustments_mut()
@@ -709,7 +715,8 @@ impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> {
709715
fn report_error(&self, t: Ty<'tcx>) {
710716
if !self.tcx.sess.has_errors() {
711717
self.infcx
712-
.need_type_info_err(Some(self.body.id()), self.span.to_span(&self.tcx), t).emit();
718+
.need_type_info_err(Some(self.body.id()), self.span.to_span(&self.tcx), t)
719+
.emit();
713720
}
714721
}
715722
}

0 commit comments

Comments
 (0)