about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-07-16 20:17:57 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-07-16 20:18:18 -0700
commit0e42004babc7b965a10056084a8ae76c72140a44 (patch)
treedd0484f1854d0c059b61516ee42812f16751fd94 /src/libsyntax
parentd809336d0f5f4efa11336878736aeefe1fbae895 (diff)
downloadrust-0e42004babc7b965a10056084a8ae76c72140a44.tar.gz
rust-0e42004babc7b965a10056084a8ae76c72140a44.zip
introduce an owned kind for data that contains no borrowed ptrs
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs1
-rw-r--r--src/libsyntax/fold.rs2
-rw-r--r--src/libsyntax/parse/parser.rs17
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libsyntax/print/pprust.rs1
-rw-r--r--src/libsyntax/visit.rs2
6 files changed, 16 insertions, 9 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index db70ad12b6e..0e70a58b33b 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -62,6 +62,7 @@ enum ty_param_bound {
     bound_copy,
     bound_send,
     bound_const,
+    bound_owned,
     bound_trait(@ty),
 }
 
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 965caacf07a..53bb9510acd 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -135,7 +135,7 @@ fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
 
 fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
     alt tpb {
-      bound_copy | bound_send | bound_const { tpb }
+      bound_copy | bound_send | bound_const | bound_owned { tpb }
       bound_trait(ty) { bound_trait(fld.fold_ty(ty)) }
     }
 }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index fa0361e797b..dcc8f7430ca 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -16,7 +16,8 @@ import dvec::{dvec, extensions};
 import vec::{push};
 import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
              bitand, bitor, bitxor, blk, blk_check_mode, bound_const,
-             bound_copy, bound_send, bound_trait, box, by_copy, by_move,
+             bound_copy, bound_send, bound_trait, bound_owned,
+             box, by_copy, by_move,
              by_mutbl_ref, by_ref, by_val, capture_clause, capture_item,
              carg_base, carg_ident, cdir_dir_mod, cdir_src_mod,
              cdir_view_item, checked_expr, claimed_expr, class_immutable,
@@ -1935,12 +1936,16 @@ class parser {
         let ident = self.parse_ident();
         if self.eat(token::COLON) {
             while self.token != token::COMMA && self.token != token::GT {
-                if self.eat_keyword(~"send") { push(bounds, bound_send); }
-                else if self.eat_keyword(~"copy") { push(bounds, bound_copy) }
+                if self.eat_keyword(~"send") {
+                    push(bounds, bound_send); }
+                else if self.eat_keyword(~"copy") {
+                    push(bounds, bound_copy) }
                 else if self.eat_keyword(~"const") {
-                    push(bounds, bound_const)
-                }
-                else { push(bounds, bound_trait(self.parse_ty(false))); }
+                    push(bounds, bound_const);
+                } else if self.eat_keyword(~"owned") {
+                    push(bounds, bound_owned);
+                } else {
+                    push(bounds, bound_trait(self.parse_ty(false))); }
             }
         }
         ret {ident: ident, id: self.get_id(), bounds: @bounds};
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index eb8c5b65fa5..949b078d8f0 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -313,7 +313,7 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
         ~"if", ~"iface", ~"impl", ~"import",
         ~"let", ~"log", ~"loop",
         ~"mod", ~"mut",
-        ~"new",
+        ~"new", ~"owned",
         ~"pure", ~"ret",
         ~"true", ~"trait", ~"type",
         ~"unchecked", ~"unsafe",
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 1b9b0ce7f96..937a46a05d3 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1377,6 +1377,7 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) {
               ast::bound_copy { word(s.s, ~"copy"); }
               ast::bound_send { word(s.s, ~"send"); }
               ast::bound_const { word(s.s, ~"const"); }
+              ast::bound_owned { word(s.s, ~"owned"); }
               ast::bound_trait(t) { print_type(s, t); }
             }
         }
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 3e61f3706f9..b6822186b25 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -246,7 +246,7 @@ fn visit_ty_params<E>(tps: ~[ty_param], e: E, v: vt<E>) {
         for vec::each(*tp.bounds) |bound| {
             alt bound {
               bound_trait(t) { v.visit_ty(t, e, v); }
-              bound_copy | bound_send | bound_const { }
+              bound_copy | bound_send | bound_const | bound_owned { }
             }
         }
     }