diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:36:21 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-01 18:36:21 -0700 |
| commit | 9edbf42a342ced7357fe5ec225975f214d872fbc (patch) | |
| tree | 3ac2106c48eb2997f0795c8bcef20f921407636b /src/libsyntax | |
| parent | 2e3b0c051dca9880bf66b5366dccd2e0bb424b99 (diff) | |
| parent | f86318d63c86568b312f39da20bea67e328c1fc5 (diff) | |
| download | rust-9edbf42a342ced7357fe5ec225975f214d872fbc.tar.gz rust-9edbf42a342ced7357fe5ec225975f214d872fbc.zip | |
rollup merge of #23945: pnkfelix/gate-u-negate
Feature-gate unsigned unary negate. Discussed in weekly meeting here: https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2015-03-31.md#feature-gate--expr and also in the internals thread here: http://internals.rust-lang.org/t/forbid-unsigned-integer/752
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ce1539c62f8..40390765dde 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -388,7 +388,7 @@ pub const CRATE_NODE_ID: NodeId = 0; /// When parsing and doing expansions, we initially give all AST nodes this AST /// node value. Then later, in the renumber pass, we renumber them to have /// small, positive ids. -pub const DUMMY_NODE_ID: NodeId = -1; +pub const DUMMY_NODE_ID: NodeId = !0; /// The AST represents all type param bounds as types. /// typeck::collect::compute_bounds matches these against diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6a00fff1860..c2f2c51ed2c 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -278,9 +278,9 @@ pub struct ExpnInfo { #[derive(PartialEq, Eq, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Copy)] pub struct ExpnId(u32); -pub const NO_EXPANSION: ExpnId = ExpnId(-1); +pub const NO_EXPANSION: ExpnId = ExpnId(!0); // For code appearing from the command line -pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(-2); +pub const COMMAND_LINE_EXPN: ExpnId = ExpnId(!1); impl ExpnId { pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4c01cecc67c..2aa405bf6df 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -152,6 +152,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[ // #23121. Array patterns have some hazards yet. ("slice_patterns", "1.0.0", Active), + + // Allows use of unary negate on unsigned integers, e.g. -e for e: u8 + ("negate_unsigned", "1.0.0", Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -325,6 +328,7 @@ pub struct Features { pub allow_custom_derive: bool, pub simd_ffi: bool, pub unmarked_api: bool, + pub negate_unsigned: bool, /// spans of #![feature] attrs for stable language features. for error reporting pub declared_stable_lang_features: Vec<Span>, /// #![feature] attrs for non-language (library) features @@ -346,6 +350,7 @@ impl Features { allow_custom_derive: false, simd_ffi: false, unmarked_api: false, + negate_unsigned: false, declared_stable_lang_features: Vec::new(), declared_lib_features: Vec::new() } @@ -724,6 +729,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, allow_custom_derive: cx.has_feature("custom_derive"), simd_ffi: cx.has_feature("simd_ffi"), unmarked_api: cx.has_feature("unmarked_api"), + negate_unsigned: cx.has_feature("negate_unsigned"), declared_stable_lang_features: accepted_features, declared_lib_features: unknown_features } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c2f323f98af..3e0c938649d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -3053,7 +3053,7 @@ mod test { #[test] fn test_signed_int_to_string() { let pos_int = ast::LitInt(42, ast::SignedIntLit(ast::TyI32, ast::Plus)); - let neg_int = ast::LitInt((-42) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus)); + let neg_int = ast::LitInt((!42 + 1) as u64, ast::SignedIntLit(ast::TyI32, ast::Minus)); assert_eq!(format!("-{}", lit_to_string(&codemap::dummy_spanned(pos_int))), lit_to_string(&codemap::dummy_spanned(neg_int))); } |
