Actually resolve trait bounds on impls. Closes #7266.
This commit is contained in:
parent
817f98085f
commit
57ee34c2bf
@ -609,6 +609,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
|
||||
for ms.iter().advance |m| {
|
||||
check_method(ccx, *m);
|
||||
}
|
||||
vtable::resolve_impl(ccx, it);
|
||||
}
|
||||
ast::item_trait(_, _, ref trait_methods) => {
|
||||
for (*trait_methods).iter().advance |trait_method| {
|
||||
|
@ -478,6 +478,12 @@ pub fn location_info_for_expr(expr: @ast::expr) -> LocationInfo {
|
||||
id: expr.id
|
||||
}
|
||||
}
|
||||
pub fn location_info_for_item(item: @ast::item) -> LocationInfo {
|
||||
LocationInfo {
|
||||
span: item.span,
|
||||
id: item.id
|
||||
}
|
||||
}
|
||||
|
||||
pub fn early_resolve_expr(ex: @ast::expr,
|
||||
fcx: @mut FnCtxt,
|
||||
@ -661,6 +667,27 @@ fn resolve_expr(ex: @ast::expr,
|
||||
visit::visit_expr(ex, (fcx, v));
|
||||
}
|
||||
|
||||
pub fn resolve_impl(ccx: @mut CrateCtxt, impl_item: @ast::item) {
|
||||
let def_id = ast_util::local_def(impl_item.id);
|
||||
match ty::impl_trait_ref(ccx.tcx, def_id) {
|
||||
None => {},
|
||||
Some(trait_ref) => {
|
||||
let infcx = infer::new_infer_ctxt(ccx.tcx);
|
||||
let vcx = VtableContext { ccx: ccx, infcx: infcx };
|
||||
let trait_def = ty::lookup_trait_def(ccx.tcx, trait_ref.def_id);
|
||||
|
||||
let vtbls = lookup_vtables(&vcx,
|
||||
&location_info_for_item(impl_item),
|
||||
*trait_def.generics.type_param_defs,
|
||||
&trait_ref.substs,
|
||||
false);
|
||||
|
||||
// FIXME(#7450): Doesn't work cross crate
|
||||
ccx.vtable_map.insert(impl_item.id, vtbls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect points where a trait-bounded type parameter is
|
||||
// instantiated, resolve the impls for the parameters.
|
||||
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user