about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMarvin Löbel <loebel.marvin@gmail.com>2014-03-11 00:17:46 +0100
committerMarvin Löbel <loebel.marvin@gmail.com>2014-03-14 14:57:31 +0100
commiteb69eb36f8c94d97546f2937e134e93d2f0dcb55 (patch)
tree20da050fec8ddaa7020aaf90bd70e0de7dcdadaa /src/libsyntax
parent6c895d1d588e6cb7ae3f308f709272a11e8278da (diff)
downloadrust-eb69eb36f8c94d97546f2937e134e93d2f0dcb55.tar.gz
rust-eb69eb36f8c94d97546f2937e134e93d2f0dcb55.zip
Added support for type placeholders (explicit requested type
inference in a type with `_` ). This enables partial type inference.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs3
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/libsyntax/print/pprust.rs2
3 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 7fef6da5607..3e600249a7d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -830,8 +830,7 @@ pub enum Ty_ {
     TyPath(Path, Option<OptVec<TyParamBound>>, NodeId), // for #7264; see above
     TyTypeof(@Expr),
     // TyInfer means the type should be inferred instead of it having been
-    // specified. This should only appear at the "top level" of a type and not
-    // nested in one.
+    // specified. This can appear anywhere in a type.
     TyInfer,
 }
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index a4877491990..b4f7238c9c7 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1274,6 +1274,9 @@ impl Parser {
                 bounds
             } = self.parse_path(LifetimeAndTypesAndBounds);
             TyPath(path, bounds, ast::DUMMY_NODE_ID)
+        } else if self.eat(&token::UNDERSCORE) {
+            // TYPE TO BE INFERRED
+            TyInfer
         } else {
             let msg = format!("expected type, found token {:?}", self.token);
             self.fatal(msg);
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 6894d6a2b05..36c39220483 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -504,7 +504,7 @@ pub fn print_type(s: &mut State, ty: &ast::Ty) -> io::IoResult<()> {
             try!(word(&mut s.s, ")"));
         }
         ast::TyInfer => {
-            fail!("print_type shouldn't see a ty_infer");
+            try!(word(&mut s.s, "_"));
         }
     }
     end(s)