Skip to content

Commit 567e4d9

Browse files
committed
Minor infer/typeck cleanups
1 parent ff536f3 commit 567e4d9

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/rustc/middle/typeck/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ import middle::ty::{tv_vid, vid};
7373
import regionmanip::{replace_bound_regions_in_fn_ty, region_of};
7474
import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
7575
import rscope::{in_binding_rscope, region_scope, type_rscope};
76-
import syntax::ast::{ty_char, ty_i};
77-
import typeck::infer::{root, to_str};
76+
import syntax::ast::ty_i;
7877
import typeck::infer::{unify_methods}; // infcx.set()
7978
import typeck::infer::{force_level, force_none, force_non_region_vars_only,
8079
force_all};
@@ -624,7 +623,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
624623
ast::lit_str(_) { ty::mk_str(tcx) }
625624
ast::lit_int(_, t) { ty::mk_mach_int(tcx, t) }
626625
ast::lit_uint(_, t) { ty::mk_mach_uint(tcx, t) }
627-
ast::lit_int_unsuffixed(v) {
626+
ast::lit_int_unsuffixed(_) {
628627
// An unsuffixed integer literal could have any integral type,
629628
// so we create an integral type variable for it.
630629
ty::mk_var_integral(tcx, fcx.infcx.next_ty_var_integral_id());

src/rustc/middle/typeck/infer.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn intersection(a: int_ty_set, b: int_ty_set) -> int_ty_set {
209209

210210
fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
211211
option<ty::t> {
212-
#debug["type_contained_in(a=%s)", uint::to_str(*a, 10u)];
212+
#debug["single_type_contained_in(a=%s)", uint::to_str(*a, 10u)];
213213

214214
if *a == INT_TY_SET_i8 { ret some(ty::mk_i8(tcx)); }
215215
if *a == INT_TY_SET_u8 { ret some(ty::mk_u8(tcx)); }
@@ -219,15 +219,11 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
219219
if *a == INT_TY_SET_u32 { ret some(ty::mk_u32(tcx)); }
220220
if *a == INT_TY_SET_i64 { ret some(ty::mk_i64(tcx)); }
221221
if *a == INT_TY_SET_u64 { ret some(ty::mk_u64(tcx)); }
222-
if *a == INT_TY_SET_i { ret(some(ty::mk_int(tcx))); }
223-
if *a == INT_TY_SET_u { ret(some(ty::mk_uint(tcx))); }
222+
if *a == INT_TY_SET_i { ret some(ty::mk_int(tcx)); }
223+
if *a == INT_TY_SET_u { ret some(ty::mk_uint(tcx)); }
224224
ret none;
225225
}
226226

227-
fn is_subset_of(a: int_ty_set, b: int_ty_set) -> bool {
228-
(*a & *b) == *a
229-
}
230-
231227
fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t)
232228
-> int_ty_set {
233229

@@ -1647,11 +1643,13 @@ fn super_tys<C:combine>(
16471643
self.infcx().vars_integral(self.infcx().tvib, a_id, b_id).then {||
16481644
ok(a) }
16491645
}
1650-
(ty::ty_var_integral(a_id), _) {
1646+
(ty::ty_var_integral(a_id), ty::ty_int(_)) |
1647+
(ty::ty_var_integral(a_id), ty::ty_uint(_)) {
16511648
self.infcx().vart_integral(self.infcx().tvib, a_id, b).then {||
16521649
ok(a) }
16531650
}
1654-
(_, ty::ty_var_integral(b_id)) {
1651+
(ty::ty_int(_), ty::ty_var_integral(b_id)) |
1652+
(ty::ty_uint(_), ty::ty_var_integral(b_id)) {
16551653
self.infcx().tvar_integral(self.infcx().tvib, a, b_id).then {||
16561654
ok(a) }
16571655
}

0 commit comments

Comments
 (0)