diff options
| author | bors <bors@rust-lang.org> | 2013-03-13 14:57:55 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-13 14:57:55 -0700 |
| commit | ab5472a7244896df20ceb7a12d9d30afc838f004 (patch) | |
| tree | 1ca658c64f9200eb015762c4d4557f5172cf4837 /src/libsyntax/parse | |
| parent | 67b0f3d5b2d88ea9b5c0a667fc3dbdf794e5c054 (diff) | |
| parent | 852619d5d7ef7e9b9c5e57102e244c575f0c6a8f (diff) | |
| download | rust-ab5472a7244896df20ceb7a12d9d30afc838f004.tar.gz rust-ab5472a7244896df20ceb7a12d9d30afc838f004.zip | |
auto merge of #5307 : nikomatsakis/rust/remove-by-val, r=nikomatsakis
This is done in two steps: First, we make foreign functions not consider modes at all. This is because previously ++ mode was the only way to pass structs to foreign functions and so forth. We also add a lint mode warning if you use `&&` mode in a foreign function, since the semantics of that change (it used to pass a pointer to the C function, now it doesn't). Then, we remove by value and make it equivalent to `+` mode. At the same time, we stop parsing `-` mode and convert all uses of it to `+` mode (it was already being parsed to `+` mode anyhow). This obsoletes pull request #5298. r? @brson
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index ef858a2d5eb..2ade0810dea 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -55,6 +55,7 @@ pub enum ObsoleteSyntax { ObsoletePostFnTySigil, ObsoleteBareFnType, ObsoleteNewtypeEnum, + ObsoleteMode, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -176,6 +177,10 @@ pub impl Parser { "newtype enum", "instead of `enum Foo = int`, write `struct Foo(int)`" ), + ObsoleteMode => ( + "obsolete argument mode", + "replace `-` or `++` mode with `+`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0c38b2f5ab5..77ba27cf423 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -17,7 +17,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound}; use ast::{provided, public, pure_fn, purity}; use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer}; use ast::{bind_by_copy, bitand, bitor, bitxor, blk}; -use ast::{blk_check_mode, box, by_copy, by_ref, by_val}; +use ast::{blk_check_mode, box, by_copy, by_ref}; use ast::{crate, crate_cfg, decl, decl_item}; use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind}; use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again}; @@ -78,6 +78,7 @@ use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; +use parse::obsolete::{ObsoleteMode}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -716,12 +717,15 @@ pub impl Parser { fn parse_arg_mode(&self) -> mode { if self.eat(&token::BINOP(token::MINUS)) { - expl(by_copy) // NDM outdated syntax + self.obsolete(*self.span, ObsoleteMode); + expl(by_copy) } else if self.eat(&token::ANDAND) { expl(by_ref) } else if self.eat(&token::BINOP(token::PLUS)) { if self.eat(&token::BINOP(token::PLUS)) { - expl(by_val) + // ++ mode is obsolete, but we need a snapshot + // to stop parsing it. + expl(by_copy) } else { expl(by_copy) } |
