From 36909c7575e2ddfe2925423aceb62d82ae8208b2 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 28 Mar 2013 18:55:35 -0700 Subject: [PATCH 1/2] libsyntax: Don't allow `impl (Trait) for Type` (with the parentheses). --- src/libsyntax/parse/parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 51a7f7fbd1c0a..c52162b7f14ed 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3107,11 +3107,15 @@ pub impl Parser { // XXX: clownshoes let ident = special_idents::clownshoes_extensions; + // Special case: if the next identifier that follows is '(', don't + // allow this to be parsed as a trait. + let could_be_trait = *self.token != token::LPAREN; + // Parse the trait. let mut ty = self.parse_ty(false); // Parse traits, if necessary. - let opt_trait = if self.eat_keyword(&~"for") { + let opt_trait = if could_be_trait && self.eat_keyword(&~"for") { // New-style trait. Reinterpret the type as a trait. let opt_trait_ref = match ty.node { ty_path(path, node_id) => { From ef56aa62fb4d672d04e5634bad001d427aa6b553 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 28 Mar 2013 19:12:48 -0700 Subject: [PATCH 2/2] libcore: Add `print` and `println` to the prelude --- src/libcore/prelude.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 0194e8f009c6a..9c3bf04b2a8f5 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -21,6 +21,10 @@ pub use ops::{Shl, Shr, Index}; pub use option::{Option, Some, None}; pub use result::{Result, Ok, Err}; +/* Reexported functions */ + +pub use io::{print, println}; + /* Reexported types and traits */ pub use clone::Clone;