1
Fork 0

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.
This commit is contained in:
Patrick Walton 2013-03-16 11:11:31 -07:00
parent c4db4faefa
commit e78f2e2ac5
72 changed files with 373 additions and 540 deletions

View file

@ -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)));