Skip to content

Commit 4ef3f59

Browse files
committed
Run rustfmt on librustc_typeck/check/ folder
1 parent 75c155b commit 4ef3f59

File tree

7 files changed

+633
-603
lines changed

7 files changed

+633
-603
lines changed

Diff for: src/librustc_typeck/check/assoc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
// except according to those terms.
1010

1111
use rustc::infer::InferCtxt;
12-
use rustc::traits::{self, FulfillmentContext, Normalized, MiscObligation,
13-
SelectionContext, ObligationCause};
12+
use rustc::traits::{self, FulfillmentContext, Normalized, MiscObligation, SelectionContext,
13+
ObligationCause};
1414
use rustc::ty::fold::TypeFoldable;
1515
use syntax::ast;
1616
use syntax_pos::Span;
1717

18-
//FIXME(@jroesch): Ideally we should be able to drop the fulfillment_cx argument.
18+
// FIXME(@jroesch): Ideally we should be able to drop the fulfillment_cx argument.
1919
pub fn normalize_associated_types_in<'a, 'gcx, 'tcx, T>(
2020
infcx: &InferCtxt<'a, 'gcx, 'tcx>,
2121
fulfillment_cx: &mut FulfillmentContext<'tcx>,

Diff for: src/librustc_typeck/check/autoderef.rs

+61-48
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use syntax::parse::token;
2626
#[derive(Copy, Clone, Debug)]
2727
enum AutoderefKind {
2828
Builtin,
29-
Overloaded
29+
Overloaded,
3030
}
3131

3232
pub struct Autoderef<'a, 'gcx: 'tcx, 'tcx: 'a> {
@@ -35,7 +35,7 @@ pub struct Autoderef<'a, 'gcx: 'tcx, 'tcx: 'a> {
3535
cur_ty: Ty<'tcx>,
3636
obligations: Vec<traits::PredicateObligation<'tcx>>,
3737
at_start: bool,
38-
span: Span
38+
span: Span,
3939
}
4040

4141
impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
@@ -45,7 +45,8 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
4545
let tcx = self.fcx.tcx;
4646

4747
debug!("autoderef: steps={:?}, cur_ty={:?}",
48-
self.steps, self.cur_ty);
48+
self.steps,
49+
self.cur_ty);
4950
if self.at_start {
5051
self.at_start = false;
5152
debug!("autoderef stage #0 is {:?}", self.cur_ty);
@@ -54,11 +55,13 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
5455

5556
if self.steps.len() == tcx.sess.recursion_limit.get() {
5657
// We've reached the recursion limit, error gracefully.
57-
struct_span_err!(tcx.sess, self.span, E0055,
58-
"reached the recursion limit while auto-dereferencing {:?}",
59-
self.cur_ty)
60-
.span_label(self.span, &format!("deref recursion limit reached"))
61-
.emit();
58+
struct_span_err!(tcx.sess,
59+
self.span,
60+
E0055,
61+
"reached the recursion limit while auto-dereferencing {:?}",
62+
self.cur_ty)
63+
.span_label(self.span, &format!("deref recursion limit reached"))
64+
.emit();
6265
return None;
6366
}
6467

@@ -72,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
7275
} else {
7376
match self.overloaded_deref_ty(self.cur_ty) {
7477
Some(ty) => (AutoderefKind::Overloaded, ty),
75-
_ => return None
78+
_ => return None,
7679
}
7780
};
7881

@@ -81,8 +84,10 @@ impl<'a, 'gcx, 'tcx> Iterator for Autoderef<'a, 'gcx, 'tcx> {
8184
}
8285

8386
self.steps.push((self.cur_ty, kind));
84-
debug!("autoderef stage #{:?} is {:?} from {:?}", self.steps.len(),
85-
new_ty, (self.cur_ty, kind));
87+
debug!("autoderef stage #{:?} is {:?} from {:?}",
88+
self.steps.len(),
89+
new_ty,
90+
(self.cur_ty, kind));
8691
self.cur_ty = new_ty;
8792

8893
Some((self.cur_ty, self.steps.len()))
@@ -99,9 +104,9 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
99104
let trait_ref = TraitRef {
100105
def_id: match tcx.lang_items.deref_trait() {
101106
Some(f) => f,
102-
None => return None
107+
None => return None,
103108
},
104-
substs: Substs::new_trait(tcx, self.cur_ty, &[])
109+
substs: Substs::new_trait(tcx, self.cur_ty, &[]),
105110
};
106111

