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 | |
| 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')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 1 |
6 files changed, 19 insertions, 11 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b22018c4c76..298cb241bed 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -456,7 +456,7 @@ impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> { #[auto_encode] #[auto_decode] #[deriving_eq] -pub enum rmode { by_ref, by_val, by_copy } +pub enum rmode { by_ref, by_copy } impl to_bytes::IterBytes for rmode { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a7d5c0ce75f..a97007cfb3a 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -148,7 +148,7 @@ pub fn map_crate(diag: span_handler, c: crate) -> map { // the item itself. pub fn map_decoded_item(diag: span_handler, map: map, - path: path, + +path: path, ii: inlined_item) { // I believe it is ok for the local IDs of inlined items from other crates // to overlap with the local ids from this crate, so just generate the ids @@ -171,10 +171,10 @@ pub fn map_decoded_item(diag: span_handler, ii_item(*) | ii_dtor(*) => { /* fallthrough */ } ii_foreign(i) => { cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic, - @/*bad*/ copy path)); + @path)); } ii_method(impl_did, m) => { - map_method(impl_did, @/*bad*/ copy path, m, cx); + map_method(impl_did, @path, m, cx); } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index fb7143f7c14..cd7f9a7cf82 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -72,7 +72,7 @@ pub fn attr_meta(attr: ast::attribute) -> @ast::meta_item { } // Get the meta_items from inside a vector of attributes -pub fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { +pub fn attr_metas(attrs: &[ast::attribute]) -> ~[@ast::meta_item] { do attrs.map |a| { attr_meta(*a) } } @@ -214,7 +214,7 @@ pub fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool { !find_attrs_by_name(attrs, name).is_empty() } -pub fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: &str) +pub fn first_attr_value_str_by_name(attrs: &[ast::attribute], name: &str) -> Option<@~str> { let mattrs = find_attrs_by_name(attrs, name); @@ -304,7 +304,7 @@ pub fn find_linkage_metas(attrs: &[ast::attribute]) -> ~[@ast::meta_item] { } } -pub fn foreign_abi(attrs: ~[ast::attribute]) +pub fn foreign_abi(attrs: &[ast::attribute]) -> Either<~str, ast::foreign_abi> { return match attr::first_attr_value_str_by_name(attrs, ~"abi") { None => { 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) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 92883123782..84656063646 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1710,7 +1710,6 @@ pub fn mode_to_str(m: ast::mode) -> ~str { match m { ast::expl(ast::by_ref) => ~"&&", ast::expl(ast::by_copy) => ~"+", - ast::expl(ast::by_val) => ~"++", ast::infer(_) => ~"" } } |
