diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-16 11:11:31 -0700 | 
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-18 17:21:16 -0700 | 
| commit | e78f2e2ac577f9c47cd58af52d3bcd496254545d (patch) | |
| tree | f05564837fe02f676458ea86b705709715c44017 /src/libsyntax/parse/parser.rs | |
| parent | c4db4faefaf13ac814f34c2a6cf105b7684de019 (diff) | |
| download | rust-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/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 | 
1 files changed, 10 insertions, 5 deletions
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)));  | 
