Skip to content

Commit a17a7c9

Browse files
committed
Miscellaneous reformatting and commenting.
1 parent 9b820d0 commit a17a7c9

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/librustc_typeck/check/_match.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ use syntax::print::pprust;
3030
use syntax::ptr::P;
3131

3232
pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
33-
pat: &ast::Pat, expected: Ty<'tcx>) {
33+
pat: &ast::Pat,
34+
expected: Ty<'tcx>)
35+
{
3436
let fcx = pcx.fcx;
3537
let tcx = pcx.fcx.ccx.tcx;
3638

@@ -90,7 +92,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
9092
}
9193
} else {
9294
span_err!(tcx.sess, begin.span, E0029,
93-
"only char and numeric types are allowed in range");
95+
"only char and numeric types are allowed in range");
9496
}
9597

9698
fcx.write_ty(pat.id, lhs_ty);
@@ -154,8 +156,9 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
154156
check_pat_struct(pcx, pat, path, fields.as_slice(), etc, expected);
155157
}
156158
ast::PatTup(ref elements) => {
157-
let element_tys: Vec<_> = range(0, elements.len()).map(|_| fcx.infcx()
158-
.next_ty_var()).collect();
159+
let element_tys: Vec<_> =
160+
range(0, elements.len()).map(|_| fcx.infcx().next_ty_var())
161+
.collect();
159162
let pat_ty = ty::mk_tup(tcx, element_tys.clone());
160163
fcx.write_ty(pat.id, pat_ty);
161164
demand::eqtype(fcx, pat.span, expected, pat_ty);
@@ -183,8 +186,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
183186
let inner_ty = fcx.infcx().next_ty_var();
184187

185188
let mutbl =
186-
ty::deref(fcx.infcx().shallow_resolve(expected), true)
187-
.map_or(ast::MutImmutable, |mt| mt.mutbl);
189+
ty::deref(fcx.infcx().shallow_resolve(expected), true).map(|mt| mt.mutbl)
190+
.unwrap_or(ast::MutImmutable);
188191

189192
let mt = ty::mt { ty: inner_ty, mutbl: mutbl };
190193
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
@@ -217,8 +220,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
217220
let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span));
218221
ty::mk_slice(tcx, tcx.mk_region(region), ty::mt {
219222
ty: inner_ty,
220-
mutbl: ty::deref(expected_ty, true)
221-
.map_or(ast::MutImmutable, |mt| mt.mutbl)
223+
mutbl: ty::deref(expected_ty, true).map(|mt| mt.mutbl)
224+
.unwrap_or(ast::MutImmutable)
222225
})
223226
}
224227
};

src/librustc_typeck/check/demand.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ use syntax::ast;
1818
use syntax::codemap::Span;
1919
use util::ppaux::Repr;
2020

21-
// Requires that the two types unify, and prints an error message if they
22-
// don't.
21+
// Requires that the two types unify, and prints an error message if
22+
// they don't.
2323
pub fn suptype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
24-
expected: Ty<'tcx>, actual: Ty<'tcx>) {
25-
suptype_with_fn(fcx, sp, false, expected, actual,
24+
ty_expected: Ty<'tcx>, ty_actual: Ty<'tcx>) {
25+
suptype_with_fn(fcx, sp, false, ty_expected, ty_actual,
2626
|sp, e, a, s| { fcx.report_mismatched_types(sp, e, a, s) })
2727
}
2828

29+
/// As `suptype`, but call `handle_err` if unification for subtyping fails.
2930
pub fn suptype_with_fn<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
3031
sp: Span,
3132
b_is_expected: bool,
@@ -48,9 +49,7 @@ pub fn eqtype<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
4849
expected: Ty<'tcx>, actual: Ty<'tcx>) {
4950
match infer::mk_eqty(fcx.infcx(), false, infer::Misc(sp), actual, expected) {
5051
Ok(()) => { /* ok */ }
51-
Err(ref err) => {
52-
fcx.report_mismatched_types(sp, expected, actual, err);
53-
}
52+
Err(ref err) => { fcx.report_mismatched_types(sp, expected, actual, err); }
5453
}
5554
}
5655

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4683,7 +4683,7 @@ impl<'tcx> Repr<'tcx> for Expectation<'tcx> {
46834683
pub fn check_decl_initializer(fcx: &FnCtxt,
46844684
nid: ast::NodeId,
46854685
init: &ast::Expr)
4686-
{
4686+
{
46874687
let local_ty = fcx.local_ty(init.span, nid);
46884688
check_expr_coercable_to_type(fcx, init, local_ty)
46894689
}

0 commit comments

Comments
 (0)