about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-16 11:11:31 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-03-18 17:21:16 -0700
commite78f2e2ac577f9c47cd58af52d3bcd496254545d (patch)
treef05564837fe02f676458ea86b705709715c44017 /src/libsyntax/parse
parentc4db4faefaf13ac814f34c2a6cf105b7684de019 (diff)
downloadrust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.tar.gz
rust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.zip
librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer.rs4
-rw-r--r--src/libsyntax/parse/parser.rs15
2 files changed, 12 insertions, 7 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 09ffd79c246..90f51fe9b65 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -811,7 +811,7 @@ pub mod test {
             sp:span {lo:BytePos(21),hi:BytePos(23),expn_info: None}};
         check_equal (tok1,tok2);
         // the 'main' id is already read:
-        check_equal (string_reader.last_pos,BytePos(28));
+        check_equal (copy string_reader.last_pos,BytePos(28));
         // read another token:
         let tok3 = string_reader.next_token();
         let tok4 = TokenAndSpan{
@@ -819,7 +819,7 @@ pub mod test {
             sp:span {lo:BytePos(24),hi:BytePos(28),expn_info: None}};
         check_equal (tok3,tok4);
         // the lparen is already read:
-        check_equal (string_reader.last_pos,BytePos(29))
+        check_equal (copy string_reader.last_pos,BytePos(29))
     }
 
     // check that the given reader produces the desired stream
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 2ea304a0a9b..8a883b73a64 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -412,7 +412,8 @@ pub impl Parser {
 
     fn parse_purity(&self) -> purity {
         if self.eat_keyword(&~"pure") {
-            return pure_fn;
+            // NB: We parse this as impure for bootstrapping purposes.
+            return impure_fn;
         } else if self.eat_keyword(&~"unsafe") {
             return unsafe_fn;
         } else {
@@ -2668,7 +2669,8 @@ pub impl Parser {
 
     fn parse_optional_purity(&self) -> ast::purity {
         if self.eat_keyword(&~"pure") {
-            ast::pure_fn
+            // NB: We parse this as impure for bootstrapping purposes.
+            ast::impure_fn
         } else if self.eat_keyword(&~"unsafe") {
             ast::unsafe_fn
         } else {
@@ -3418,7 +3420,8 @@ pub impl Parser {
 
         let prefix = Path(self.sess.cm.span_to_filename(*self.span));
         let prefix = prefix.dir_path();
-        let mod_path = Path(".").push_many(*self.mod_path_stack);
+        let mod_path_stack = &*self.mod_path_stack;
+        let mod_path = Path(".").push_many(*mod_path_stack);
         let default_path = *self.sess.interner.get(id) + ~".rs";
         let file_path = match ::attr::first_attr_value_str_by_name(
             outer_attrs, ~"path") {
@@ -3505,7 +3508,8 @@ pub impl Parser {
         if self.eat_keyword(&~"fn") { impure_fn }
         else if self.eat_keyword(&~"pure") {
             self.expect_keyword(&~"fn");
-            pure_fn
+            // NB: We parse this as impure for bootstrapping purposes.
+            impure_fn
         } else if self.eat_keyword(&~"unsafe") {
             self.expect_keyword(&~"fn");
             unsafe_fn
@@ -3894,8 +3898,9 @@ pub impl Parser {
                                           maybe_append(attrs, extra_attrs)));
         } else if items_allowed && self.eat_keyword(&~"pure") {
             // PURE FUNCTION ITEM
+            // NB: We parse this as impure for bootstrapping purposes.
             self.expect_keyword(&~"fn");
-            let (ident, item_, extra_attrs) = self.parse_item_fn(pure_fn);
+            let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn);
             return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
                                           visibility,
                                           maybe_append(attrs, extra_attrs)));