]> git.lizzy.rs Git - rust.git/commitdiff
Handle `Sized?` in `type` items.
authorNick Cameron <ncameron@mozilla.com>
Tue, 9 Sep 2014 06:22:20 +0000 (18:22 +1200)
committerNick Cameron <ncameron@mozilla.com>
Tue, 9 Sep 2014 06:22:20 +0000 (18:22 +1200)
Resolves bounds for `type` and adds the warning for 'unbounds' (? bounds) that we have for bounds.

Closes #16888

src/librustc/middle/resolve.rs
src/librustc/middle/typeck/collect.rs
src/test/run-pass/unsized.rs

index 0c8697d31f3c98dd2023d1013d9578b96344b004..ae3a109a505a388a9db7469838e61be9018fd72b 100644 (file)
@@ -3936,6 +3936,7 @@ fn resolve_item(&mut self, item: &Item) {
                                                                item.id,
                                                                ItemRibKind),
                                              |this| {
+                    this.resolve_type_parameters(&generics.ty_params);
                     visit::walk_item(this, item, ());
                 });
             }
index 742d22cc3793ff396dfdde686f2e67f1f69db63e..d1d76734941e8b68cac3fde546cd8f00bd02a144 100644 (file)
@@ -488,7 +488,9 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
                                  generics: &ast::Generics,
                                  thing: &'static str) {
     for ty_param in generics.ty_params.iter() {
-        for bound in ty_param.bounds.iter() {
+        let bounds = ty_param.bounds.iter();
+        let mut bounds = bounds.chain(ty_param.unbound.iter());
+        for bound in bounds {
             match *bound {
                 ast::TraitTyParamBound(..) | ast::UnboxedFnTyParamBound(..) => {
                     // According to accepted RFC #XXX, we should
@@ -1076,9 +1078,10 @@ fn add_unsized_bound(ccx: &CrateCtxt,
                      desc: &str,
                      span: Span) {
     let kind_id = ccx.tcx.lang_items.require(SizedTraitLangItem);
+
     match unbound {
         &Some(ast::TraitTyParamBound(ref tpb)) => {
-            // #FIXME(8559) currently requires the unbound to be built-in.
+            // FIXME(#8559) currently requires the unbound to be built-in.
             let trait_def_id = ty::trait_ref_to_def_id(ccx.tcx, tpb);
             match kind_id {
                 Ok(kind_id) if trait_def_id != kind_id => {
index 0530c8a6ab3dd48fd0b816357631e7604f07c6ec..141d6c88dd96108607083019bdceb5d4cf6928b7 100644 (file)
@@ -24,6 +24,7 @@ trait T8<Sized? X: T2> {}
 enum E<Sized? X> {}
 impl <Sized? X> T1 for S1<X> {}
 fn f<Sized? X>() {}
+type TT<Sized? T> = T;
 
 pub fn main() {
 }