Skip to content

Commit e8cd29b

Browse files
committed
Apply comments from tjc
1 parent 9963bd2 commit e8cd29b

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/librustc/middle/subst.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,37 @@ pub trait Subst {
2828
// Substitution over types
2929
//
3030
// Because this is so common, we make a special optimization to avoid
31-
// doing anything is `substs` is a no-op. I tried to generalize these
31+
// doing anything if `substs` is a no-op. I tried to generalize these
3232
// to all subst methods but ran into trouble due to the limitations of
3333
// our current method/trait matching algorithm. - Niko
3434

35-
trait Subst1 {
36-
fn subst1(&self, tcx: ty::ctxt, substs: &ty::substs) -> Self;
35+
trait EffectfulSubst {
36+
fn effectfulSubst(&self, tcx: ty::ctxt, substs: &ty::substs) -> Self;
3737
}
3838

3939
impl Subst for ty::t {
4040
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::t {
4141
if ty::substs_is_noop(substs) {
4242
return *self;
4343
} else {
44-
return self.subst1(tcx, substs);
44+
return self.effectfulSubst(tcx, substs);
4545
}
4646
}
4747
}
4848

49-
impl Subst1 for ty::t {
50-
fn subst1(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::t {
49+
impl EffectfulSubst for ty::t {
50+
fn effectfulSubst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::t {
5151
if !ty::type_needs_subst(*self) {
5252
return *self;
5353
}
5454

5555
match ty::get(*self).sty {
56-
ty::ty_param(p) => substs.tps[p.idx],
57-
ty::ty_self(_) => substs.self_ty.get(),
56+
ty::ty_param(p) => {
57+
substs.tps[p.idx]
58+
}
59+
ty::ty_self(_) => {
60+
substs.self_ty.expect("ty_self not found in substs")
61+
}
5862
_ => {
5963
ty::fold_regions_and_ty(
6064
tcx, *self,
@@ -74,8 +78,8 @@ impl Subst1 for ty::t {
7478
}
7579
_ => r
7680
},
77-
|t| t.subst1(tcx, substs),
78-
|t| t.subst1(tcx, substs))
81+
|t| t.effectfulSubst(tcx, substs),
82+
|t| t.effectfulSubst(tcx, substs))
7983
}
8084
}
8185
}

src/librustc/middle/typeck/check/method.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,14 @@ pub impl<'self> LookupContext<'self> {
376376

377377
let tcx = self.tcx();
378378
let mut next_bound_idx = 0; // count only trait bounds
379-
let type_param_def = tcx.ty_param_defs.get(&param_ty.def_id.node);
379+
let type_param_def = match tcx.ty_param_defs.find(&param_ty.def_id.node) {
380+
Some(t) => t,
381+
None => {
382+
tcx.sess.span_bug(
383+
self.expr.span,
384+
fmt!("No param def for %?", param_ty));
385+
}
386+
};
380387

381388
for ty::each_bound_trait_and_supertraits(tcx, type_param_def.bounds)
382389
|bound_trait_ref|

src/librustc/middle/typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
335335
ty::mk_bare_fn(tcx, copy m.fty));
336336

337337
// create the type parameter definitions for `foo`, applying
338-
// the substutition to any traits that appear in their bounds.
338+
// the substitution to any traits that appear in their bounds.
339339

340340
// add in the type parameters from the trait
341341
let mut new_type_param_defs = ~[];

0 commit comments

Comments
 (0)