107112
let cause = traits::ObligationCause::misc(self.span, self.fcx.body_id);
@@ -113,15 +118,13 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
113118
return None;
114119
}
115120

116-
let normalized = traits::normalize_projection_type(
117-
&mut selcx,
118-
ty::ProjectionTy {
119-
trait_ref: trait_ref,
120-
item_name: token::intern("Target")
121-
},
122-
cause,
123-
0
124-
);
121+
let normalized = traits::normalize_projection_type(&mut selcx,
122+
ty::ProjectionTy {
123+
trait_ref: trait_ref,
124+
item_name: token::intern("Target"),
125+
},
126+
cause,
127+
0);
125128

126129
debug!("overloaded_deref_ty({:?}) = {:?}", ty, normalized);
127130
self.obligations.extend(normalized.obligations);
@@ -134,17 +137,23 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
134137
}
135138

136139
pub fn finalize<'b, I>(self, pref: LvaluePreference, exprs: I)
137-
where I: IntoIterator<Item=&'b hir::Expr>
140+
where I: IntoIterator<Item = &'b hir::Expr>
138141
{
139-
let methods : Vec<_> = self.steps.iter().map(|&(ty, kind)| {
140-
if let AutoderefKind::Overloaded = kind {
141-
self.fcx.try_overloaded_deref(self.span, None, ty, pref)
142-
} else {
143-
None
144-
}
145-
}).collect();
142+
let methods: Vec<_> = self.steps
143+
.iter()
144+
.map(|&(ty, kind)| {
145+
if let AutoderefKind::Overloaded = kind {
146+
self.fcx.try_overloaded_deref(self.span, None, ty, pref)
147+
} else {
148+
None
149+
}
150+
})
151+
.collect();
146152

147-
debug!("finalize({:?}) - {:?},{:?}", pref, methods, self.obligations);
153+
debug!("finalize({:?}) - {:?},{:?}",
154+
pref,
155+
methods,
156+
self.obligations);
148157

149158
for expr in exprs {
150159
debug!("finalize - finalizing #{} - {:?}", expr.id, expr);
@@ -163,18 +172,14 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> {
163172
}
164173

165174
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
166-
pub fn autoderef(&'a self,
167-
span: Span,
168-
base_ty: Ty<'tcx>)
169-
-> Autoderef<'a, 'gcx, 'tcx>
170-
{
175+
pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'gcx, 'tcx> {
171176
Autoderef {
172177
fcx: self,
173178
steps: vec![],
174179
cur_ty: self.resolve_type_vars_if_possible(&base_ty),
175180
obligations: vec![],
176181
at_start: true,
177-
span: span
182+
span: span,
178183
}
179184
}
180185

@@ -183,28 +188,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
183188
base_expr: Option<&hir::Expr>,
184189
base_ty: Ty<'tcx>,
185190
lvalue_pref: LvaluePreference)
186-
-> Option<MethodCallee<'tcx>>
187-
{
191+
-> Option<MethodCallee<'tcx>> {
188192
debug!("try_overloaded_deref({:?},{:?},{:?},{:?})",
189-
span, base_expr, base_ty, lvalue_pref);
193+
span,
194+
base_expr,
195+
base_ty,
196+
lvalue_pref);
190197
// Try DerefMut first, if preferred.
191198
let method = match (lvalue_pref, self.tcx.lang_items.deref_mut_trait()) {
192199
(PreferMutLvalue, Some(trait_did)) => {
193-
self.lookup_method_in_trait(span, base_expr,
194-
token::intern("deref_mut"), trait_did,
195-
base_ty, None)
200+
self.lookup_method_in_trait(span,
201+
base_expr,
202+
token::intern("deref_mut"),
203+
trait_did,
204+
base_ty,
205+
None)
196206
}
197-
_ => None
207+
_ => None,
198208
};
199209

200210
// Otherwise, fall back to Deref.
201211
let method = match (method, self.tcx.lang_items.deref_trait()) {
202212
(None, Some(trait_did)) => {
203-
self.lookup_method_in_trait(span, base_expr,
204-
token::intern("deref"), trait_did,
205-
base_ty, None)
213+
self.lookup_method_in_trait(span,
214+
base_expr,
215+
token::intern("deref"),
216+
trait_did,
217+
base_ty,
218+
None)
206219
}
207-
(method, _) => method
220+
(method, _) => method,
208221
};
209222

210223
method

0 commit comments

Comments
 (0)