diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-16 22:14:59 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-22 09:01:12 -0700 |
| commit | 46d4bbbae4e52b79c23136b926c1e3b1f187ce4b (patch) | |
| tree | 781fb02e8c6acd62d3cbad5c71bd1404e60d2a31 /src/libsyntax/parse | |
| parent | 42c05fe642efa726dc6cde624b40b638741724ee (diff) | |
| download | rust-46d4bbbae4e52b79c23136b926c1e3b1f187ce4b.tar.gz rust-46d4bbbae4e52b79c23136b926c1e3b1f187ce4b.zip | |
Simplify the AST representation of ty param bounds
Change ast::ty_param_bound so that all ty param bounds are represented as traits, with no special cases for Copy/Send/Owned/Const. typeck::collect generates the special cases. A consequence of this is that code using the #[no_core] attribute can't use the Copy kind/trait. Probably not a big deal? As a side effect, any user-defined traits that happen to be called Copy, etc. in the same module override the built-in Copy trait. r=nmatsakis Closes #2284
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1ee683bdd08..925da063ca6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -24,8 +24,7 @@ use obsolete::{ }; use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move, - bitand, bitor, bitxor, blk, blk_check_mode, bound_const, - bound_copy, bound_send, bound_trait, bound_owned, box, by_copy, + bitand, bitor, bitxor, blk, blk_check_mode, box, by_copy, by_move, by_ref, by_val, capture_clause, capture_item, cdir_dir_mod, cdir_src_mod, cdir_view_item, class_immutable, class_mutable, @@ -2295,19 +2294,20 @@ impl Parser { return spanned(lo, hi, bloc); } + fn mk_ty_path(i: ident) -> @Ty { + @{id: self.get_id(), node: ty_path( + ident_to_path(copy self.last_span, i), + self.get_id()), span: self.last_span} + } + fn parse_optional_ty_param_bounds() -> @~[ty_param_bound] { let mut bounds = ~[]; if self.eat(token::COLON) { while is_ident(self.token) { if is_ident(self.token) { - // XXX: temporary until kinds become traits let maybe_bound = match self.token { token::IDENT(copy sid, _) => { match *self.id_to_str(sid) { - ~"Send" => Some(bound_send), - ~"Copy" => Some(bound_copy), - ~"Const" => Some(bound_const), - ~"Owned" => Some(bound_owned), ~"send" | ~"copy" @@ -2317,7 +2317,7 @@ impl Parser { ObsoleteLowerCaseKindBounds); // Bogus value, but doesn't matter, since // is an error - Some(bound_send) + Some(ty_param_bound(self.mk_ty_path(sid))) } _ => None @@ -2332,11 +2332,11 @@ impl Parser { bounds.push(bound); } None => { - bounds.push(bound_trait(self.parse_ty(false))); + bounds.push(ty_param_bound(self.parse_ty(false))); } } } else { - bounds.push(bound_trait(self.parse_ty(false))); + bounds.push(ty_param_bound(self.parse_ty(false))); } } } |
