diff options
| author | bors <bors@rust-lang.org> | 2014-12-19 06:12:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-19 06:12:01 +0000 |
| commit | 6bdce25e155d846bb9252fa4a18baef7e74cf8bf (patch) | |
| tree | 80099a51ee183950cfa5661299e8dfcdeafd20c0 /src/libsyntax | |
| parent | 840de072085df360733c48396224e9966e2dc72c (diff) | |
| parent | 9b5de39c25b9b19ffcff3d519821b72a31d39d6c (diff) | |
| download | rust-6bdce25e155d846bb9252fa4a18baef7e74cf8bf.tar.gz rust-6bdce25e155d846bb9252fa4a18baef7e74cf8bf.zip | |
auto merge of #19899 : japaric/rust/unops-by-value, r=nikomatsakis
- The following operator traits now take their argument by value: `Neg`, `Not`. This breaks all existing implementations of these traits. - The unary operation `OP a` now "desugars" to `OpTrait::op_method(a)` and consumes its argument. [breaking-change] --- r? @nikomatsakis This PR is very similar to the binops-by-value PR cc @aturon
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index aaa172633be..5243f07f327 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -85,7 +85,7 @@ pub fn is_shift_binop(b: BinOp) -> bool { } } -/// Returns `true` is the binary operator takes its arguments by value +/// Returns `true` if the binary operator takes its arguments by value pub fn is_by_value_binop(b: BinOp) -> bool { match b { BiAdd | BiSub | BiMul | BiDiv | BiRem | BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr => { @@ -95,6 +95,14 @@ pub fn is_by_value_binop(b: BinOp) -> bool { } } +/// Returns `true` if the unary operator takes its argument by value +pub fn is_by_value_unop(u: UnOp) -> bool { + match u { + UnNeg | UnNot => true, + _ => false, + } +} + pub fn unop_to_string(op: UnOp) -> &'static str { match op { UnUniq => "box() ", |
