about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-08-07 13:01:15 -0700
committerBrian Anderson <banderson@mozilla.com>2012-08-07 13:01:22 -0700
commit92ef17aaebb28a8fe6579f669a3ee162c931d9dd (patch)
tree7cc308557c4ae5d86b834e8a3a41adc0ab7dbbe3 /src
parent2772b2e5c7f85e230bcae13c49eb1386afc6cd0e (diff)
downloadrust-92ef17aaebb28a8fe6579f669a3ee162c931d9dd.tar.gz
rust-92ef17aaebb28a8fe6579f669a3ee162c931d9dd.zip
syntax: Fix parsing of inherent traits
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/test/run-pass/impl-implicit-trait.rs20
2 files changed, 22 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c675af6803c..7eb96cbeb59 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2436,7 +2436,8 @@ class parser {
                 !self.token_is_keyword(~"of", self.look_ahead(1)) &&
                 !self.token_is_keyword(~"for", self.look_ahead(1)) &&
                 self.look_ahead(1) != token::BINOP(token::SLASH) &&
-                self.look_ahead(1) != token::LT {
+                (self.look_ahead(1) != token::LT
+                 || (self.look_ahead(1) == token::LT && tps.is_not_empty())) {
 
             // This is a new-style impl declaration.
             ident = @~"__extensions__";     // XXX: clownshoes
diff --git a/src/test/run-pass/impl-implicit-trait.rs b/src/test/run-pass/impl-implicit-trait.rs
new file mode 100644
index 00000000000..e9ca583005c
--- /dev/null
+++ b/src/test/run-pass/impl-implicit-trait.rs
@@ -0,0 +1,20 @@
+enum option_<T> {
+    none_,
+    some_(T),
+}
+
+impl<T> option_<T> {
+    fn foo() -> bool { true }
+}
+
+enum option__ {
+    none__,
+    some__(int)
+}
+
+impl option__ {
+    fn foo() -> bool { true }
+}
+
+fn main() {
+}
\ No newline at end of file