Skip to content

Commit b191628

Browse files
committed
Handle Sized? in type items.
Resolves bounds for `type` and adds the warning for 'unbounds' (? bounds) that we have for bounds. Closes #16888
1 parent 0c73e5f commit b191628

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/librustc/middle/resolve.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3936,6 +3936,7 @@ impl<'a> Resolver<'a> {
39363936
item.id,
39373937
ItemRibKind),
39383938
|this| {
3939+
this.resolve_type_parameters(&generics.ty_params);
39393940
visit::walk_item(this, item, ());
39403941
});
39413942
}

src/librustc/middle/typeck/collect.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
488488
generics: &ast::Generics,
489489
thing: &'static str) {
490490
for ty_param in generics.ty_params.iter() {
491-
for bound in ty_param.bounds.iter() {
491+
let bounds = ty_param.bounds.iter();
492+
let mut bounds = bounds.chain(ty_param.unbound.iter());
493+
for bound in bounds {
492494
match *bound {
493495
ast::TraitTyParamBound(..) | ast::UnboxedFnTyParamBound(..) => {
494496
// According to accepted RFC #XXX, we should
@@ -1076,9 +1078,10 @@ fn add_unsized_bound(ccx: &CrateCtxt,
10761078
desc: &str,
10771079
span: Span) {
10781080
let kind_id = ccx.tcx.lang_items.require(SizedTraitLangItem);
1081+
10791082
match unbound {
10801083
&Some(ast::TraitTyParamBound(ref tpb)) => {
1081-
// #FIXME(8559) currently requires the unbound to be built-in.
1084+
// FIXME(#8559) currently requires the unbound to be built-in.
10821085
let trait_def_id = ty::trait_ref_to_def_id(ccx.tcx, tpb);
10831086
match kind_id {
10841087
Ok(kind_id) if trait_def_id != kind_id => {

src/test/run-pass/unsized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct S1<Sized? X>;
2424
enum E<Sized? X> {}
2525
impl <Sized? X> T1 for S1<X> {}
2626
fn f<Sized? X>() {}
27+
type TT<Sized? T> = T;
2728

2829
pub fn main() {
2930
}

0 commit comments

Comments
 (0)