Skip to content

Commit 3c3bfb4

Browse files
committed
Add more capabilities to typarams bounded by traits with super-builtin-kinds. Close #7083.
1 parent 4ca2e55 commit 3c3bfb4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/librustc/middle/ty.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
23222322
let _i = indenter();
23232323

23242324
let mut tc = TC_ALL;
2325-
for bound in type_param_def.bounds.builtin_bounds.iter() {
2325+
do each_inherited_builtin_bound(cx, type_param_def.bounds) |bound| {
23262326
debug!("tc = %s, bound = %?", tc.to_str(), bound);
23272327
tc = tc - match bound {
23282328
BoundStatic => TypeContents::nonstatic(cx),
@@ -2335,6 +2335,23 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
23352335

23362336
debug!("result = %s", tc.to_str());
23372337
return tc;
2338+
2339+
// Iterates over all builtin bounds on the type parameter def, including
2340+
// those inherited from traits with builtin-kind-supertraits.
2341+
fn each_inherited_builtin_bound(cx: ctxt, bounds: &ParamBounds,
2342+
f: &fn(BuiltinBound)) {
2343+
for bound in bounds.builtin_bounds.iter() {
2344+
f(bound);
2345+
}
2346+
2347+
do each_bound_trait_and_supertraits(cx, bounds.trait_bounds) |trait_ref| {
2348+
let trait_def = lookup_trait_def(cx, trait_ref.def_id);
2349+
for bound in trait_def.bounds.iter() {
2350+
f(bound);
2351+
}
2352+
true
2353+
};
2354+
}
23382355
}
23392356
}
23402357

0 commit comments

Comments
 (0)