Ensure method names in iface and impl items are unique

Closes #2114
This commit is contained in:
Marijn Haverbeke 2012-04-03 16:30:39 +02:00
parent fabd49bc2d
commit 90d3f0fb5e
2 changed files with 10 additions and 8 deletions

View File

@ -1341,10 +1341,6 @@ impl of combine for glb {
ok(ty::mk_bot(self.infcx().tcx))
}
fn c_regions(a: ty::region, _b: ty::region) -> cres<ty::region> {
ok(a) // FIXME
}
fn c_mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> {
let tcx = self.infcx().tcx;

View File

@ -1727,13 +1727,21 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) {
alt i.node {
ast::item_fn(decl, ty_params, _) {
check_fn(*e, i.span, decl);
ensure_unique(*e, i.span, typaram_names(ty_params), ident_id,
ensure_unique(*e, i.span, ty_params, {|tp| tp.ident},
"type parameter");
}
ast::item_enum(_, ty_params) {
ensure_unique(*e, i.span, typaram_names(ty_params), ident_id,
ensure_unique(*e, i.span, ty_params, {|tp| tp.ident},
"type parameter");
}
ast::item_iface(_, methods) {
ensure_unique(*e, i.span, methods, {|m| m.ident},
"method");
}
ast::item_impl(_, _, _, methods) {
ensure_unique(*e, i.span, methods, {|m| m.ident},
"method");
}
_ { }
}
}
@ -1871,8 +1879,6 @@ fn add_name(ch: checker, sp: span, name: ident) {
ch.seen += [name];
}
fn ident_id(&&i: ident) -> ident { ret i; }
fn ensure_unique<T>(e: env, sp: span, elts: [T], id: fn(T) -> ident,
kind: str) {
let ch = checker(e, kind);