Skip to content

Commit 8a9cdda

Browse files
committed
Fix type parameter handling for static default methods. Closes #8654.
1 parent 451de33 commit 8a9cdda

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,6 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
30923092
sp: span,
30933093
defn: ast::def)
30943094
-> ty_param_bounds_and_ty {
3095-
30963095
match defn {
30973096
ast::def_arg(nid, _) | ast::def_local(nid, _) | ast::def_self(nid, _) |
30983097
ast::def_binding(nid, _) => {
@@ -3149,7 +3148,8 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
31493148
let ty_param_count = tpt.generics.type_param_defs.len();
31503149
let ty_substs_len = pth.types.len();
31513150

3152-
debug!("ty_param_count=%? ty_substs_len=%?",
3151+
debug!("tpt=%s ty_param_count=%? ty_substs_len=%?",
3152+
tpt.repr(fcx.tcx()),
31533153
ty_param_count,
31543154
ty_substs_len);
31553155

src/librustc/middle/typeck/collect.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
346346
let substd_type_param_defs = m.generics.type_param_defs.subst(tcx, &substs);
347347
new_type_param_defs.push_all(*substd_type_param_defs);
348348

349-
debug!("static method %s type_param_defs=%s substs=%s",
349+
debug!("static method %s type_param_defs=%s ty=%s, substs=%s",
350350
m.def_id.repr(tcx),
351351
new_type_param_defs.repr(tcx),
352+
ty.repr(tcx),
352353
substs.repr(tcx));
353354

354355
tcx.tcache.insert(m.def_id,
@@ -893,8 +894,8 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
893894
}
894895
ast::item_trait(ref generics, _, ref trait_methods) => {
895896
let _trait_def = trait_def_of_item(ccx, it);
896-
ensure_trait_methods(ccx, it.id);
897897

898+
// Run convert_methods on the provided methods.
898899
let (_, provided_methods) =
899900
split_trait_methods(*trait_methods);
900901
let untransformed_rcvr_ty = ty::mk_self(tcx, local_def(it.id));
@@ -904,6 +905,11 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
904905
untransformed_rcvr_ty,
905906
&ty_generics, generics,
906907
it.vis);
908+
909+
// We need to do this *after* converting methods, since
910+
// convert_methods produces a tcache entry that is wrong for
911+
// static trait methods. This is somewhat unfortunate.
912+
ensure_trait_methods(ccx, it.id);
907913
}
908914
ast::item_struct(struct_def, ref generics) => {
909915
ensure_no_ty_param_bounds(ccx, it.span, generics, "structure");

0 commit comments

Comments
 (0)