From 3ff81390449cdcad9efd8d377b1a4af06d93a057 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 12:56:10 -0700 Subject: [PATCH 01/10] libsyntax: Stop parsing `pure` and `static` --- src/libcore/rt/sched.rs | 2 +- src/librustpkg/rustpkg.rc | 2 +- src/libsyntax/parse/obsolete.rs | 10 ++++++++++ src/libsyntax/parse/parser.rs | 16 ++++++++++++---- src/test/auxiliary/static_fn_inline_xc_aux.rs | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs index 4a140458fd341..c2c4bedee81ed 100644 --- a/src/libcore/rt/sched.rs +++ b/src/libcore/rt/sched.rs @@ -311,7 +311,7 @@ impl Task { }; } - static priv fn build_start_wrapper(start: ~fn()) -> ~fn() { + priv fn build_start_wrapper(start: ~fn()) -> ~fn() { // XXX: The old code didn't have this extra allocation let wrapper: ~fn() = || { start(); diff --git a/src/librustpkg/rustpkg.rc b/src/librustpkg/rustpkg.rc index c2e3ce04f0645..90d6fcbb8a533 100644 --- a/src/librustpkg/rustpkg.rc +++ b/src/librustpkg/rustpkg.rc @@ -57,7 +57,7 @@ struct PackageScript { } impl PackageScript { - static fn parse(parent: &Path) -> Result { + fn parse(parent: &Path) -> Result { let script = parent.push(~"pkg.rs"); if !os::path_exists(&script) { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 65eb87fb83c05..173ae31f94830 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -59,6 +59,8 @@ pub enum ObsoleteSyntax { ObsoleteImplicitSelf, ObsoleteLifetimeNotation, ObsoleteConstManagedPointer, + ObsoletePurity, + ObsoleteStaticMethod, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -198,6 +200,14 @@ pub impl Parser { "const `@` pointer", "instead of `@const Foo`, write `@Foo`" ), + ObsoletePurity => ( + "pure function", + "remove `pure`" + ), + ObsoleteStaticMethod => ( + "`static` notation", + "`static` is superfluous; remove it" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7ee45eea0def2..4b79e4f20f3bb 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -80,6 +80,7 @@ use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf}; use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer}; +use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod}; 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}; @@ -413,7 +414,7 @@ pub impl Parser { fn parse_purity(&self) -> purity { if self.eat_keyword(&~"pure") { - // NB: We parse this as impure for bootstrapping purposes. + self.obsolete(*self.last_span, ObsoletePurity); return impure_fn; } else if self.eat_keyword(&~"unsafe") { return unsafe_fn; @@ -2684,7 +2685,7 @@ pub impl Parser { fn parse_optional_purity(&self) -> ast::purity { if self.eat_keyword(&~"pure") { - // NB: We parse this as impure for bootstrapping purposes. + self.obsolete(*self.last_span, ObsoletePurity); ast::impure_fn } else if self.eat_keyword(&~"unsafe") { ast::unsafe_fn @@ -3341,8 +3342,14 @@ pub impl Parser { else if self.eat_keyword(&~"priv") { private } else { inherited } } + fn parse_staticness(&self) -> bool { - self.eat_keyword(&~"static") + if self.eat_keyword(&~"static") { + self.obsolete(*self.last_span, ObsoleteStaticMethod); + true + } else { + false + } } // given a termination token and a vector of already-parsed @@ -3580,6 +3587,7 @@ pub impl Parser { fn parse_fn_purity(&self) -> purity { if self.eat_keyword(&~"fn") { impure_fn } else if self.eat_keyword(&~"pure") { + self.obsolete(*self.last_span, ObsoletePurity); self.expect_keyword(&~"fn"); // NB: We parse this as impure for bootstrapping purposes. impure_fn @@ -3979,7 +3987,7 @@ pub impl Parser { } if items_allowed && self.eat_keyword(&~"pure") { // PURE FUNCTION ITEM - // NB: We parse this as impure for bootstrapping purposes. + self.obsolete(*self.last_span, ObsoletePurity); self.expect_keyword(&~"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_, diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs index b1bdfcfcffcb8..5fc6621f18658 100644 --- a/src/test/auxiliary/static_fn_inline_xc_aux.rs +++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs @@ -11,14 +11,14 @@ pub mod num { pub trait Num2 { - static fn from_int2(n: int) -> Self; + fn from_int2(n: int) -> Self; } } pub mod float { impl ::num::Num2 for float { #[inline] - static fn from_int2(n: int) -> float { return n as float; } + fn from_int2(n: int) -> float { return n as float; } } } From 0a2703a6d3dc86db0c13dbfa48bcc0e88fcdd334 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 13:11:03 -0700 Subject: [PATCH 02/10] libsyntax: Introduce the new `assert!` macro; make `assert` no longer a keyword --- src/libcore/at_vec.rs | 2 +- src/libsyntax/ext/expand.rs | 13 +++++++++++++ src/libsyntax/parse/obsolete.rs | 5 ----- src/libsyntax/parse/parser.rs | 6 +----- src/libsyntax/parse/token.rs | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 29b7e35e24b7f..dbc132899d90e 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -291,7 +291,7 @@ pub fn test() { } } - fail_unless!(seq_range(10, 15) == @[10, 11, 12, 13, 14]); + assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]); fail_unless!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]); fail_unless!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 27b35b3784929..46ded7ecf3dd0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -464,6 +464,19 @@ pub fn core_macros() -> ~str { } ) + macro_rules! assert( + ($cond:expr) => { + if !$cond { + ::core::sys::fail_assert(stringify!($cond), file!(), line!()) + } + }; + ($cond:expr, $msg:expr) => { + if !$cond { + ::core::sys::fail_assert($msg, file!(), line!()) + } + } + ) + macro_rules! assert_eq ( ($given:expr , $expected:expr) => ({let given_val = $given; diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 173ae31f94830..a987ae948a48f 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -51,7 +51,6 @@ pub enum ObsoleteSyntax { ObsoleteTraitImplVisibility, ObsoleteRecordType, ObsoleteRecordPattern, - ObsoleteAssertion, ObsoletePostFnTySigil, ObsoleteBareFnType, ObsoleteNewtypeEnum, @@ -165,10 +164,6 @@ pub impl Parser { "structural record pattern", "use a structure instead" ), - ObsoleteAssertion => ( - "assertion", - "use `fail_unless!()` instead" - ), ObsoletePostFnTySigil => ( "fn sigil in postfix position", "Rather than `fn@`, `fn~`, or `fn&`, \ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4b79e4f20f3bb..6f2c0f7ddf5cd 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -76,7 +76,7 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; -use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; +use parse::obsolete::{ObsoletePostFnTySigil}; use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf}; use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer}; @@ -1217,10 +1217,6 @@ pub impl Parser { ex = expr_log(ast::log_other, lvl, e); hi = self.span.hi; self.expect(&token::RPAREN); - } else if self.eat_keyword(&~"assert") { - let e = self.parse_expr(); - ex = expr_copy(e); // whatever - self.obsolete(*self.last_span, ObsoleteAssertion); } else if self.eat_keyword(&~"return") { if can_begin_expr(&*self.token) { let e = self.parse_expr(); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index f5542fa81a6a9..8b78087e16f7d 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -488,7 +488,7 @@ pub fn temporary_keyword_table() -> HashMap<~str, ()> { pub fn strict_keyword_table() -> HashMap<~str, ()> { let words = HashMap(); let keys = ~[ - ~"as", ~"assert", + ~"as", ~"break", ~"const", ~"copy", ~"do", ~"drop", From 8628a5f959ad9231acd815633badbadb1db5225d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 14:00:15 -0700 Subject: [PATCH 03/10] librustc: Remove the `const` declaration form everywhere --- src/libcore/flate.rs | 8 +- src/libcore/gc.rs | 8 +- src/libcore/hashmap.rs | 2 +- src/libcore/libc.rs | 392 +++++++++--------- src/libcore/managed.rs | 6 +- src/libcore/num/cmath.rs | 136 +++--- src/libcore/num/f32.rs | 36 +- src/libcore/num/f64.rs | 52 +-- src/libcore/num/float.rs | 36 +- src/libcore/num/int-template.rs | 8 +- src/libcore/num/int-template/i16.rs | 2 +- src/libcore/num/int-template/i32.rs | 2 +- src/libcore/num/int-template/i64.rs | 2 +- src/libcore/num/int-template/i8.rs | 2 +- src/libcore/num/int-template/int.rs | 2 +- src/libcore/num/strconv.rs | 6 +- src/libcore/num/uint-template.rs | 8 +- src/libcore/num/uint-template/u16.rs | 2 +- src/libcore/num/uint-template/u32.rs | 2 +- src/libcore/num/uint-template/u64.rs | 2 +- src/libcore/num/uint-template/u8.rs | 2 +- src/libcore/num/uint-template/uint.rs | 4 +- src/libcore/os.rs | 60 +-- src/libcore/pipes.rs | 2 +- src/libcore/rand.rs | 2 +- src/libcore/rt/context.rs | 8 +- src/libcore/rt/sched.rs | 6 +- src/libcore/rt/thread_local_storage.rs | 2 +- src/libcore/rt/uv.rs | 4 +- src/libcore/str.rs | 36 +- src/libcore/task/mod.rs | 2 +- src/libcore/trie.rs | 6 +- src/libcore/unstable/extfmt.rs | 12 +- src/libcore/unstable/global.rs | 2 +- src/libcore/unstable/lang.rs | 4 +- src/libfuzzer/cycles.rs | 4 +- src/librust/rust.rc | 4 +- src/librustc/back/abi.rs | 72 ++-- src/librustc/driver/session.rs | 46 +- src/librustc/front/core_inject.rs | 2 +- src/librustc/front/test.rs | 4 +- src/librustc/lib/llvm.rs | 4 +- src/librustc/metadata/common.rs | 122 +++--- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/liveness.rs | 6 +- src/librustc/middle/trans/build.rs | 2 +- src/librustc/middle/trans/common.rs | 6 +- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 52 +-- src/librustc/middle/trans/type_use.rs | 6 +- src/librustc/middle/ty.rs | 60 +-- src/librustc/middle/typeck/astconv.rs | 4 +- src/librustc/middle/typeck/infer/resolve.rs | 34 +- src/librustc/middle/typeck/infer/test.rs | 2 +- src/librustdoc/demo.rs | 2 +- src/librustdoc/desc_to_brief_pass.rs | 3 +- src/librustdoc/extract.rs | 2 +- src/librustdoc/fold.rs | 2 +- src/librustdoc/markdown_pass.rs | 4 +- src/librustdoc/sort_item_type_pass.rs | 2 +- src/librustdoc/tystr_pass.rs | 2 +- src/librustpkg/util.rs | 2 +- src/libstd/arena.rs | 2 +- src/libstd/bigint.rs | 50 +-- src/libstd/bitv.rs | 2 +- src/libstd/cmp.rs | 2 +- src/libstd/deque.rs | 2 +- src/libstd/ebml.rs | 2 +- src/libstd/flatpipes.rs | 6 +- src/libstd/oldmap.rs | 2 +- src/libstd/par.rs | 4 +- src/libstd/rope.rs | 4 +- src/libstd/sha1.rs | 14 +- src/libstd/sort.rs | 6 +- src/libstd/term.rs | 36 +- src/libstd/test.rs | 4 +- src/libstd/time.rs | 6 +- src/libstd/unicode.rs | 262 ++++++------ src/libsyntax/ast.rs | 4 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/parse/prec.rs | 4 +- src/libsyntax/parse/token.rs | 76 ++-- src/libsyntax/print/pp.rs | 2 +- src/libsyntax/print/pprust.rs | 6 +- src/test/auxiliary/cci_const.rs | 6 +- src/test/bench/shootout-nbody.rs | 6 +- src/test/bench/sudoku.rs | 6 +- src/test/compile-fail/bad-const-type.rs | 2 +- .../borrowck-assign-to-constants.rs | 2 +- .../const-cast-different-types.rs | 8 +- .../compile-fail/const-cast-wrong-type.rs | 6 +- src/test/compile-fail/const-recursive.rs | 4 +- src/test/compile-fail/issue-2478.rs | 2 +- src/test/compile-fail/issue-3521-2.rs | 2 +- src/test/compile-fail/issue-3668-2.rs | 2 +- src/test/compile-fail/issue-3668.rs | 2 +- src/test/compile-fail/issue-4523.rs | 2 +- src/test/compile-fail/issue-4968.rs | 2 +- src/test/compile-fail/regions-in-consts.rs | 6 +- src/test/run-pass-fulldeps/qquote.rs | 4 +- src/test/run-pass-fulldeps/quote-tokens.rs | 2 +- src/test/run-pass/conditional-compile.rs | 8 +- src/test/run-pass/const-autoderef-newtype.rs | 4 +- src/test/run-pass/const-autoderef.rs | 8 +- src/test/run-pass/const-big-enum.rs | 6 +- src/test/run-pass/const-cast-ptr-int.rs | 2 +- src/test/run-pass/const-cast.rs | 8 +- src/test/run-pass/const-const.rs | 4 +- src/test/run-pass/const-contents.rs | 12 +- src/test/run-pass/const-cross-crate-const.rs | 6 +- src/test/run-pass/const-cross-crate-extern.rs | 2 +- src/test/run-pass/const-deref.rs | 8 +- src/test/run-pass/const-enum-byref-self.rs | 2 +- src/test/run-pass/const-enum-byref.rs | 2 +- src/test/run-pass/const-enum-cast.rs | 8 +- src/test/run-pass/const-enum-ptr.rs | 2 +- src/test/run-pass/const-enum-struct.rs | 2 +- src/test/run-pass/const-enum-struct2.rs | 2 +- src/test/run-pass/const-enum-structlike.rs | 2 +- src/test/run-pass/const-enum-tuple.rs | 2 +- src/test/run-pass/const-enum-tuple2.rs | 2 +- src/test/run-pass/const-enum-tuplestruct.rs | 2 +- src/test/run-pass/const-enum-tuplestruct2.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 6 +- src/test/run-pass/const-enum-vec-ptr.rs | 2 +- src/test/run-pass/const-enum-vector.rs | 2 +- .../const-expr-in-fixed-length-vec.rs | 2 +- src/test/run-pass/const-expr-in-vec-repeat.rs | 2 +- src/test/run-pass/const-extern-function.rs | 4 +- .../run-pass/const-fields-and-indexing.rs | 17 +- src/test/run-pass/const-fn-val.rs | 2 +- src/test/run-pass/const-negative.rs | 2 +- src/test/run-pass/const-nullary-enum.rs | 4 +- .../run-pass/const-nullary-univariant-enum.rs | 4 +- src/test/run-pass/const-rec-and-tup.rs | 10 +- .../run-pass/const-region-ptrs-noncopy.rs | 4 +- src/test/run-pass/const-region-ptrs.rs | 4 +- src/test/run-pass/const-str-ptr.rs | 6 +- src/test/run-pass/const-struct.rs | 6 +- src/test/run-pass/const-tuple-struct.rs | 2 +- src/test/run-pass/const-unit-struct.rs | 2 +- src/test/run-pass/const-vec-of-fns.rs | 8 +- src/test/run-pass/const-vecs-and-slices.rs | 4 +- src/test/run-pass/const.rs | 2 +- src/test/run-pass/consts-in-patterns.rs | 4 +- src/test/run-pass/explicit-self.rs | 2 +- .../run-pass/export-glob-imports-target.rs | 2 +- src/test/run-pass/foreign-mod-unused-const.rs | 2 +- src/test/run-pass/issue-1660.rs | 2 +- src/test/run-pass/issue-2190-1.rs | 2 +- src/test/run-pass/issue-2428.rs | 2 +- src/test/run-pass/item-attributes.rs | 8 +- src/test/run-pass/mod-merge-hack-inst.rs | 2 +- src/test/run-pass/mod-merge-hack-template.rs | 2 +- src/test/run-pass/resolve-issue-2428.rs | 2 +- src/test/run-pass/shift.rs | 20 +- 157 files changed, 1061 insertions(+), 1063 deletions(-) diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index c830648e9dffe..d9dc89097d03d 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -41,10 +41,10 @@ pub mod rustrt { } } -const lz_none : c_int = 0x0; // Huffman-coding only. -const lz_fast : c_int = 0x1; // LZ with only one probe -const lz_norm : c_int = 0x80; // LZ with 128 probes, "normal" -const lz_best : c_int = 0xfff; // LZ with 4095 probes, "best" +static lz_none : c_int = 0x0; // Huffman-coding only. +static lz_fast : c_int = 0x1; // LZ with only one probe +static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal" +static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best" pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] { do vec::as_const_buf(bytes) |b, len| { diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 3449c5ff4ba45..6b25611466321 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -211,11 +211,11 @@ unsafe fn find_segment_for_frame(fp: *Word, segment: *StackSegment) type Memory = uint; -const task_local_heap: Memory = 1; -const exchange_heap: Memory = 2; -const stack: Memory = 4; +static task_local_heap: Memory = 1; +static exchange_heap: Memory = 2; +static stack: Memory = 4; -const need_cleanup: Memory = exchange_heap | stack; +static need_cleanup: Memory = exchange_heap | stack; // Walks stack, searching for roots of the requested type, and passes // each root to the visitor. diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 64806cd21aaec..f5a97bdaca3ac 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -25,7 +25,7 @@ pub mod linear { use uint; use vec; - const INITIAL_CAPACITY: uint = 32u; // 2^5 + static INITIAL_CAPACITY: uint = 32u; // 2^5 struct Bucket { hash: uint, diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index 2c624a963b130..47eece81ce1c9 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -732,52 +732,52 @@ pub mod consts { #[cfg(target_os = "win32")] pub mod os { pub mod c95 { - pub const EXIT_FAILURE : int = 1; - pub const EXIT_SUCCESS : int = 0; - pub const RAND_MAX : int = 32767; - pub const EOF : int = -1; - pub const SEEK_SET : int = 0; - pub const SEEK_CUR : int = 1; - pub const SEEK_END : int = 2; - pub const _IOFBF : int = 0; - pub const _IONBF : int = 4; - pub const _IOLBF : int = 64; - pub const BUFSIZ : uint = 512_u; - pub const FOPEN_MAX : uint = 20_u; - pub const FILENAME_MAX : uint = 260_u; - pub const L_tmpnam : uint = 16_u; - pub const TMP_MAX : uint = 32767_u; + pub static EXIT_FAILURE : int = 1; + pub static EXIT_SUCCESS : int = 0; + pub static RAND_MAX : int = 32767; + pub static EOF : int = -1; + pub static SEEK_SET : int = 0; + pub static SEEK_CUR : int = 1; + pub static SEEK_END : int = 2; + pub static _IOFBF : int = 0; + pub static _IONBF : int = 4; + pub static _IOLBF : int = 64; + pub static BUFSIZ : uint = 512_u; + pub static FOPEN_MAX : uint = 20_u; + pub static FILENAME_MAX : uint = 260_u; + pub static L_tmpnam : uint = 16_u; + pub static TMP_MAX : uint = 32767_u; } pub mod c99 { } pub mod posix88 { - pub const O_RDONLY : int = 0; - pub const O_WRONLY : int = 1; - pub const O_RDWR : int = 2; - pub const O_APPEND : int = 8; - pub const O_CREAT : int = 256; - pub const O_EXCL : int = 1024; - pub const O_TRUNC : int = 512; - pub const S_IFIFO : int = 4096; - pub const S_IFCHR : int = 8192; - pub const S_IFBLK : int = 12288; - pub const S_IFDIR : int = 16384; - pub const S_IFREG : int = 32768; - pub const S_IFMT : int = 61440; - pub const S_IEXEC : int = 64; - pub const S_IWRITE : int = 128; - pub const S_IREAD : int = 256; - pub const S_IRWXU : int = 448; - pub const S_IXUSR : int = 64; - pub const S_IWUSR : int = 128; - pub const S_IRUSR : int = 256; - pub const F_OK : int = 0; - pub const R_OK : int = 4; - pub const W_OK : int = 2; - pub const X_OK : int = 1; - pub const STDIN_FILENO : int = 0; - pub const STDOUT_FILENO : int = 1; - pub const STDERR_FILENO : int = 2; + pub static O_RDONLY : int = 0; + pub static O_WRONLY : int = 1; + pub static O_RDWR : int = 2; + pub static O_APPEND : int = 8; + pub static O_CREAT : int = 256; + pub static O_EXCL : int = 1024; + pub static O_TRUNC : int = 512; + pub static S_IFIFO : int = 4096; + pub static S_IFCHR : int = 8192; + pub static S_IFBLK : int = 12288; + pub static S_IFDIR : int = 16384; + pub static S_IFREG : int = 32768; + pub static S_IFMT : int = 61440; + pub static S_IEXEC : int = 64; + pub static S_IWRITE : int = 128; + pub static S_IREAD : int = 256; + pub static S_IRWXU : int = 448; + pub static S_IXUSR : int = 64; + pub static S_IWUSR : int = 128; + pub static S_IRUSR : int = 256; + pub static F_OK : int = 0; + pub static R_OK : int = 4; + pub static W_OK : int = 2; + pub static X_OK : int = 1; + pub static STDIN_FILENO : int = 0; + pub static STDOUT_FILENO : int = 1; + pub static STDERR_FILENO : int = 2; } pub mod posix01 { } @@ -786,13 +786,13 @@ pub mod consts { pub mod bsd44 { } pub mod extra { - pub const O_TEXT : int = 16384; - pub const O_BINARY : int = 32768; - pub const O_NOINHERIT: int = 128; + pub static O_TEXT : int = 16384; + pub static O_BINARY : int = 32768; + pub static O_NOINHERIT: int = 128; - pub const ERROR_SUCCESS : int = 0; - pub const ERROR_INSUFFICIENT_BUFFER : int = 122; - pub const INVALID_HANDLE_VALUE: int = -1; + pub static ERROR_SUCCESS : int = 0; + pub static ERROR_INSUFFICIENT_BUFFER : int = 122; + pub static INVALID_HANDLE_VALUE: int = -1; } } @@ -801,56 +801,56 @@ pub mod consts { #[cfg(target_os = "android")] pub mod os { pub mod c95 { - pub const EXIT_FAILURE : int = 1; - pub const EXIT_SUCCESS : int = 0; - pub const RAND_MAX : int = 2147483647; - pub const EOF : int = -1; - pub const SEEK_SET : int = 0; - pub const SEEK_CUR : int = 1; - pub const SEEK_END : int = 2; - pub const _IOFBF : int = 0; - pub const _IONBF : int = 2; - pub const _IOLBF : int = 1; - pub const BUFSIZ : uint = 8192_u; - pub const FOPEN_MAX : uint = 16_u; - pub const FILENAME_MAX : uint = 4096_u; - pub const L_tmpnam : uint = 20_u; - pub const TMP_MAX : uint = 238328_u; + pub static EXIT_FAILURE : int = 1; + pub static EXIT_SUCCESS : int = 0; + pub static RAND_MAX : int = 2147483647; + pub static EOF : int = -1; + pub static SEEK_SET : int = 0; + pub static SEEK_CUR : int = 1; + pub static SEEK_END : int = 2; + pub static _IOFBF : int = 0; + pub static _IONBF : int = 2; + pub static _IOLBF : int = 1; + pub static BUFSIZ : uint = 8192_u; + pub static FOPEN_MAX : uint = 16_u; + pub static FILENAME_MAX : uint = 4096_u; + pub static L_tmpnam : uint = 20_u; + pub static TMP_MAX : uint = 238328_u; } pub mod c99 { } pub mod posix88 { - pub const O_RDONLY : int = 0; - pub const O_WRONLY : int = 1; - pub const O_RDWR : int = 2; - pub const O_APPEND : int = 1024; - pub const O_CREAT : int = 64; - pub const O_EXCL : int = 128; - pub const O_TRUNC : int = 512; - pub const S_IFIFO : int = 4096; - pub const S_IFCHR : int = 8192; - pub const S_IFBLK : int = 24576; - pub const S_IFDIR : int = 16384; - pub const S_IFREG : int = 32768; - pub const S_IFMT : int = 61440; - pub const S_IEXEC : int = 64; - pub const S_IWRITE : int = 128; - pub const S_IREAD : int = 256; - pub const S_IRWXU : int = 448; - pub const S_IXUSR : int = 64; - pub const S_IWUSR : int = 128; - pub const S_IRUSR : int = 256; - pub const F_OK : int = 0; - pub const R_OK : int = 4; - pub const W_OK : int = 2; - pub const X_OK : int = 1; - pub const STDIN_FILENO : int = 0; - pub const STDOUT_FILENO : int = 1; - pub const STDERR_FILENO : int = 2; - pub const F_LOCK : int = 1; - pub const F_TEST : int = 3; - pub const F_TLOCK : int = 2; - pub const F_ULOCK : int = 0; + pub static O_RDONLY : int = 0; + pub static O_WRONLY : int = 1; + pub static O_RDWR : int = 2; + pub static O_APPEND : int = 1024; + pub static O_CREAT : int = 64; + pub static O_EXCL : int = 128; + pub static O_TRUNC : int = 512; + pub static S_IFIFO : int = 4096; + pub static S_IFCHR : int = 8192; + pub static S_IFBLK : int = 24576; + pub static S_IFDIR : int = 16384; + pub static S_IFREG : int = 32768; + pub static S_IFMT : int = 61440; + pub static S_IEXEC : int = 64; + pub static S_IWRITE : int = 128; + pub static S_IREAD : int = 256; + pub static S_IRWXU : int = 448; + pub static S_IXUSR : int = 64; + pub static S_IWUSR : int = 128; + pub static S_IRUSR : int = 256; + pub static F_OK : int = 0; + pub static R_OK : int = 4; + pub static W_OK : int = 2; + pub static X_OK : int = 1; + pub static STDIN_FILENO : int = 0; + pub static STDOUT_FILENO : int = 1; + pub static STDERR_FILENO : int = 2; + pub static F_LOCK : int = 1; + pub static F_TEST : int = 3; + pub static F_TLOCK : int = 2; + pub static F_ULOCK : int = 0; } pub mod posix01 { } @@ -859,65 +859,65 @@ pub mod consts { pub mod bsd44 { } pub mod extra { - pub const O_RSYNC : int = 1052672; - pub const O_DSYNC : int = 4096; - pub const O_SYNC : int = 1052672; + pub static O_RSYNC : int = 1052672; + pub static O_DSYNC : int = 4096; + pub static O_SYNC : int = 1052672; } } #[cfg(target_os = "freebsd")] pub mod os { pub mod c95 { - pub const EXIT_FAILURE : int = 1; - pub const EXIT_SUCCESS : int = 0; - pub const RAND_MAX : int = 2147483647; - pub const EOF : int = -1; - pub const SEEK_SET : int = 0; - pub const SEEK_CUR : int = 1; - pub const SEEK_END : int = 2; - pub const _IOFBF : int = 0; - pub const _IONBF : int = 2; - pub const _IOLBF : int = 1; - pub const BUFSIZ : uint = 1024_u; - pub const FOPEN_MAX : uint = 20_u; - pub const FILENAME_MAX : uint = 1024_u; - pub const L_tmpnam : uint = 1024_u; - pub const TMP_MAX : uint = 308915776_u; + pub static EXIT_FAILURE : int = 1; + pub static EXIT_SUCCESS : int = 0; + pub static RAND_MAX : int = 2147483647; + pub static EOF : int = -1; + pub static SEEK_SET : int = 0; + pub static SEEK_CUR : int = 1; + pub static SEEK_END : int = 2; + pub static _IOFBF : int = 0; + pub static _IONBF : int = 2; + pub static _IOLBF : int = 1; + pub static BUFSIZ : uint = 1024_u; + pub static FOPEN_MAX : uint = 20_u; + pub static FILENAME_MAX : uint = 1024_u; + pub static L_tmpnam : uint = 1024_u; + pub static TMP_MAX : uint = 308915776_u; } pub mod c99 { } pub mod posix88 { - pub const O_RDONLY : int = 0; - pub const O_WRONLY : int = 1; - pub const O_RDWR : int = 2; - pub const O_APPEND : int = 8; - pub const O_CREAT : int = 512; - pub const O_EXCL : int = 2048; - pub const O_TRUNC : int = 1024; - pub const S_IFIFO : int = 4096; - pub const S_IFCHR : int = 8192; - pub const S_IFBLK : int = 24576; - pub const S_IFDIR : int = 16384; - pub const S_IFREG : int = 32768; - pub const S_IFMT : int = 61440; - pub const S_IEXEC : int = 64; - pub const S_IWRITE : int = 128; - pub const S_IREAD : int = 256; - pub const S_IRWXU : int = 448; - pub const S_IXUSR : int = 64; - pub const S_IWUSR : int = 128; - pub const S_IRUSR : int = 256; - pub const F_OK : int = 0; - pub const R_OK : int = 4; - pub const W_OK : int = 2; - pub const X_OK : int = 1; - pub const STDIN_FILENO : int = 0; - pub const STDOUT_FILENO : int = 1; - pub const STDERR_FILENO : int = 2; - pub const F_LOCK : int = 1; - pub const F_TEST : int = 3; - pub const F_TLOCK : int = 2; - pub const F_ULOCK : int = 0; + pub static O_RDONLY : int = 0; + pub static O_WRONLY : int = 1; + pub static O_RDWR : int = 2; + pub static O_APPEND : int = 8; + pub static O_CREAT : int = 512; + pub static O_EXCL : int = 2048; + pub static O_TRUNC : int = 1024; + pub static S_IFIFO : int = 4096; + pub static S_IFCHR : int = 8192; + pub static S_IFBLK : int = 24576; + pub static S_IFDIR : int = 16384; + pub static S_IFREG : int = 32768; + pub static S_IFMT : int = 61440; + pub static S_IEXEC : int = 64; + pub static S_IWRITE : int = 128; + pub static S_IREAD : int = 256; + pub static S_IRWXU : int = 448; + pub static S_IXUSR : int = 64; + pub static S_IWUSR : int = 128; + pub static S_IRUSR : int = 256; + pub static F_OK : int = 0; + pub static R_OK : int = 4; + pub static W_OK : int = 2; + pub static X_OK : int = 1; + pub static STDIN_FILENO : int = 0; + pub static STDOUT_FILENO : int = 1; + pub static STDERR_FILENO : int = 2; + pub static F_LOCK : int = 1; + pub static F_TEST : int = 3; + pub static F_TLOCK : int = 2; + pub static F_ULOCK : int = 0; } pub mod posix01 { } @@ -926,66 +926,66 @@ pub mod consts { pub mod bsd44 { } pub mod extra { - pub const O_SYNC : int = 128; - pub const CTL_KERN: int = 1; - pub const KERN_PROC: int = 14; - pub const KERN_PROC_PATHNAME: int = 12; + pub static O_SYNC : int = 128; + pub static CTL_KERN: int = 1; + pub static KERN_PROC: int = 14; + pub static KERN_PROC_PATHNAME: int = 12; } } #[cfg(target_os = "macos")] pub mod os { pub mod c95 { - pub const EXIT_FAILURE : int = 1; - pub const EXIT_SUCCESS : int = 0; - pub const RAND_MAX : int = 2147483647; - pub const EOF : int = -1; - pub const SEEK_SET : int = 0; - pub const SEEK_CUR : int = 1; - pub const SEEK_END : int = 2; - pub const _IOFBF : int = 0; - pub const _IONBF : int = 2; - pub const _IOLBF : int = 1; - pub const BUFSIZ : uint = 1024_u; - pub const FOPEN_MAX : uint = 20_u; - pub const FILENAME_MAX : uint = 1024_u; - pub const L_tmpnam : uint = 1024_u; - pub const TMP_MAX : uint = 308915776_u; + pub static EXIT_FAILURE : int = 1; + pub static EXIT_SUCCESS : int = 0; + pub static RAND_MAX : int = 2147483647; + pub static EOF : int = -1; + pub static SEEK_SET : int = 0; + pub static SEEK_CUR : int = 1; + pub static SEEK_END : int = 2; + pub static _IOFBF : int = 0; + pub static _IONBF : int = 2; + pub static _IOLBF : int = 1; + pub static BUFSIZ : uint = 1024_u; + pub static FOPEN_MAX : uint = 20_u; + pub static FILENAME_MAX : uint = 1024_u; + pub static L_tmpnam : uint = 1024_u; + pub static TMP_MAX : uint = 308915776_u; } pub mod c99 { } pub mod posix88 { - pub const O_RDONLY : int = 0; - pub const O_WRONLY : int = 1; - pub const O_RDWR : int = 2; - pub const O_APPEND : int = 8; - pub const O_CREAT : int = 512; - pub const O_EXCL : int = 2048; - pub const O_TRUNC : int = 1024; - pub const S_IFIFO : int = 4096; - pub const S_IFCHR : int = 8192; - pub const S_IFBLK : int = 24576; - pub const S_IFDIR : int = 16384; - pub const S_IFREG : int = 32768; - pub const S_IFMT : int = 61440; - pub const S_IEXEC : int = 64; - pub const S_IWRITE : int = 128; - pub const S_IREAD : int = 256; - pub const S_IRWXU : int = 448; - pub const S_IXUSR : int = 64; - pub const S_IWUSR : int = 128; - pub const S_IRUSR : int = 256; - pub const F_OK : int = 0; - pub const R_OK : int = 4; - pub const W_OK : int = 2; - pub const X_OK : int = 1; - pub const STDIN_FILENO : int = 0; - pub const STDOUT_FILENO : int = 1; - pub const STDERR_FILENO : int = 2; - pub const F_LOCK : int = 1; - pub const F_TEST : int = 3; - pub const F_TLOCK : int = 2; - pub const F_ULOCK : int = 0; + pub static O_RDONLY : int = 0; + pub static O_WRONLY : int = 1; + pub static O_RDWR : int = 2; + pub static O_APPEND : int = 8; + pub static O_CREAT : int = 512; + pub static O_EXCL : int = 2048; + pub static O_TRUNC : int = 1024; + pub static S_IFIFO : int = 4096; + pub static S_IFCHR : int = 8192; + pub static S_IFBLK : int = 24576; + pub static S_IFDIR : int = 16384; + pub static S_IFREG : int = 32768; + pub static S_IFMT : int = 61440; + pub static S_IEXEC : int = 64; + pub static S_IWRITE : int = 128; + pub static S_IREAD : int = 256; + pub static S_IRWXU : int = 448; + pub static S_IXUSR : int = 64; + pub static S_IWUSR : int = 128; + pub static S_IRUSR : int = 256; + pub static F_OK : int = 0; + pub static R_OK : int = 4; + pub static W_OK : int = 2; + pub static X_OK : int = 1; + pub static STDIN_FILENO : int = 0; + pub static STDOUT_FILENO : int = 1; + pub static STDERR_FILENO : int = 2; + pub static F_LOCK : int = 1; + pub static F_TEST : int = 3; + pub static F_TLOCK : int = 2; + pub static F_ULOCK : int = 0; } pub mod posix01 { } @@ -994,9 +994,9 @@ pub mod consts { pub mod bsd44 { } pub mod extra { - pub const O_DSYNC : int = 4194304; - pub const O_SYNC : int = 128; - pub const F_FULLFSYNC : int = 51; + pub static O_DSYNC : int = 4194304; + pub static O_SYNC : int = 128; + pub static F_FULLFSYNC : int = 51; } } } diff --git a/src/libcore/managed.rs b/src/libcore/managed.rs index 30ebeda3f5cdc..4eda5e7b5e8c6 100644 --- a/src/libcore/managed.rs +++ b/src/libcore/managed.rs @@ -16,9 +16,9 @@ use ptr; pub mod raw { - pub const RC_EXCHANGE_UNIQUE : uint = (-1) as uint; - pub const RC_MANAGED_UNIQUE : uint = (-2) as uint; - pub const RC_IMMORTAL : uint = 0x77777777; + pub static RC_EXCHANGE_UNIQUE : uint = (-1) as uint; + pub static RC_MANAGED_UNIQUE : uint = (-2) as uint; + pub static RC_IMMORTAL : uint = 0x77777777; use intrinsic::TyDesc; diff --git a/src/libcore/num/cmath.rs b/src/libcore/num/cmath.rs index 2f9d4304cba70..378ebfa53a0c2 100644 --- a/src/libcore/num/cmath.rs +++ b/src/libcore/num/cmath.rs @@ -174,33 +174,33 @@ pub mod c_float_utils { // FIXME obtain machine float/math constants automatically (Issue #1986) pub mod c_float_targ_consts { - pub const radix: uint = 2u; - pub const mantissa_digits: uint = 24u; - pub const digits: uint = 6u; - pub const min_exp: uint = -125u; - pub const max_exp: uint = 128u; - pub const min_10_exp: int = -37; - pub const max_10_exp: int = 38; - // FIXME (#1433): this is wrong, replace with hexadecimal (%a) constants + pub static radix: uint = 2u; + pub static mantissa_digits: uint = 24u; + pub static digits: uint = 6u; + pub static min_exp: uint = -125u; + pub static max_exp: uint = 128u; + pub static min_10_exp: int = -37; + pub static max_10_exp: int = 38; + // FIXME (#1433): this is wrong, replace with hexadecimal (%a) staticants // below. - pub const min_value: f32 = 1.175494e-38_f32; - pub const max_value: f32 = 3.402823e+38_f32; - pub const epsilon: f32 = 0.000000_f32; + pub static min_value: f32 = 1.175494e-38_f32; + pub static max_value: f32 = 3.402823e+38_f32; + pub static epsilon: f32 = 0.000000_f32; } pub mod c_double_targ_consts { - pub const radix: uint = 2u; - pub const mantissa_digits: uint = 53u; - pub const digits: uint = 15u; - pub const min_exp: uint = -1021u; - pub const max_exp: uint = 1024u; - pub const min_10_exp: int = -307; - pub const max_10_exp: int = 308; - // FIXME (#1433): this is wrong, replace with hexadecimal (%a) constants + pub static radix: uint = 2u; + pub static mantissa_digits: uint = 53u; + pub static digits: uint = 15u; + pub static min_exp: uint = -1021u; + pub static max_exp: uint = 1024u; + pub static min_10_exp: int = -307; + pub static max_10_exp: int = 308; + // FIXME (#1433): this is wrong, replace with hexadecimal (%a) staticants // below. - pub const min_value: f64 = 2.225074e-308_f64; - pub const max_value: f64 = 1.797693e+308_f64; - pub const epsilon: f64 = 2.220446e-16_f64; + pub static min_value: f64 = 2.225074e-308_f64; + pub static max_value: f64 = 1.797693e+308_f64; + pub static epsilon: f64 = 2.220446e-16_f64; } /* @@ -208,61 +208,61 @@ pub mod c_double_targ_consts { FIXME use these once they can be parsed (see Issue #1433) pub mod c_float_math_consts { - pub const pi: c_float = 0x1.921fb6p+1_f32; - pub const div_1_pi: c_float = 0x1.45f306p-2_f32; - pub const div_2_pi: c_float = 0x1.45f306p-1_f32; - pub const div_pi_2: c_float = 0x1.921fb6p+0_f32; - pub const div_pi_4: c_float = 0x1.921fb6p-1_f32; - pub const div_2_sqrtpi: c_float = 0x1.20dd76p+0_f32; - pub const e: c_float = 0x1.5bf0a8p+1_f32; - pub const log2_e: c_float = 0x1.715476p+0_f32; - pub const log10_e: c_float = 0x1.bcb7b2p-2_f32; - pub const ln_2: c_float = 0x1.62e43p-1_f32; - pub const ln_10: c_float = 0x1.26bb1cp+1_f32; - pub const sqrt2: c_float = 0x1.6a09e6p+0_f32; - pub const div_1_sqrt2: c_float = 0x1.6a09e6p-1_f32; + pub static pi: c_float = 0x1.921fb6p+1_f32; + pub static div_1_pi: c_float = 0x1.45f306p-2_f32; + pub static div_2_pi: c_float = 0x1.45f306p-1_f32; + pub static div_pi_2: c_float = 0x1.921fb6p+0_f32; + pub static div_pi_4: c_float = 0x1.921fb6p-1_f32; + pub static div_2_sqrtpi: c_float = 0x1.20dd76p+0_f32; + pub static e: c_float = 0x1.5bf0a8p+1_f32; + pub static log2_e: c_float = 0x1.715476p+0_f32; + pub static log10_e: c_float = 0x1.bcb7b2p-2_f32; + pub static ln_2: c_float = 0x1.62e43p-1_f32; + pub static ln_10: c_float = 0x1.26bb1cp+1_f32; + pub static sqrt2: c_float = 0x1.6a09e6p+0_f32; + pub static div_1_sqrt2: c_float = 0x1.6a09e6p-1_f32; } pub mod c_double_math_consts { - pub const pi: c_double = 0x1.921fb54442d18p+1_f64; - pub const div_1_pi: c_double = 0x1.45f306dc9c883p-2_f64; - pub const div_2_pi: c_double = 0x1.45f306dc9c883p-1_f64; - pub const div_pi_2: c_double = 0x1.921fb54442d18p+0_f64; - pub const div_pi_4: c_double = 0x1.921fb54442d18p-1_f64; - pub const div_2_sqrtpi: c_double = 0x1.20dd750429b6dp+0_f64; - pub const e: c_double = 0x1.5bf0a8b145769p+1_f64; - pub const log2_e: c_double = 0x1.71547652b82fep+0_f64; - pub const log10_e: c_double = 0x1.bcb7b1526e50ep-2_f64; - pub const ln_2: c_double = 0x1.62e42fefa39efp-1_f64; - pub const ln_10: c_double = 0x1.26bb1bbb55516p+1_f64; - pub const sqrt2: c_double = 0x1.6a09e667f3bcdp+0_f64; - pub const div_1_sqrt2: c_double = 0x1.6a09e667f3bcdp-1_f64; + pub static pi: c_double = 0x1.921fb54442d18p+1_f64; + pub static div_1_pi: c_double = 0x1.45f306dc9c883p-2_f64; + pub static div_2_pi: c_double = 0x1.45f306dc9c883p-1_f64; + pub static div_pi_2: c_double = 0x1.921fb54442d18p+0_f64; + pub static div_pi_4: c_double = 0x1.921fb54442d18p-1_f64; + pub static div_2_sqrtpi: c_double = 0x1.20dd750429b6dp+0_f64; + pub static e: c_double = 0x1.5bf0a8b145769p+1_f64; + pub static log2_e: c_double = 0x1.71547652b82fep+0_f64; + pub static log10_e: c_double = 0x1.bcb7b1526e50ep-2_f64; + pub static ln_2: c_double = 0x1.62e42fefa39efp-1_f64; + pub static ln_10: c_double = 0x1.26bb1bbb55516p+1_f64; + pub static sqrt2: c_double = 0x1.6a09e667f3bcdp+0_f64; + pub static div_1_sqrt2: c_double = 0x1.6a09e667f3bcdp-1_f64; } pub mod c_float_targ_consts { - pub const radix: uint = 2u; - pub const mantissa_digits: uint = 24u; - pub const digits: uint = 6u; - pub const min_exp: int = -125; - pub const max_exp: int = 128; - pub const min_10_exp: int = -37; - pub const max_10_exp: int = 38; - pub const min_value: c_float = 0x1p-126_f32; - pub const max_value: c_float = 0x1.fffffep+127_f32; - pub const epsilon: c_float = 0x1p-23_f32; + pub static radix: uint = 2u; + pub static mantissa_digits: uint = 24u; + pub static digits: uint = 6u; + pub static min_exp: int = -125; + pub static max_exp: int = 128; + pub static min_10_exp: int = -37; + pub static max_10_exp: int = 38; + pub static min_value: c_float = 0x1p-126_f32; + pub static max_value: c_float = 0x1.fffffep+127_f32; + pub static epsilon: c_float = 0x1p-23_f32; } pub mod c_double_targ_consts { - pub const radix: uint = 2u; - pub const mantissa_digits: uint = 53u; - pub const digits: uint = 15u; - pub const min_exp: int = -1021; - pub const max_exp: int = 1024; - pub const min_10_exp: int = -307; - pub const max_10_exp: int = 308; - pub const min_value: c_double = 0x1p-1022_f64; - pub const max_value: c_double = 0x1.fffffffffffffp+1023_f64; - pub const epsilon: c_double = 0x1p-52_f64; + pub static radix: uint = 2u; + pub static mantissa_digits: uint = 53u; + pub static digits: uint = 15u; + pub static min_exp: int = -1021; + pub static max_exp: int = 1024; + pub static min_10_exp: int = -307; + pub static max_10_exp: int = 308; + pub static min_value: c_double = 0x1p-1022_f64; + pub static max_value: c_double = 0x1.fffffffffffffp+1023_f64; + pub static epsilon: c_double = 0x1p-52_f64; } */ diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 719e5620d02ca..4a8649fb66e78 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -102,11 +102,11 @@ delegate!(fn trunc(n: c_float) -> c_float = cmath::c_float_utils::trunc) // These are not defined inside consts:: for consistency with // the integer types -pub const NaN: f32 = 0.0_f32/0.0_f32; +pub static NaN: f32 = 0.0_f32/0.0_f32; -pub const infinity: f32 = 1.0_f32/0.0_f32; +pub static infinity: f32 = 1.0_f32/0.0_f32; -pub const neg_infinity: f32 = -1.0_f32/0.0_f32; +pub static neg_infinity: f32 = -1.0_f32/0.0_f32; #[inline(always)] pub fn is_NaN(f: f32) -> bool { f != f } @@ -206,45 +206,45 @@ pub fn is_finite(x: f32) -> bool { /* Module: consts */ pub mod consts { // FIXME (requires Issue #1433 to fix): replace with mathematical - // constants from cmath. - /// Archimedes' constant - pub const pi: f32 = 3.14159265358979323846264338327950288_f32; + // staticants from cmath. + /// Archimedes' staticant + pub static pi: f32 = 3.14159265358979323846264338327950288_f32; /// pi/2.0 - pub const frac_pi_2: f32 = 1.57079632679489661923132169163975144_f32; + pub static frac_pi_2: f32 = 1.57079632679489661923132169163975144_f32; /// pi/4.0 - pub const frac_pi_4: f32 = 0.785398163397448309615660845819875721_f32; + pub static frac_pi_4: f32 = 0.785398163397448309615660845819875721_f32; /// 1.0/pi - pub const frac_1_pi: f32 = 0.318309886183790671537767526745028724_f32; + pub static frac_1_pi: f32 = 0.318309886183790671537767526745028724_f32; /// 2.0/pi - pub const frac_2_pi: f32 = 0.636619772367581343075535053490057448_f32; + pub static frac_2_pi: f32 = 0.636619772367581343075535053490057448_f32; /// 2.0/sqrt(pi) - pub const frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517_f32; + pub static frac_2_sqrtpi: f32 = 1.12837916709551257389615890312154517_f32; /// sqrt(2.0) - pub const sqrt2: f32 = 1.41421356237309504880168872420969808_f32; + pub static sqrt2: f32 = 1.41421356237309504880168872420969808_f32; /// 1.0/sqrt(2.0) - pub const frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039_f32; + pub static frac_1_sqrt2: f32 = 0.707106781186547524400844362104849039_f32; /// Euler's number - pub const e: f32 = 2.71828182845904523536028747135266250_f32; + pub static e: f32 = 2.71828182845904523536028747135266250_f32; /// log2(e) - pub const log2_e: f32 = 1.44269504088896340735992468100189214_f32; + pub static log2_e: f32 = 1.44269504088896340735992468100189214_f32; /// log10(e) - pub const log10_e: f32 = 0.434294481903251827651128918916605082_f32; + pub static log10_e: f32 = 0.434294481903251827651128918916605082_f32; /// ln(2.0) - pub const ln_2: f32 = 0.693147180559945309417232121458176568_f32; + pub static ln_2: f32 = 0.693147180559945309417232121458176568_f32; /// ln(10.0) - pub const ln_10: f32 = 2.30258509299404568401799145468436421_f32; + pub static ln_10: f32 = 2.30258509299404568401799145468436421_f32; } #[inline(always)] diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 6a581ddfa9424..8107110e977d8 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -113,27 +113,27 @@ delegate!(fn yn(i: c_int, n: c_double) -> c_double = // These are not defined inside consts:: for consistency with // the integer types -pub const radix: uint = 2u; +pub static radix: uint = 2u; -pub const mantissa_digits: uint = 53u; -pub const digits: uint = 15u; +pub static mantissa_digits: uint = 53u; +pub static digits: uint = 15u; -pub const epsilon: f64 = 2.2204460492503131e-16_f64; +pub static epsilon: f64 = 2.2204460492503131e-16_f64; -pub const min_value: f64 = 2.2250738585072014e-308_f64; -pub const max_value: f64 = 1.7976931348623157e+308_f64; +pub static min_value: f64 = 2.2250738585072014e-308_f64; +pub static max_value: f64 = 1.7976931348623157e+308_f64; -pub const min_exp: int = -1021; -pub const max_exp: int = 1024; +pub static min_exp: int = -1021; +pub static max_exp: int = 1024; -pub const min_10_exp: int = -307; -pub const max_10_exp: int = 308; +pub static min_10_exp: int = -307; +pub static max_10_exp: int = 308; -pub const NaN: f64 = 0.0_f64/0.0_f64; +pub static NaN: f64 = 0.0_f64/0.0_f64; -pub const infinity: f64 = 1.0_f64/0.0_f64; +pub static infinity: f64 = 1.0_f64/0.0_f64; -pub const neg_infinity: f64 = -1.0_f64/0.0_f64; +pub static neg_infinity: f64 = -1.0_f64/0.0_f64; #[inline(always)] pub fn is_NaN(f: f64) -> bool { f != f } @@ -230,43 +230,43 @@ pub mod consts { // FIXME (requires Issue #1433 to fix): replace with mathematical // constants from cmath. /// Archimedes' constant - pub const pi: f64 = 3.14159265358979323846264338327950288_f64; + pub static pi: f64 = 3.14159265358979323846264338327950288_f64; /// pi/2.0 - pub const frac_pi_2: f64 = 1.57079632679489661923132169163975144_f64; + pub static frac_pi_2: f64 = 1.57079632679489661923132169163975144_f64; /// pi/4.0 - pub const frac_pi_4: f64 = 0.785398163397448309615660845819875721_f64; + pub static frac_pi_4: f64 = 0.785398163397448309615660845819875721_f64; /// 1.0/pi - pub const frac_1_pi: f64 = 0.318309886183790671537767526745028724_f64; + pub static frac_1_pi: f64 = 0.318309886183790671537767526745028724_f64; /// 2.0/pi - pub const frac_2_pi: f64 = 0.636619772367581343075535053490057448_f64; + pub static frac_2_pi: f64 = 0.636619772367581343075535053490057448_f64; /// 2.0/sqrt(pi) - pub const frac_2_sqrtpi: f64 = 1.12837916709551257389615890312154517_f64; + pub static frac_2_sqrtpi: f64 = 1.12837916709551257389615890312154517_f64; /// sqrt(2.0) - pub const sqrt2: f64 = 1.41421356237309504880168872420969808_f64; + pub static sqrt2: f64 = 1.41421356237309504880168872420969808_f64; /// 1.0/sqrt(2.0) - pub const frac_1_sqrt2: f64 = 0.707106781186547524400844362104849039_f64; + pub static frac_1_sqrt2: f64 = 0.707106781186547524400844362104849039_f64; /// Euler's number - pub const e: f64 = 2.71828182845904523536028747135266250_f64; + pub static e: f64 = 2.71828182845904523536028747135266250_f64; /// log2(e) - pub const log2_e: f64 = 1.44269504088896340735992468100189214_f64; + pub static log2_e: f64 = 1.44269504088896340735992468100189214_f64; /// log10(e) - pub const log10_e: f64 = 0.434294481903251827651128918916605082_f64; + pub static log10_e: f64 = 0.434294481903251827651128918916605082_f64; /// ln(2.0) - pub const ln_2: f64 = 0.693147180559945309417232121458176568_f64; + pub static ln_2: f64 = 0.693147180559945309417232121458176568_f64; /// ln(10.0) - pub const ln_10: f64 = 2.30258509299404568401799145468436421_f64; + pub static ln_10: f64 = 2.30258509299404568401799145468436421_f64; } #[inline(always)] diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 4e9a1b62b6ece..65a846c6db149 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -41,54 +41,54 @@ pub use f64::{modf, pow, round, sinh, tanh, tgamma, trunc}; pub use f64::signbit; pub use f64::{j0, j1, jn, y0, y1, yn}; -pub const NaN: float = 0.0/0.0; +pub static NaN: float = 0.0/0.0; -pub const infinity: float = 1.0/0.0; +pub static infinity: float = 1.0/0.0; -pub const neg_infinity: float = -1.0/0.0; +pub static neg_infinity: float = -1.0/0.0; /* Module: consts */ pub mod consts { // FIXME (requires Issue #1433 to fix): replace with mathematical - // constants from cmath. - /// Archimedes' constant - pub const pi: float = 3.14159265358979323846264338327950288; + // staticants from cmath. + /// Archimedes' staticant + pub static pi: float = 3.14159265358979323846264338327950288; /// pi/2.0 - pub const frac_pi_2: float = 1.57079632679489661923132169163975144; + pub static frac_pi_2: float = 1.57079632679489661923132169163975144; /// pi/4.0 - pub const frac_pi_4: float = 0.785398163397448309615660845819875721; + pub static frac_pi_4: float = 0.785398163397448309615660845819875721; /// 1.0/pi - pub const frac_1_pi: float = 0.318309886183790671537767526745028724; + pub static frac_1_pi: float = 0.318309886183790671537767526745028724; /// 2.0/pi - pub const frac_2_pi: float = 0.636619772367581343075535053490057448; + pub static frac_2_pi: float = 0.636619772367581343075535053490057448; /// 2.0/sqrt(pi) - pub const frac_2_sqrtpi: float = 1.12837916709551257389615890312154517; + pub static frac_2_sqrtpi: float = 1.12837916709551257389615890312154517; /// sqrt(2.0) - pub const sqrt2: float = 1.41421356237309504880168872420969808; + pub static sqrt2: float = 1.41421356237309504880168872420969808; /// 1.0/sqrt(2.0) - pub const frac_1_sqrt2: float = 0.707106781186547524400844362104849039; + pub static frac_1_sqrt2: float = 0.707106781186547524400844362104849039; /// Euler's number - pub const e: float = 2.71828182845904523536028747135266250; + pub static e: float = 2.71828182845904523536028747135266250; /// log2(e) - pub const log2_e: float = 1.44269504088896340735992468100189214; + pub static log2_e: float = 1.44269504088896340735992468100189214; /// log10(e) - pub const log10_e: float = 0.434294481903251827651128918916605082; + pub static log10_e: float = 0.434294481903251827651128918916605082; /// ln(2.0) - pub const ln_2: float = 0.693147180559945309417232121458176568; + pub static ln_2: float = 0.693147180559945309417232121458176568; /// ln(10.0) - pub const ln_10: float = 2.30258509299404568401799145468436421; + pub static ln_10: float = 2.30258509299404568401799145468436421; } /* diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 4d5ac92311ef8..af56d3e63051a 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -21,11 +21,11 @@ use prelude::*; pub use cmp::{min, max}; -pub const bits : uint = inst::bits; -pub const bytes : uint = (inst::bits / 8); +pub static bits : uint = inst::bits; +pub static bytes : uint = (inst::bits / 8); -pub const min_value: T = (-1 as T) << (bits - 1); -pub const max_value: T = min_value - 1 as T; +pub static min_value: T = (-1 as T) << (bits - 1); +pub static max_value: T = min_value - 1 as T; #[inline(always)] pub fn add(x: T, y: T) -> T { x + y } diff --git a/src/libcore/num/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index 9914807c98f6f..965b6f86a53d6 100644 --- a/src/libcore/num/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs @@ -14,7 +14,7 @@ use num::NumCast; mod inst { pub type T = i16; - pub const bits: uint = ::u16::bits; + pub static bits: uint = ::u16::bits; } impl NumCast for i16 { diff --git a/src/libcore/num/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index c02facd47db25..030bc9c3fdefe 100644 --- a/src/libcore/num/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs @@ -14,7 +14,7 @@ use num::NumCast; mod inst { pub type T = i32; - pub const bits: uint = ::u32::bits; + pub static bits: uint = ::u32::bits; } impl NumCast for i32 { diff --git a/src/libcore/num/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index c285ba23c2789..283de94e9d80e 100644 --- a/src/libcore/num/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs @@ -14,7 +14,7 @@ use num::NumCast; mod inst { pub type T = i64; - pub const bits: uint = ::u64::bits; + pub static bits: uint = ::u64::bits; } impl NumCast for i64 { diff --git a/src/libcore/num/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index 2733a06456326..2f2de358337b7 100644 --- a/src/libcore/num/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs @@ -14,7 +14,7 @@ use num::NumCast; mod inst { pub type T = i8; - pub const bits: uint = ::u8::bits; + pub static bits: uint = ::u8::bits; } impl NumCast for i8 { diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index 29e1e52348eb9..3c89492c7e48e 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -16,7 +16,7 @@ pub use self::inst::pow; mod inst { pub type T = int; - pub const bits: uint = ::uint::bits; + pub static bits: uint = ::uint::bits; /// Returns `base` raised to the power of `exponent` pub fn pow(base: int, exponent: uint) -> int { diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index e39d52d86f2cd..26f0582bfb2ba 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -394,9 +394,9 @@ pub fn to_str_common T { x + y } diff --git a/src/libcore/num/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index bdd9512013621..c73313ac0f34f 100644 --- a/src/libcore/num/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs @@ -16,7 +16,7 @@ mod inst { pub type T = u16; #[allow(non_camel_case_types)] pub type T_SIGNED = i16; - pub const bits: uint = 16; + pub static bits: uint = 16; } impl NumCast for u16 { diff --git a/src/libcore/num/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 7bef51489f221..eb63f1a370aec 100644 --- a/src/libcore/num/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs @@ -16,7 +16,7 @@ mod inst { pub type T = u32; #[allow(non_camel_case_types)] pub type T_SIGNED = i32; - pub const bits: uint = 32; + pub static bits: uint = 32; } impl NumCast for u32 { diff --git a/src/libcore/num/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index fecafe37f3d93..799421dc9767f 100644 --- a/src/libcore/num/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs @@ -16,7 +16,7 @@ mod inst { pub type T = u64; #[allow(non_camel_case_types)] pub type T_SIGNED = i64; - pub const bits: uint = 64; + pub static bits: uint = 64; } impl NumCast for u64 { diff --git a/src/libcore/num/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index 0d48de67334a5..b173d29510c04 100644 --- a/src/libcore/num/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs @@ -18,7 +18,7 @@ mod inst { pub type T = u8; #[allow(non_camel_case_types)] pub type T_SIGNED = i8; - pub const bits: uint = 8; + pub static bits: uint = 8; // Type-specific functions here. These must be reexported by the // parent module so that they appear in core::u8 and not core::u8::u8; diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index f3f27a4e48ab6..741e0f36a333b 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -28,10 +28,10 @@ pub mod inst { #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] - pub const bits: uint = 32; + pub static bits: uint = 32; #[cfg(target_arch = "x86_64")] - pub const bits: uint = 64; + pub static bits: uint = 64; /** * Divide two numbers, return the result, rounded up. diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 17ec9df9d5690..3c2dbf7ea15bc 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -65,8 +65,8 @@ pub mod rustrt { } } -pub const TMPBUF_SZ : uint = 1000u; -const BUF_BYTES : uint = 2048u; +pub static TMPBUF_SZ : uint = 1000u; +static BUF_BYTES : uint = 2048u; pub fn getcwd() -> Path { let buf = [0 as libc::c_char, ..BUF_BYTES]; @@ -1013,8 +1013,8 @@ pub fn last_os_error() -> ~str { args: *c_void) -> DWORD; } - const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; - const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; + static FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; + static FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200; let mut buf = [0 as c_char, ..TMPBUF_SZ]; @@ -1170,11 +1170,11 @@ pub mod consts { pub use os::consts::windows::*; pub mod unix { - pub const FAMILY: &'static str = "unix"; + pub static FAMILY: &'static str = "unix"; } pub mod windows { - pub const FAMILY: &'static str = "windows"; + pub static FAMILY: &'static str = "windows"; } #[cfg(target_os = "macos")] @@ -1193,38 +1193,38 @@ pub mod consts { pub use os::consts::win32::*; pub mod macos { - pub const SYSNAME: &'static str = "macos"; - pub const DLL_PREFIX: &'static str = "lib"; - pub const DLL_SUFFIX: &'static str = ".dylib"; - pub const EXE_SUFFIX: &'static str = ""; + pub static SYSNAME: &'static str = "macos"; + pub static DLL_PREFIX: &'static str = "lib"; + pub static DLL_SUFFIX: &'static str = ".dylib"; + pub static EXE_SUFFIX: &'static str = ""; } pub mod freebsd { - pub const SYSNAME: &'static str = "freebsd"; - pub const DLL_PREFIX: &'static str = "lib"; - pub const DLL_SUFFIX: &'static str = ".so"; - pub const EXE_SUFFIX: &'static str = ""; + pub static SYSNAME: &'static str = "freebsd"; + pub static DLL_PREFIX: &'static str = "lib"; + pub static DLL_SUFFIX: &'static str = ".so"; + pub static EXE_SUFFIX: &'static str = ""; } pub mod linux { - pub const SYSNAME: &'static str = "linux"; - pub const DLL_PREFIX: &'static str = "lib"; - pub const DLL_SUFFIX: &'static str = ".so"; - pub const EXE_SUFFIX: &'static str = ""; + pub static SYSNAME: &'static str = "linux"; + pub static DLL_PREFIX: &'static str = "lib"; + pub static DLL_SUFFIX: &'static str = ".so"; + pub static EXE_SUFFIX: &'static str = ""; } pub mod android { - pub const SYSNAME: &'static str = "android"; - pub const DLL_PREFIX: &'static str = "lib"; - pub const DLL_SUFFIX: &'static str = ".so"; - pub const EXE_SUFFIX: &'static str = ""; + pub static SYSNAME: &'static str = "android"; + pub static DLL_PREFIX: &'static str = "lib"; + pub static DLL_SUFFIX: &'static str = ".so"; + pub static EXE_SUFFIX: &'static str = ""; } pub mod win32 { - pub const SYSNAME: &'static str = "win32"; - pub const DLL_PREFIX: &'static str = ""; - pub const DLL_SUFFIX: &'static str = ".dll"; - pub const EXE_SUFFIX: &'static str = ".exe"; + pub static SYSNAME: &'static str = "win32"; + pub static DLL_PREFIX: &'static str = ""; + pub static DLL_SUFFIX: &'static str = ".dll"; + pub static EXE_SUFFIX: &'static str = ".exe"; } @@ -1241,16 +1241,16 @@ pub mod consts { use os::consts::mips::*; pub mod x86 { - pub const ARCH: &'static str = "x86"; + pub static ARCH: &'static str = "x86"; } pub mod x86_64 { - pub const ARCH: &'static str = "x86_64"; + pub static ARCH: &'static str = "x86_64"; } pub mod arm { - pub const ARCH: &'static str = "arm"; + pub static ARCH: &'static str = "arm"; } pub mod mips { - pub const ARCH: &'static str = "mips"; + pub static ARCH: &'static str = "mips"; } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 710f2c51ee8c7..9cf3e4d611457 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -96,7 +96,7 @@ use task; use vec; #[doc(hidden)] -const SPIN_COUNT: uint = 0; +static SPIN_COUNT: uint = 0; macro_rules! move_it ( { $x:expr } => ( unsafe { let y = *ptr::addr_of(&($x)); y } ) diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index fbdda02dcdc78..3085269f692ef 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -313,7 +313,7 @@ impl RngUtil for @Rng { let u1 = self.next() as f64; let u2 = self.next() as f64; let u3 = self.next() as f64; - const scale : f64 = (u32::max_value as f64) + 1.0f64; + static scale : f64 = (u32::max_value as f64) + 1.0f64; return ((u1 / scale + u2) / scale + u3) / scale; } diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs index 4150366dacfa3..4798399d5e948 100644 --- a/src/libcore/rt/context.rs +++ b/src/libcore/rt/context.rs @@ -112,10 +112,10 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp: *mut uint) { // Redefinitions from regs.h - const RUSTRT_ARG0: uint = 3; - const RUSTRT_RSP: uint = 1; - const RUSTRT_IP: uint = 8; - const RUSTRT_RBP: uint = 2; + static RUSTRT_ARG0: uint = 3; + static RUSTRT_RSP: uint = 1; + static RUSTRT_IP: uint = 8; + static RUSTRT_RBP: uint = 2; let sp = align_down(sp); let sp = mut_offset(sp, -1); diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs index c2c4bedee81ed..0beadb30d42c6 100644 --- a/src/libcore/rt/sched.rs +++ b/src/libcore/rt/sched.rs @@ -282,7 +282,7 @@ pub impl Scheduler { } } -const TASK_MIN_STACK_SIZE: uint = 10000000; // XXX: Too much stack +static TASK_MIN_STACK_SIZE: uint = 10000000; // XXX: Too much stack pub struct Task { /// The task entry point, saved here for later destruction @@ -481,7 +481,7 @@ fn test_swap_tasks() { #[bench] #[test] #[ignore(reason = "long test")] fn test_run_a_lot_of_tasks_queued() { do run_in_bare_thread { - const MAX: int = 1000000; + static MAX: int = 1000000; let mut count = 0; let count_ptr: *mut int = &mut count; @@ -514,7 +514,7 @@ fn test_run_a_lot_of_tasks_queued() { #[bench] #[test] #[ignore(reason = "too much stack allocation")] fn test_run_a_lot_of_tasks_direct() { do run_in_bare_thread { - const MAX: int = 100000; + static MAX: int = 100000; let mut count = 0; let count_ptr: *mut int = &mut count; diff --git a/src/libcore/rt/thread_local_storage.rs b/src/libcore/rt/thread_local_storage.rs index e10551b6b893b..5af8c79fd635c 100644 --- a/src/libcore/rt/thread_local_storage.rs +++ b/src/libcore/rt/thread_local_storage.rs @@ -56,7 +56,7 @@ pub type Key = DWORD; #[cfg(windows)] pub unsafe fn create(key: &mut Key) { - const TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF; + static TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF; *key = unsafe { TlsAlloc() }; fail_unless!(*key != TLS_OUT_OF_INDEXES); } diff --git a/src/libcore/rt/uv.rs b/src/libcore/rt/uv.rs index 4d87bdb02e81a..19ce04bd66b5c 100644 --- a/src/libcore/rt/uv.rs +++ b/src/libcore/rt/uv.rs @@ -396,7 +396,7 @@ pub impl TcpWatcher { data.connect_cb = Some(cb); unsafe { - const BACKLOG: c_int = 128; // XXX should be configurable + static BACKLOG: c_int = 128; // XXX should be configurable // XXX: This can probably fail fail_unless!(0 == uvll::listen(self.native_handle(), BACKLOG, connection_cb)); @@ -848,7 +848,7 @@ fn connect_read() { #[ignore(reason = "ffi struct issues")] fn listen() { do run_in_bare_thread() { - const MAX: int = 10; + static MAX: int = 10; let mut loop_ = Loop::new(); let mut server_tcp_watcher = { TcpWatcher::new(&mut loop_) }; let addr = Ipv4(127, 0, 0, 1, 2925); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index fc4d1e387dd86..f26d9ee349264 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1907,26 +1907,26 @@ pub fn any_between(s: &str, start: uint, end: uint, } // UTF-8 tags and ranges -const tag_cont_u8: u8 = 128u8; -const tag_cont: uint = 128u; -const max_one_b: uint = 128u; -const tag_two_b: uint = 192u; -const max_two_b: uint = 2048u; -const tag_three_b: uint = 224u; -const max_three_b: uint = 65536u; -const tag_four_b: uint = 240u; -const max_four_b: uint = 2097152u; -const tag_five_b: uint = 248u; -const max_five_b: uint = 67108864u; -const tag_six_b: uint = 252u; +static tag_cont_u8: u8 = 128u8; +static tag_cont: uint = 128u; +static max_one_b: uint = 128u; +static tag_two_b: uint = 192u; +static max_two_b: uint = 2048u; +static tag_three_b: uint = 224u; +static max_three_b: uint = 65536u; +static tag_four_b: uint = 240u; +static max_four_b: uint = 2097152u; +static tag_five_b: uint = 248u; +static max_five_b: uint = 67108864u; +static tag_six_b: uint = 252u; // Constants used for converting strs to floats -pub const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; -pub const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, - 'n' as u8, 'f' as u8]; -pub const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, - 'n' as u8, 'f' as u8]; -pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; +pub static inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; +pub static positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, + 'n' as u8, 'f' as u8]; +pub static negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, + 'n' as u8, 'f' as u8]; +pub static nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; /** * Work with the byte buffer of a string. diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index a38b44afb513f..a6646605b752d 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -1160,7 +1160,7 @@ fn test_child_doesnt_ref_parent() { // climbing the task tree to dereference each ancestor. (See #1789) // (well, it would if the constant were 8000+ - I lowered it to be more // valgrind-friendly. try this at home, instead..!) - const generations: uint = 16; + static generations: uint = 16; fn child_no(x: uint) -> ~fn() { return || { if x < generations { diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 258de5c81db1a..5d6c68d00f68d 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -14,9 +14,9 @@ use prelude::*; // FIXME: #3469: need to manually update TrieNode when SHIFT changes // FIXME: #5244: need to manually update the TrieNode constructor -const SHIFT: uint = 4; -const SIZE: uint = 1 << SHIFT; -const MASK: uint = SIZE - 1; +static SHIFT: uint = 4; +static SIZE: uint = 1 << SHIFT; +static MASK: uint = SIZE - 1; enum Child { Internal(~TrieNode), diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index 2571dca1c96c7..029205f6bfae3 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -687,12 +687,12 @@ pub mod rt { use uint; use vec; - pub const flag_none : u32 = 0u32; - pub const flag_left_justify : u32 = 0b00000000000001u32; - pub const flag_left_zero_pad : u32 = 0b00000000000010u32; - pub const flag_space_for_sign : u32 = 0b00000000000100u32; - pub const flag_sign_always : u32 = 0b00000000001000u32; - pub const flag_alternate : u32 = 0b00000000010000u32; + pub static flag_none : u32 = 0u32; + pub static flag_left_justify : u32 = 0b00000000000001u32; + pub static flag_left_zero_pad : u32 = 0b00000000000010u32; + pub static flag_space_for_sign : u32 = 0b00000000000100u32; + pub static flag_sign_always : u32 = 0b00000000001000u32; + pub static flag_alternate : u32 = 0b00000000010000u32; pub enum Count { CountIs(uint), CountImplied, } diff --git a/src/libcore/unstable/global.rs b/src/libcore/unstable/global.rs index 660336055590e..32e1b35d7db9f 100644 --- a/src/libcore/unstable/global.rs +++ b/src/libcore/unstable/global.rs @@ -159,7 +159,7 @@ impl Drop for GlobalState { fn get_global_state() -> Exclusive { - const POISON: int = -1; + static POISON: int = -1; // FIXME #4728: Doing atomic_cxchg to initialize the global state // lazily, which wouldn't be necessary with a runtime written diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index db0b1cc33cd67..ea5dfa0a530c3 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -22,9 +22,9 @@ use cast::transmute; pub type rust_task = c_void; #[cfg(target_word_size = "32")] -pub const FROZEN_BIT: uint = 0x80000000; +pub static FROZEN_BIT: uint = 0x80000000; #[cfg(target_word_size = "64")] -pub const FROZEN_BIT: uint = 0x8000000000000000; +pub static FROZEN_BIT: uint = 0x8000000000000000; pub mod rustrt { use libc::{c_char, uintptr_t}; diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index 7ea74b369404c..dcf9a493c558a 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -26,8 +26,8 @@ fn choice(r : rand::rng, v : ~[const T]) -> T { fn likelihood(r : rand::rng, k : uint, n : uint) -> bool { under(r, n) < k } -const iters : uint = 1000u; -const vlen : uint = 100u; +static iters : uint = 1000u; +static vlen : uint = 100u; enum maybe_pointy { none, diff --git a/src/librust/rust.rc b/src/librust/rust.rc index 3ca4ef5efbd95..2ebc162eb6aec 100644 --- a/src/librust/rust.rc +++ b/src/librust/rust.rc @@ -54,7 +54,7 @@ struct Command { usage_full: UsageSource/&self } -const commands: &'static [Command/&static] = &[ +static commands: &'static [Command/&static] = &[ Command{ cmd: "build", action: Exec("rustc"), @@ -199,7 +199,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage { } fn usage() { - const indent: uint = 8; + static indent: uint = 8; io::print( "The rust tool is a convenience for managing rust source code.\n\ diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs index 06625c1ddd965..70a029ede6f8d 100644 --- a/src/librustc/back/abi.rs +++ b/src/librustc/back/abi.rs @@ -11,64 +11,64 @@ -pub const rc_base_field_refcnt: uint = 0u; +pub static rc_base_field_refcnt: uint = 0u; -pub const task_field_refcnt: uint = 0u; +pub static task_field_refcnt: uint = 0u; -pub const task_field_stk: uint = 2u; +pub static task_field_stk: uint = 2u; -pub const task_field_runtime_sp: uint = 3u; +pub static task_field_runtime_sp: uint = 3u; -pub const task_field_rust_sp: uint = 4u; +pub static task_field_rust_sp: uint = 4u; -pub const task_field_gc_alloc_chain: uint = 5u; +pub static task_field_gc_alloc_chain: uint = 5u; -pub const task_field_dom: uint = 6u; +pub static task_field_dom: uint = 6u; -pub const n_visible_task_fields: uint = 7u; +pub static n_visible_task_fields: uint = 7u; -pub const dom_field_interrupt_flag: uint = 1u; +pub static dom_field_interrupt_flag: uint = 1u; -pub const frame_glue_fns_field_mark: uint = 0u; +pub static frame_glue_fns_field_mark: uint = 0u; -pub const frame_glue_fns_field_drop: uint = 1u; +pub static frame_glue_fns_field_drop: uint = 1u; -pub const frame_glue_fns_field_reloc: uint = 2u; +pub static frame_glue_fns_field_reloc: uint = 2u; -pub const box_field_refcnt: uint = 0u; -pub const box_field_tydesc: uint = 1u; -pub const box_field_prev: uint = 2u; -pub const box_field_next: uint = 3u; -pub const box_field_body: uint = 4u; +pub static box_field_refcnt: uint = 0u; +pub static box_field_tydesc: uint = 1u; +pub static box_field_prev: uint = 2u; +pub static box_field_next: uint = 3u; +pub static box_field_body: uint = 4u; -pub const general_code_alignment: uint = 16u; +pub static general_code_alignment: uint = 16u; -pub const tydesc_field_size: uint = 0u; -pub const tydesc_field_align: uint = 1u; -pub const tydesc_field_take_glue: uint = 2u; -pub const tydesc_field_drop_glue: uint = 3u; -pub const tydesc_field_free_glue: uint = 4u; -pub const tydesc_field_visit_glue: uint = 5u; -pub const tydesc_field_shape: uint = 6u; -pub const tydesc_field_shape_tables: uint = 7u; -pub const n_tydesc_fields: uint = 8u; +pub static tydesc_field_size: uint = 0u; +pub static tydesc_field_align: uint = 1u; +pub static tydesc_field_take_glue: uint = 2u; +pub static tydesc_field_drop_glue: uint = 3u; +pub static tydesc_field_free_glue: uint = 4u; +pub static tydesc_field_visit_glue: uint = 5u; +pub static tydesc_field_shape: uint = 6u; +pub static tydesc_field_shape_tables: uint = 7u; +pub static n_tydesc_fields: uint = 8u; // The two halves of a closure: code and environment. -pub const fn_field_code: uint = 0u; -pub const fn_field_box: uint = 1u; +pub static fn_field_code: uint = 0u; +pub static fn_field_box: uint = 1u; -pub const vec_elt_fill: uint = 0u; +pub static vec_elt_fill: uint = 0u; -pub const vec_elt_alloc: uint = 1u; +pub static vec_elt_alloc: uint = 1u; -pub const vec_elt_elems: uint = 2u; +pub static vec_elt_elems: uint = 2u; -pub const slice_elt_base: uint = 0u; -pub const slice_elt_len: uint = 1u; +pub static slice_elt_base: uint = 0u; +pub static slice_elt_len: uint = 1u; -pub const worst_case_glue_call_args: uint = 7u; +pub static worst_case_glue_call_args: uint = 7u; -pub const abi_version: uint = 1u; +pub static abi_version: uint = 1u; pub fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; } diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index caf4689688b10..28ebc3f424ef0 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -44,29 +44,29 @@ pub struct config { float_type: float_ty } -pub const verbose: uint = 1 << 0; -pub const time_passes: uint = 1 << 1; -pub const count_llvm_insns: uint = 1 << 2; -pub const time_llvm_passes: uint = 1 << 3; -pub const trans_stats: uint = 1 << 4; -pub const no_asm_comments: uint = 1 << 5; -pub const no_verify: uint = 1 << 6; -pub const trace: uint = 1 << 7; -pub const coherence: uint = 1 << 8; -pub const borrowck_stats: uint = 1 << 9; -pub const borrowck_note_pure: uint = 1 << 10; -pub const borrowck_note_loan: uint = 1 << 11; -pub const no_landing_pads: uint = 1 << 12; -pub const debug_llvm: uint = 1 << 13; -pub const count_type_sizes: uint = 1 << 14; -pub const meta_stats: uint = 1 << 15; -pub const no_opt: uint = 1 << 16; -pub const no_monomorphic_collapse: uint = 1 << 17; -pub const gc: uint = 1 << 18; -pub const jit: uint = 1 << 19; -pub const debug_info: uint = 1 << 20; -pub const extra_debug_info: uint = 1 << 21; -pub const static: uint = 1 << 22; +pub static verbose: uint = 1 << 0; +pub static time_passes: uint = 1 << 1; +pub static count_llvm_insns: uint = 1 << 2; +pub static time_llvm_passes: uint = 1 << 3; +pub static trans_stats: uint = 1 << 4; +pub static no_asm_comments: uint = 1 << 5; +pub static no_verify: uint = 1 << 6; +pub static trace: uint = 1 << 7; +pub static coherence: uint = 1 << 8; +pub static borrowck_stats: uint = 1 << 9; +pub static borrowck_note_pure: uint = 1 << 10; +pub static borrowck_note_loan: uint = 1 << 11; +pub static no_landing_pads: uint = 1 << 12; +pub static debug_llvm: uint = 1 << 13; +pub static count_type_sizes: uint = 1 << 14; +pub static meta_stats: uint = 1 << 15; +pub static no_opt: uint = 1 << 16; +pub static no_monomorphic_collapse: uint = 1 << 17; +pub static gc: uint = 1 << 18; +pub static jit: uint = 1 << 19; +pub static debug_info: uint = 1 << 20; +pub static extra_debug_info: uint = 1 << 21; +pub static static: uint = 1 << 22; pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] { ~[(~"verbose", ~"in general, enable more debug printouts", verbose), diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index 0766dcd245086..6e134d25ff2cf 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -19,7 +19,7 @@ use syntax::codemap; use syntax::codemap::dummy_sp; use syntax::fold; -const CORE_VERSION: &'static str = "0.6"; +static CORE_VERSION: &'static str = "0.6"; pub fn maybe_inject_libcore_ref(sess: Session, crate: @ast::crate) -> @ast::crate { diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index d7c1bc9b2d32d..401005310107d 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -257,7 +257,7 @@ mod __test { std::test::test_main_static(::os::args(), tests) } - const tests : &'static [std::test::TestDescAndFn] = &[ + static tests : &'static [std::test::TestDescAndFn] = &[ ... the list of tests in the crate ... ]; } @@ -360,7 +360,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item { let test_descs = mk_test_descs(cx); (quote_item!( - pub const tests : &'static [self::std::test::TestDescAndFn] = + pub static tests : &'static [self::std::test::TestDescAndFn] = $test_descs ; )).get() diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 5cdfe6a49f723..e01c4ae7d727d 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -20,8 +20,8 @@ use std::oldmap::HashMap; pub type Opcode = u32; pub type Bool = c_uint; -pub const True: Bool = 1 as Bool; -pub const False: Bool = 0 as Bool; +pub static True: Bool = 1 as Bool; +pub static False: Bool = 0 as Bool; // Consts for the LLVM CallConv type, pre-cast to uint. diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 38b76c4ace29f..920631a55b4ec 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -11,84 +11,84 @@ // EBML enum definitions and utils shared by the encoder and decoder -pub const tag_items: uint = 0x02u; +pub static tag_items: uint = 0x02u; -pub const tag_paths_data_name: uint = 0x04u; +pub static tag_paths_data_name: uint = 0x04u; -pub const tag_def_id: uint = 0x07u; +pub static tag_def_id: uint = 0x07u; -pub const tag_items_data: uint = 0x08u; +pub static tag_items_data: uint = 0x08u; -pub const tag_items_data_item: uint = 0x09u; +pub static tag_items_data_item: uint = 0x09u; -pub const tag_items_data_item_family: uint = 0x0au; +pub static tag_items_data_item_family: uint = 0x0au; -pub const tag_items_data_item_ty_param_bounds: uint = 0x0bu; +pub static tag_items_data_item_ty_param_bounds: uint = 0x0bu; -pub const tag_items_data_item_type: uint = 0x0cu; +pub static tag_items_data_item_type: uint = 0x0cu; -pub const tag_items_data_item_symbol: uint = 0x0du; +pub static tag_items_data_item_symbol: uint = 0x0du; -pub const tag_items_data_item_variant: uint = 0x0eu; +pub static tag_items_data_item_variant: uint = 0x0eu; -pub const tag_items_data_parent_item: uint = 0x0fu; +pub static tag_items_data_parent_item: uint = 0x0fu; -pub const tag_index: uint = 0x11u; +pub static tag_index: uint = 0x11u; -pub const tag_index_buckets: uint = 0x12u; +pub static tag_index_buckets: uint = 0x12u; -pub const tag_index_buckets_bucket: uint = 0x13u; +pub static tag_index_buckets_bucket: uint = 0x13u; -pub const tag_index_buckets_bucket_elt: uint = 0x14u; +pub static tag_index_buckets_bucket_elt: uint = 0x14u; -pub const tag_index_table: uint = 0x15u; +pub static tag_index_table: uint = 0x15u; -pub const tag_meta_item_name_value: uint = 0x18u; +pub static tag_meta_item_name_value: uint = 0x18u; -pub const tag_meta_item_name: uint = 0x19u; +pub static tag_meta_item_name: uint = 0x19u; -pub const tag_meta_item_value: uint = 0x20u; +pub static tag_meta_item_value: uint = 0x20u; -pub const tag_attributes: uint = 0x21u; +pub static tag_attributes: uint = 0x21u; -pub const tag_attribute: uint = 0x22u; +pub static tag_attribute: uint = 0x22u; -pub const tag_meta_item_word: uint = 0x23u; +pub static tag_meta_item_word: uint = 0x23u; -pub const tag_meta_item_list: uint = 0x24u; +pub static tag_meta_item_list: uint = 0x24u; // The list of crates that this crate depends on -pub const tag_crate_deps: uint = 0x25u; +pub static tag_crate_deps: uint = 0x25u; // A single crate dependency -pub const tag_crate_dep: uint = 0x26u; +pub static tag_crate_dep: uint = 0x26u; -pub const tag_crate_hash: uint = 0x28u; +pub static tag_crate_hash: uint = 0x28u; -pub const tag_parent_item: uint = 0x29u; +pub static tag_parent_item: uint = 0x29u; -pub const tag_crate_dep_name: uint = 0x2au; -pub const tag_crate_dep_hash: uint = 0x2bu; -pub const tag_crate_dep_vers: uint = 0x2cu; +pub static tag_crate_dep_name: uint = 0x2au; +pub static tag_crate_dep_hash: uint = 0x2bu; +pub static tag_crate_dep_vers: uint = 0x2cu; -pub const tag_mod_impl: uint = 0x30u; +pub static tag_mod_impl: uint = 0x30u; -pub const tag_item_trait_method: uint = 0x31u; -pub const tag_impl_trait: uint = 0x32u; +pub static tag_item_trait_method: uint = 0x31u; +pub static tag_impl_trait: uint = 0x32u; // discriminator value for variants -pub const tag_disr_val: uint = 0x34u; +pub static tag_disr_val: uint = 0x34u; // used to encode ast_map::path and ast_map::path_elt -pub const tag_path: uint = 0x40u; -pub const tag_path_len: uint = 0x41u; -pub const tag_path_elt_mod: uint = 0x42u; -pub const tag_path_elt_name: uint = 0x43u; -pub const tag_item_field: uint = 0x44u; -pub const tag_struct_mut: uint = 0x45u; - -pub const tag_region_param: uint = 0x46u; -pub const tag_mod_impl_trait: uint = 0x47u; +pub static tag_path: uint = 0x40u; +pub static tag_path_len: uint = 0x41u; +pub static tag_path_elt_mod: uint = 0x42u; +pub static tag_path_elt_name: uint = 0x43u; +pub static tag_item_field: uint = 0x44u; +pub static tag_struct_mut: uint = 0x45u; + +pub static tag_region_param: uint = 0x46u; +pub static tag_mod_impl_trait: uint = 0x47u; /* trait items contain tag_item_trait_method elements, impl items contain tag_item_impl_method elements, and classes @@ -97,16 +97,16 @@ pub const tag_mod_impl_trait: uint = 0x47u; both, tag_item_trait_method and tag_item_impl_method have to be two different tags. */ -pub const tag_item_impl_method: uint = 0x48u; -pub const tag_item_dtor: uint = 0x49u; -pub const tag_item_trait_method_self_ty: uint = 0x4b; -pub const tag_item_trait_method_self_ty_region: uint = 0x4c; +pub static tag_item_impl_method: uint = 0x48u; +pub static tag_item_dtor: uint = 0x49u; +pub static tag_item_trait_method_self_ty: uint = 0x4b; +pub static tag_item_trait_method_self_ty_region: uint = 0x4c; // Reexports are found within module tags. Each reexport contains def_ids // and names. -pub const tag_items_data_item_reexport: uint = 0x4d; -pub const tag_items_data_item_reexport_def_id: uint = 0x4e; -pub const tag_items_data_item_reexport_name: uint = 0x4f; +pub static tag_items_data_item_reexport: uint = 0x4d; +pub static tag_items_data_item_reexport_def_id: uint = 0x4e; +pub static tag_items_data_item_reexport_name: uint = 0x4f; // used to encode crate_ctxt side tables pub enum astencode_tag { // Reserves 0x50 -- 0x6f @@ -136,9 +136,9 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_table_capture_map = 0x64 } -pub const tag_item_trait_method_sort: uint = 0x70; +pub static tag_item_trait_method_sort: uint = 0x70; -pub const tag_item_impl_type_basename: uint = 0x71; +pub static tag_item_impl_type_basename: uint = 0x71; // Language items are a top-level directory (for speed). Hierarchy: // @@ -147,17 +147,17 @@ pub const tag_item_impl_type_basename: uint = 0x71; // - tag_lang_items_item_id: u32 // - tag_lang_items_item_node_id: u32 -pub const tag_lang_items: uint = 0x72; -pub const tag_lang_items_item: uint = 0x73; -pub const tag_lang_items_item_id: uint = 0x74; -pub const tag_lang_items_item_node_id: uint = 0x75; +pub static tag_lang_items: uint = 0x72; +pub static tag_lang_items_item: uint = 0x73; +pub static tag_lang_items_item_id: uint = 0x74; +pub static tag_lang_items_item_node_id: uint = 0x75; -pub const tag_item_unnamed_field: uint = 0x76; -pub const tag_items_data_item_struct_ctor: uint = 0x77; -pub const tag_items_data_item_visibility: uint = 0x78; +pub static tag_item_unnamed_field: uint = 0x76; +pub static tag_items_data_item_struct_ctor: uint = 0x77; +pub static tag_items_data_item_visibility: uint = 0x78; -pub const tag_link_args: uint = 0x79; -pub const tag_link_args_arg: uint = 0x7a; +pub static tag_link_args: uint = 0x79; +pub static tag_link_args_arg: uint = 0x7a; pub struct LinkMeta { name: @str, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 6bb10a42f3e45..ccc29fbbccb26 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1313,7 +1313,7 @@ fn encode_hash(ebml_w: writer::Encoder, hash: &str) { } // NB: Increment this as you change the metadata encoding version. -pub const metadata_encoding_version : &'static [u8] = +pub static metadata_encoding_version : &'static [u8] = &[0x72, //'r' as u8, 0x75, //'u' as u8, 0x73, //'s' as u8, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index ef8857d444a52..75247e78acaa9 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -58,7 +58,7 @@ use syntax::{visit, ast_util}; use core::hashmap::linear::LinearSet; -pub const try_adding: &'static str = "Try adding a move"; +pub static try_adding: &'static str = "Try adding a move"; pub type rval_map = HashMap; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 0959e2eb0937a..e3a595a855211 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -653,9 +653,9 @@ struct Specials { no_ret_var: Variable } -const ACC_READ: uint = 1u; -const ACC_WRITE: uint = 2u; -const ACC_USE: uint = 4u; +static ACC_READ: uint = 1u; +static ACC_WRITE: uint = 2u; +static ACC_USE: uint = 4u; type LiveNodeMap = HashMap; diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 0933cf6c8e535..5e5cbc9f97191 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -178,7 +178,7 @@ pub fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) { // lot more efficient) than doing str::as_c_str("", ...) every time. pub fn noname() -> *libc::c_char { unsafe { - const cnull: uint = 0u; + static cnull: uint = 0u; return cast::reinterpret_cast(&ptr::addr_of(&cnull)); } } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index c220bd23e20f0..0b7d6f5c39bfe 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -76,8 +76,8 @@ pub type addrspace = c_uint; // 0 is ignored by the GC, and is used for all non-GC'd pointers. // 1 is for opaque GC'd boxes. // >= 2 are for specific types (e.g. resources). -pub const default_addrspace: addrspace = 0; -pub const gc_box_addrspace: addrspace = 1; +pub static default_addrspace: addrspace = 0; +pub static gc_box_addrspace: addrspace = 1; pub type addrspace_gen = @fn() -> addrspace; pub fn new_addrspace_gen() -> addrspace_gen { @@ -615,7 +615,7 @@ pub fn mk_block(llbb: BasicBlockRef, parent: Option, +kind: block_kind, } // First two args are retptr, env -pub const first_real_arg: uint = 2u; +pub static first_real_arg: uint = 2u; pub struct Result { bcx: block, diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 884bfd219ab7a..ea34df54462b7 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -179,7 +179,7 @@ pub fn const_expr(cx: @CrateContext, e: @ast::expr) -> ValueRef { llconst = C_struct(~[llconst, C_null(T_opaque_box_ptr(cx))]) } Some(@ty::AutoAddEnv(ref r, ref s)) => { - cx.sess.span_bug(e.span, fmt!("unexpected const function: \ + cx.sess.span_bug(e.span, fmt!("unexpected static function: \ region %? sigil %?", *r, *s)) } Some(@ty::AutoDerefRef(ref adj)) => { diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index c575465ddf784..505c08fc8b8c1 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -29,32 +29,32 @@ use syntax::codemap::{span, CharPos}; use syntax::parse::token::ident_interner; use syntax::{ast, codemap, ast_util, ast_map}; -const LLVMDebugVersion: int = (9 << 16); - -const DW_LANG_RUST: int = 0x9000; -const DW_VIRTUALITY_none: int = 0; - -const CompileUnitTag: int = 17; -const FileDescriptorTag: int = 41; -const SubprogramTag: int = 46; -const SubroutineTag: int = 21; -const BasicTypeDescriptorTag: int = 36; -const AutoVariableTag: int = 256; -const ArgVariableTag: int = 257; -const ReturnVariableTag: int = 258; -const LexicalBlockTag: int = 11; -const PointerTypeTag: int = 15; -const StructureTypeTag: int = 19; -const MemberTag: int = 13; -const ArrayTypeTag: int = 1; -const SubrangeTag: int = 33; - -const DW_ATE_boolean: int = 0x02; -const DW_ATE_float: int = 0x04; -const DW_ATE_signed: int = 0x05; -const DW_ATE_signed_char: int = 0x06; -const DW_ATE_unsigned: int = 0x07; -const DW_ATE_unsigned_char: int = 0x08; +static LLVMDebugVersion: int = (9 << 16); + +static DW_LANG_RUST: int = 0x9000; +static DW_VIRTUALITY_none: int = 0; + +static CompileUnitTag: int = 17; +static FileDescriptorTag: int = 41; +static SubprogramTag: int = 46; +static SubroutineTag: int = 21; +static BasicTypeDescriptorTag: int = 36; +static AutoVariableTag: int = 256; +static ArgVariableTag: int = 257; +static ReturnVariableTag: int = 258; +static LexicalBlockTag: int = 11; +static PointerTypeTag: int = 15; +static StructureTypeTag: int = 19; +static MemberTag: int = 13; +static ArrayTypeTag: int = 1; +static SubrangeTag: int = 33; + +static DW_ATE_boolean: int = 0x02; +static DW_ATE_float: int = 0x04; +static DW_ATE_signed: int = 0x05; +static DW_ATE_signed_char: int = 0x06; +static DW_ATE_unsigned: int = 0x07; +static DW_ATE_unsigned_char: int = 0x08; fn llstr(s: &str) -> ValueRef { do str::as_c_str(s) |sbuf| { diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 77e10b2fbda64..45cf790ccee20 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -47,9 +47,9 @@ use syntax::ast_util; use syntax::visit; pub type type_uses = uint; // Bitmask -pub const use_repr: uint = 1u; /* Dependency on size/alignment/mode and - take/drop glue */ -pub const use_tydesc: uint = 2u; /* Takes the tydesc, or compares */ +pub static use_repr: uint = 1u; /* Dependency on size/alignment/mode and + take/drop glue */ +pub static use_tydesc: uint = 2u; /* Takes the tydesc, or compares */ pub struct Context { ccx: @CrateContext, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index cbd2ad86b75fe..de626675fa3f1 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1801,43 +1801,43 @@ impl ToStr for TypeContents { } /// Constant for a type containing nothing of interest. -const TC_NONE: TypeContents = TypeContents{bits:0b0000_00000000}; +static TC_NONE: TypeContents = TypeContents{bits:0b0000_00000000}; /// Contains a borrowed value with a lifetime other than static -const TC_BORROWED_POINTER: TypeContents = TypeContents{bits:0b0000_00000001}; +static TC_BORROWED_POINTER: TypeContents = TypeContents{bits:0b0000_00000001}; /// Contains an owned pointer (~T) but not slice of some kind -const TC_OWNED_POINTER: TypeContents = TypeContents{bits:0b000000000010}; +static TC_OWNED_POINTER: TypeContents = TypeContents{bits:0b000000000010}; /// Contains an owned vector ~[] or owned string ~str -const TC_OWNED_VEC: TypeContents = TypeContents{bits:0b000000000100}; +static TC_OWNED_VEC: TypeContents = TypeContents{bits:0b000000000100}; /// Contains a ~fn() or a ~Trait, which is non-copyable. -const TC_OWNED_CLOSURE: TypeContents = TypeContents{bits:0b000000001000}; +static TC_OWNED_CLOSURE: TypeContents = TypeContents{bits:0b000000001000}; /// Type with a destructor -const TC_DTOR: TypeContents = TypeContents{bits:0b000000010000}; +static TC_DTOR: TypeContents = TypeContents{bits:0b000000010000}; /// Contains a managed value -const TC_MANAGED: TypeContents = TypeContents{bits:0b000000100000}; +static TC_MANAGED: TypeContents = TypeContents{bits:0b000000100000}; /// &mut with any region -const TC_BORROWED_MUT: TypeContents = TypeContents{bits:0b000001000000}; +static TC_BORROWED_MUT: TypeContents = TypeContents{bits:0b000001000000}; /// Mutable content, whether owned or by ref -const TC_MUTABLE: TypeContents = TypeContents{bits:0b000010000000}; +static TC_MUTABLE: TypeContents = TypeContents{bits:0b000010000000}; /// Mutable content, whether owned or by ref -const TC_ONCE_CLOSURE: TypeContents = TypeContents{bits:0b000100000000}; +static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits:0b000100000000}; /// Something we estimate to be "big" -const TC_BIG: TypeContents = TypeContents{bits:0b001000000000}; +static TC_BIG: TypeContents = TypeContents{bits:0b001000000000}; /// An enum with no variants. -const TC_EMPTY_ENUM: TypeContents = TypeContents{bits:0b010000000000}; +static TC_EMPTY_ENUM: TypeContents = TypeContents{bits:0b010000000000}; /// All possible contents. -const TC_ALL: TypeContents = TypeContents{bits:0b011111111111}; +static TC_ALL: TypeContents = TypeContents{bits:0b011111111111}; pub fn type_is_copyable(cx: ctxt, t: ty::t) -> bool { type_contents(cx, t).is_copy(cx) @@ -4076,21 +4076,21 @@ fn struct_item_fields(cx:ctxt, } pub fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { - const tycat_other: int = 0; - const tycat_bool: int = 1; - const tycat_int: int = 2; - const tycat_float: int = 3; - const tycat_struct: int = 4; - const tycat_bot: int = 5; - - const opcat_add: int = 0; - const opcat_sub: int = 1; - const opcat_mult: int = 2; - const opcat_shift: int = 3; - const opcat_rel: int = 4; - const opcat_eq: int = 5; - const opcat_bit: int = 6; - const opcat_logic: int = 7; + static tycat_other: int = 0; + static tycat_bool: int = 1; + static tycat_int: int = 2; + static tycat_float: int = 3; + static tycat_struct: int = 4; + static tycat_bot: int = 5; + + static opcat_add: int = 0; + static opcat_sub: int = 1; + static opcat_mult: int = 2; + static opcat_shift: int = 3; + static opcat_rel: int = 4; + static opcat_eq: int = 5; + static opcat_bit: int = 6; + static opcat_logic: int = 7; fn opcat(op: ast::binop) -> int { match op { @@ -4126,8 +4126,8 @@ pub fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { } } - const t: bool = true; - const f: bool = false; + static t: bool = true; + static f: bool = false; let tbl = ~[ /*. add, shift, bit diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index e259fdaf400e4..c288151308fe4 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -202,8 +202,8 @@ pub fn ast_path_to_ty( ty_param_substs_and_ty { substs: substs, ty: ty } } -pub const NO_REGIONS: uint = 1; -pub const NO_TPS: uint = 2; +pub static NO_REGIONS: uint = 1; +pub static NO_TPS: uint = 2; // Parses the programmer's textual representation of a type into our // internal notion of a type. `getter` is a function that returns the type diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 1d9594d930c6d..038dc524bec07 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -62,23 +62,23 @@ use syntax::ast; use core::vec; -pub const resolve_nested_tvar: uint = 0b0000000001; -pub const resolve_rvar: uint = 0b0000000010; -pub const resolve_ivar: uint = 0b0000000100; -pub const resolve_fvar: uint = 0b0000001000; -pub const resolve_fnvar: uint = 0b0000010000; -pub const resolve_all: uint = 0b0000011111; -pub const force_tvar: uint = 0b0000100000; -pub const force_rvar: uint = 0b0001000000; -pub const force_ivar: uint = 0b0010000000; -pub const force_fvar: uint = 0b0100000000; -pub const force_fnvar: uint = 0b1000000000; -pub const force_all: uint = 0b1111100000; - -pub const not_regions: uint = !(force_rvar | resolve_rvar); - -pub const try_resolve_tvar_shallow: uint = 0; -pub const resolve_and_force_all_but_regions: uint = +pub static resolve_nested_tvar: uint = 0b0000000001; +pub static resolve_rvar: uint = 0b0000000010; +pub static resolve_ivar: uint = 0b0000000100; +pub static resolve_fvar: uint = 0b0000001000; +pub static resolve_fnvar: uint = 0b0000010000; +pub static resolve_all: uint = 0b0000011111; +pub static force_tvar: uint = 0b0000100000; +pub static force_rvar: uint = 0b0001000000; +pub static force_ivar: uint = 0b0010000000; +pub static force_fvar: uint = 0b0100000000; +pub static force_fnvar: uint = 0b1000000000; +pub static force_all: uint = 0b1111100000; + +pub static not_regions: uint = !(force_rvar | resolve_rvar); + +pub static try_resolve_tvar_shallow: uint = 0; +pub static resolve_and_force_all_but_regions: uint = (resolve_all | force_all) & not_regions; pub struct ResolveState { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 867bcc30fa4ea..6a4def65fe744 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -47,7 +47,7 @@ struct RH { sub: &[RH] } -const EMPTY_SOURCE_STR: &str = "/* Hello, world! */"; +static EMPTY_SOURCE_STR: &str = "/* Hello, world! */"; fn setup_env(test_name: &str, source_string: &str) -> Env { let messages = @DVec(); diff --git a/src/librustdoc/demo.rs b/src/librustdoc/demo.rs index ad57af8942d35..c5fb8f289f65e 100644 --- a/src/librustdoc/demo.rs +++ b/src/librustdoc/demo.rs @@ -24,7 +24,7 @@ use core::prelude::*; /// The base price of a muffin on a non-holiday -const price_of_a_muffin: float = 70f; +static price_of_a_muffin: float = 70f; struct WaitPerson { hair_color: ~str diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index 281c318eb152c..957b94d18f532 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -127,8 +127,7 @@ fn extract(desc: Option<~str>) -> Option<~str> { } fn parse_desc(desc: ~str) -> Option<~str> { - - const max_brief_len: uint = 120u; + static max_brief_len: uint = 120u; match first_sentence(copy desc) { Some(first_sentence) => { diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index 5e5c843da26da..942dd3e01cbd5 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -184,7 +184,7 @@ fn constdoc_from_const(itemdoc: doc::ItemDoc) -> doc::ConstDoc { #[test] fn should_extract_const_name_and_id() { - let doc = test::mk_doc(~"const a: int = 0;"); + let doc = test::mk_doc(~"static a: int = 0;"); fail_unless!(doc.cratemod().consts()[0].id() != 0); fail_unless!(doc.cratemod().consts()[0].name() == ~"a"); } diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index e9d9732d51fd3..2cd9ef3671d6e 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -378,7 +378,7 @@ fn default_fold_should_produce_same_doc() { #[test] fn default_fold_should_produce_same_consts() { - let source = ~"const a: int = 0;"; + let source = ~"static a: int = 0;"; let ast = parse::from_str(source); let doc = extract::extract(ast, ~""); let fld = default_seq_fold(()); diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 227eb25aa81fe..73f3aa53c250d 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -594,7 +594,7 @@ fn write_const( #[test] fn should_write_const_header() { - let markdown = test::render(~"const a: bool = true;"); + let markdown = test::render(~"static a: bool = true;"); fail_unless!(str::contains(markdown, ~"## Const `a`\n\n")); } @@ -602,7 +602,7 @@ fn should_write_const_header() { fn should_write_const_description() { let markdown = test::render( ~"#[doc = \"b\"]\ - const a: bool = true;"); + static a: bool = true;"); fail_unless!(str::contains(markdown, ~"\n\nb\n\n")); } diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index 96727f6386d23..5919f1b0c2fbe 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -45,7 +45,7 @@ fn test() { ~"mod imod { } \ extern mod inmod { } \ - const iconst: int = 0; \ + static iconst: int = 0; \ fn ifn() { } \ enum ienum { ivar } \ trait itrait { fn a(); } \ diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 638274d0bb8ee..1472f6777b48f 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -121,7 +121,7 @@ fn fold_const( #[test] fn should_add_const_types() { - let doc = test::mk_doc(~"const a: bool = true;"); + let doc = test::mk_doc(~"static a: bool = true;"); fail_unless!(doc.cratemod().consts()[0].sig == Some(~"bool")); } diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 0572cf771dbed..8e5d7e95ae17a 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -139,7 +139,7 @@ fn add_pkg_module(ctx: @mut ReadyCtx, m: ast::_mod) -> ast::_mod { let item = quote_item! ( mod __pkg { extern mod rustpkg (vers="0.6"); - const listeners : &[rustpkg::Listener] = $listeners; + static listeners : &[rustpkg::Listener] = $listeners; #[main] fn main() { rustpkg::run(listeners); diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index d76438dd89bc1..a26132d92ca01 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -68,7 +68,7 @@ pub mod rustrt { // This probably belongs somewhere else. Needs to be kept in sync with // changes to glue... -const tydesc_drop_glue_index: size_t = 3 as size_t; +static tydesc_drop_glue_index: size_t = 3 as size_t; // The way arena uses arrays is really deeply awful. The arrays are // allocated, and have capacities reserved, but the fill for the array diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 309925e7cf9b4..564afea9f0835 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -44,14 +44,14 @@ pub mod BigDigit { #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] #[cfg(target_arch = "mips")] - pub const bits: uint = 16; + pub static bits: uint = 16; #[cfg(target_arch = "x86_64")] - pub const bits: uint = 32; + pub static bits: uint = 32; - pub const base: uint = 1 << bits; - priv const hi_mask: uint = (-1 as uint) << bits; - priv const lo_mask: uint = (-1 as uint) >> bits; + pub static base: uint = 1 << bits; + priv static hi_mask: uint = (-1 as uint) << bits; + priv static lo_mask: uint = (-1 as uint) >> bits; priv fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit } priv fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit } @@ -1046,9 +1046,9 @@ mod biguint_tests { fail_unless!(BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value); } - const sum_triples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] = &[ + static sum_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[ 1]), (&[ 1], &[ 1], &[ 2]), @@ -1086,9 +1086,9 @@ mod biguint_tests { } } - const mul_triples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] = &[ + static mul_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[]), (&[ 2], &[], &[]), @@ -1112,10 +1112,10 @@ mod biguint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - const divmod_quadruples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] + static divmod_quadruples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[ 1], &[ 2], &[], &[1]), (&[ 1, 1], &[ 2], &[-1/2+1], &[1]), @@ -1400,9 +1400,9 @@ mod bigint_tests { ).to_uint() == 0); } - const sum_triples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] = &[ + static sum_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[ 1]), (&[ 1], &[ 1], &[ 2]), @@ -1452,9 +1452,9 @@ mod bigint_tests { } } - const mul_triples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] = &[ + static mul_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[]), (&[ 2], &[], &[]), @@ -1478,10 +1478,10 @@ mod bigint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - const divmod_quadruples: &'static [(&'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit], - &'static [BigDigit])] + static divmod_quadruples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[ 1], &[ 2], &[], &[1]), (&[ 1, 1], &[ 2], &[-1/2+1], &[1]), diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 270a2c1fc1b31..3acc95a3aad62 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -877,7 +877,7 @@ mod tests { use core::vec; use core::rand; - const bench_bits : uint = 1 << 14; + static bench_bits : uint = 1 << 14; #[test] pub fn test_to_str() { diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 6fd77de034262..93a2f4e2acc74 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -14,7 +14,7 @@ use core::f32; use core::f64; use core::float; -pub const FUZZY_EPSILON: float = 1.0e-6; +pub static FUZZY_EPSILON: float = 1.0e-6; pub trait FuzzyEq { fn fuzzy_eq(&self, other: &Self) -> bool; diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 4f61321b4e777..e6fcbdc84c877 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -14,7 +14,7 @@ use core::container::{Container, Mutable}; use core::prelude::*; use core::vec; -const initial_capacity: uint = 32u; // 2^5 +static initial_capacity: uint = 32u; // 2^5 pub struct Deque { priv nelts: uint, diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 437ab561f9545..92898af2993de 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -545,7 +545,7 @@ pub mod writer { // Set to true to generate more debugging in EBML code. // Totally lame approach. - const debug: bool = false; + static debug: bool = false; priv impl Encoder { // used internally to emit things like the vector length and so on diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 9855e803ccbcc..01d672c9b26f5 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -254,7 +254,7 @@ pub trait ByteChan { fn send(&self, val: ~[u8]); } -const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; +static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; impl,P:BytePort> GenericPort for FlatPort { fn recv(&self) -> T { @@ -921,7 +921,7 @@ mod test { } fn test_try_recv_none3(loader: PortLoader

) { - const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; + static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by garbage let bytes = CONTINUE.to_vec() + ~[0]; let port = loader(bytes); @@ -940,7 +940,7 @@ mod test { fn test_try_recv_none4(+loader: PortLoader

) { fail_unless!(do task::try || { - const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; + static CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by a valid length, // then undeserializable garbage let len_bytes = do io::u64_to_be_bytes( diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 0b688f0c67861..02c610e4854d8 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -51,7 +51,7 @@ pub mod chained { use core::uint; use core::vec; - const initial_capacity: uint = 32u; // 2^5 + static initial_capacity: uint = 32u; // 2^5 struct Entry { hash: uint, diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 17ae48e03b93f..6f69ac4e1bd69 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -22,10 +22,10 @@ use future_spawn = future::spawn; * The maximum number of tasks this module will spawn for a single * operation. */ -const max_tasks : uint = 32u; +static max_tasks : uint = 32u; /// The minimum number of elements each task will process. -const min_granularity : uint = 1024u; +static min_granularity : uint = 1024u; /** * An internal helper to map a function over a large vector and diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index c9ad762880ca5..51cf08c8ca1fe 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -636,14 +636,14 @@ pub mod node { * * This is not a strict value */ - pub const hint_max_leaf_char_len: uint = 256u; + pub static hint_max_leaf_char_len: uint = 256u; /** * The maximal height that _should_ be permitted in a tree. * * This is not a strict value */ - pub const hint_max_node_height: uint = 16u; + pub static hint_max_node_height: uint = 16u; /** * Adopt a string as a node. diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 077ab191e69e3..64399defd54f7 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -53,13 +53,13 @@ trait Sha1 { } // Some unexported constants -const digest_buf_len: uint = 5u; -const msg_block_len: uint = 64u; -const work_buf_len: uint = 80u; -const k0: u32 = 0x5A827999u32; -const k1: u32 = 0x6ED9EBA1u32; -const k2: u32 = 0x8F1BBCDCu32; -const k3: u32 = 0xCA62C1D6u32; +static digest_buf_len: uint = 5u; +static msg_block_len: uint = 64u; +static work_buf_len: uint = 80u; +static k0: u32 = 0x5A827999u32; +static k1: u32 = 0x6ED9EBA1u32; +static k2: u32 = 0x8F1BBCDCu32; +static k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 8ab2c40116ad7..33f585d32fc9f 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -177,9 +177,9 @@ impl Sort for &'self mut [T] { fn qsort(self) { quick_sort3(self); } } -const MIN_MERGE: uint = 64; -const MIN_GALLOP: uint = 7; -const INITIAL_TMP_STORAGE: uint = 128; +static MIN_MERGE: uint = 64; +static MIN_GALLOP: uint = 7; +static INITIAL_TMP_STORAGE: uint = 128; pub fn tim_sort(array: &mut [T]) { let size = array.len(); diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 2a8c8b3b06bbd..a6c8884e05d4d 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -17,24 +17,24 @@ use core::vec; // FIXME (#2807): Windows support. -pub const color_black: u8 = 0u8; -pub const color_red: u8 = 1u8; -pub const color_green: u8 = 2u8; -pub const color_yellow: u8 = 3u8; -pub const color_blue: u8 = 4u8; -pub const color_magenta: u8 = 5u8; -pub const color_cyan: u8 = 6u8; -pub const color_light_gray: u8 = 7u8; -pub const color_light_grey: u8 = 7u8; -pub const color_dark_gray: u8 = 8u8; -pub const color_dark_grey: u8 = 8u8; -pub const color_bright_red: u8 = 9u8; -pub const color_bright_green: u8 = 10u8; -pub const color_bright_yellow: u8 = 11u8; -pub const color_bright_blue: u8 = 12u8; -pub const color_bright_magenta: u8 = 13u8; -pub const color_bright_cyan: u8 = 14u8; -pub const color_bright_white: u8 = 15u8; +pub static color_black: u8 = 0u8; +pub static color_red: u8 = 1u8; +pub static color_green: u8 = 2u8; +pub static color_yellow: u8 = 3u8; +pub static color_blue: u8 = 4u8; +pub static color_magenta: u8 = 5u8; +pub static color_cyan: u8 = 6u8; +pub static color_light_gray: u8 = 7u8; +pub static color_light_grey: u8 = 7u8; +pub static color_dark_gray: u8 = 8u8; +pub static color_dark_grey: u8 = 8u8; +pub static color_bright_red: u8 = 9u8; +pub static color_bright_green: u8 = 10u8; +pub static color_bright_yellow: u8 = 11u8; +pub static color_bright_blue: u8 = 12u8; +pub static color_bright_magenta: u8 = 13u8; +pub static color_bright_cyan: u8 = 14u8; +pub static color_bright_white: u8 = 15u8; pub fn esc(writer: @io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 7531992ae8485..d039e8eef5aa6 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -477,10 +477,10 @@ fn run_tests(opts: &TestOpts, // Windows tends to dislike being overloaded with threads. #[cfg(windows)] -const sched_overcommit : uint = 1; +static sched_overcommit : uint = 1; #[cfg(unix)] -const sched_overcommit : uint = 4u; +static sched_overcommit : uint = 4u; fn get_concurrency() -> uint { unsafe { diff --git a/src/libstd/time.rs b/src/libstd/time.rs index b46d58f891b6c..ce153c1ac2471 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -17,7 +17,7 @@ use core::prelude::*; use core::result::{Result, Ok, Err}; use core::str; -const NSEC_PER_SEC: i32 = 1_000_000_000_i32; +static NSEC_PER_SEC: i32 = 1_000_000_000_i32; pub mod rustrt { use super::Tm; @@ -900,8 +900,8 @@ mod tests { use core::vec; pub fn test_get_time() { - const some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z - const some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z + static some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z + static some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z let tv1 = get_time(); debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint); diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index f22bdaff3a0fc..4fdd4e286da1a 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -15,147 +15,147 @@ pub mod icu { pub type UProperty = int; pub type UChar32 = char; - pub const TRUE : u8 = 1u8; - pub const FALSE : u8 = 1u8; - - pub const UCHAR_ALPHABETIC : UProperty = 0; - pub const UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC - pub const UCHAR_ASCII_HEX_DIGIT : UProperty = 1; - pub const UCHAR_BIDI_CONTROL : UProperty = 2; - - pub const UCHAR_BIDI_MIRRORED : UProperty = 3; - pub const UCHAR_DASH : UProperty = 4; - pub const UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5; - pub const UCHAR_DEPRECATED : UProperty = 6; - - pub const UCHAR_DIACRITIC : UProperty = 7; - pub const UCHAR_EXTENDER : UProperty = 8; - pub const UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9; - pub const UCHAR_GRAPHEME_BASE : UProperty = 10; - - pub const UCHAR_GRAPHEME_EXTEND : UProperty = 11; - pub const UCHAR_GRAPHEME_LINK : UProperty = 12; - pub const UCHAR_HEX_DIGIT : UProperty = 13; - pub const UCHAR_HYPHEN : UProperty = 14; - - pub const UCHAR_ID_CONTINUE : UProperty = 15; - pub const UCHAR_ID_START : UProperty = 16; - pub const UCHAR_IDEOGRAPHIC : UProperty = 17; - pub const UCHAR_IDS_BINARY_OPERATOR : UProperty = 18; - - pub const UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19; - pub const UCHAR_JOIN_CONTROL : UProperty = 20; - pub const UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21; - pub const UCHAR_LOWERCASE : UProperty = 22; - - pub const UCHAR_MATH : UProperty = 23; - pub const UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24; - pub const UCHAR_QUOTATION_MARK : UProperty = 25; - pub const UCHAR_RADICAL : UProperty = 26; - - pub const UCHAR_SOFT_DOTTED : UProperty = 27; - pub const UCHAR_TERMINAL_PUNCTUATION : UProperty = 28; - pub const UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29; - pub const UCHAR_UPPERCASE : UProperty = 30; - - pub const UCHAR_WHITE_SPACE : UProperty = 31; - pub const UCHAR_XID_CONTINUE : UProperty = 32; - pub const UCHAR_XID_START : UProperty = 33; - pub const UCHAR_CASE_SENSITIVE : UProperty = 34; - - pub const UCHAR_S_TERM : UProperty = 35; - pub const UCHAR_VARIATION_SELECTOR : UProperty = 36; - pub const UCHAR_NFD_INERT : UProperty = 37; - pub const UCHAR_NFKD_INERT : UProperty = 38; - - pub const UCHAR_NFC_INERT : UProperty = 39; - pub const UCHAR_NFKC_INERT : UProperty = 40; - pub const UCHAR_SEGMENT_STARTER : UProperty = 41; - pub const UCHAR_PATTERN_SYNTAX : UProperty = 42; - - pub const UCHAR_PATTERN_WHITE_SPACE : UProperty = 43; - pub const UCHAR_POSIX_ALNUM : UProperty = 44; - pub const UCHAR_POSIX_BLANK : UProperty = 45; - pub const UCHAR_POSIX_GRAPH : UProperty = 46; - - pub const UCHAR_POSIX_PRINT : UProperty = 47; - pub const UCHAR_POSIX_XDIGIT : UProperty = 48; - pub const UCHAR_CASED : UProperty = 49; - pub const UCHAR_CASE_IGNORABLE : UProperty = 50; - - pub const UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51; - pub const UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52; - pub const UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53; - pub const UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54; - - pub const UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55; - pub const UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56; - pub const UCHAR_BINARY_LIMIT : UProperty = 57; - pub const UCHAR_BIDI_CLASS : UProperty = 0x1000; - - pub const UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS - pub const UCHAR_BLOCK : UProperty = 0x1001; - pub const UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002; - pub const UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003; - - pub const UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004; - pub const UCHAR_GENERAL_CATEGORY : UProperty = 0x1005; - pub const UCHAR_JOINING_GROUP : UProperty = 0x1006; - pub const UCHAR_JOINING_TYPE : UProperty = 0x1007; - - pub const UCHAR_LINE_BREAK : UProperty = 0x1008; - pub const UCHAR_NUMERIC_TYPE : UProperty = 0x1009; - pub const UCHAR_SCRIPT : UProperty = 0x100A; - pub const UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B; - - pub const UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C; - pub const UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D; - pub const UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E; - pub const UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F; - - pub const UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010; - pub const UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011; - pub const UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012; - pub const UCHAR_SENTENCE_BREAK : UProperty = 0x1013; - - pub const UCHAR_WORD_BREAK : UProperty = 0x1014; - pub const UCHAR_INT_LIMIT : UProperty = 0x1015; - - pub const UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000; - pub const UCHAR_MASK_START : UProperty = 0x2000; + pub static TRUE : u8 = 1u8; + pub static FALSE : u8 = 1u8; + + pub static UCHAR_ALPHABETIC : UProperty = 0; + pub static UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC + pub static UCHAR_ASCII_HEX_DIGIT : UProperty = 1; + pub static UCHAR_BIDI_CONTROL : UProperty = 2; + + pub static UCHAR_BIDI_MIRRORED : UProperty = 3; + pub static UCHAR_DASH : UProperty = 4; + pub static UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5; + pub static UCHAR_DEPRECATED : UProperty = 6; + + pub static UCHAR_DIACRITIC : UProperty = 7; + pub static UCHAR_EXTENDER : UProperty = 8; + pub static UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9; + pub static UCHAR_GRAPHEME_BASE : UProperty = 10; + + pub static UCHAR_GRAPHEME_EXTEND : UProperty = 11; + pub static UCHAR_GRAPHEME_LINK : UProperty = 12; + pub static UCHAR_HEX_DIGIT : UProperty = 13; + pub static UCHAR_HYPHEN : UProperty = 14; + + pub static UCHAR_ID_CONTINUE : UProperty = 15; + pub static UCHAR_ID_START : UProperty = 16; + pub static UCHAR_IDEOGRAPHIC : UProperty = 17; + pub static UCHAR_IDS_BINARY_OPERATOR : UProperty = 18; + + pub static UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19; + pub static UCHAR_JOIN_CONTROL : UProperty = 20; + pub static UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21; + pub static UCHAR_LOWERCASE : UProperty = 22; + + pub static UCHAR_MATH : UProperty = 23; + pub static UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24; + pub static UCHAR_QUOTATION_MARK : UProperty = 25; + pub static UCHAR_RADICAL : UProperty = 26; + + pub static UCHAR_SOFT_DOTTED : UProperty = 27; + pub static UCHAR_TERMINAL_PUNCTUATION : UProperty = 28; + pub static UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29; + pub static UCHAR_UPPERCASE : UProperty = 30; + + pub static UCHAR_WHITE_SPACE : UProperty = 31; + pub static UCHAR_XID_CONTINUE : UProperty = 32; + pub static UCHAR_XID_START : UProperty = 33; + pub static UCHAR_CASE_SENSITIVE : UProperty = 34; + + pub static UCHAR_S_TERM : UProperty = 35; + pub static UCHAR_VARIATION_SELECTOR : UProperty = 36; + pub static UCHAR_NFD_INERT : UProperty = 37; + pub static UCHAR_NFKD_INERT : UProperty = 38; + + pub static UCHAR_NFC_INERT : UProperty = 39; + pub static UCHAR_NFKC_INERT : UProperty = 40; + pub static UCHAR_SEGMENT_STARTER : UProperty = 41; + pub static UCHAR_PATTERN_SYNTAX : UProperty = 42; + + pub static UCHAR_PATTERN_WHITE_SPACE : UProperty = 43; + pub static UCHAR_POSIX_ALNUM : UProperty = 44; + pub static UCHAR_POSIX_BLANK : UProperty = 45; + pub static UCHAR_POSIX_GRAPH : UProperty = 46; + + pub static UCHAR_POSIX_PRINT : UProperty = 47; + pub static UCHAR_POSIX_XDIGIT : UProperty = 48; + pub static UCHAR_CASED : UProperty = 49; + pub static UCHAR_CASE_IGNORABLE : UProperty = 50; + + pub static UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51; + pub static UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52; + pub static UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53; + pub static UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54; + + pub static UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55; + pub static UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56; + pub static UCHAR_BINARY_LIMIT : UProperty = 57; + pub static UCHAR_BIDI_CLASS : UProperty = 0x1000; + + pub static UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS + pub static UCHAR_BLOCK : UProperty = 0x1001; + pub static UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002; + pub static UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003; + + pub static UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004; + pub static UCHAR_GENERAL_CATEGORY : UProperty = 0x1005; + pub static UCHAR_JOINING_GROUP : UProperty = 0x1006; + pub static UCHAR_JOINING_TYPE : UProperty = 0x1007; + + pub static UCHAR_LINE_BREAK : UProperty = 0x1008; + pub static UCHAR_NUMERIC_TYPE : UProperty = 0x1009; + pub static UCHAR_SCRIPT : UProperty = 0x100A; + pub static UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B; + + pub static UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C; + pub static UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D; + pub static UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E; + pub static UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F; + + pub static UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010; + pub static UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011; + pub static UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012; + pub static UCHAR_SENTENCE_BREAK : UProperty = 0x1013; + + pub static UCHAR_WORD_BREAK : UProperty = 0x1014; + pub static UCHAR_INT_LIMIT : UProperty = 0x1015; + + pub static UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000; + pub static UCHAR_MASK_START : UProperty = 0x2000; // = UCHAR_GENERAL_CATEGORY_MASK - pub const UCHAR_MASK_LIMIT : UProperty = 0x2001; + pub static UCHAR_MASK_LIMIT : UProperty = 0x2001; - pub const UCHAR_NUMERIC_VALUE : UProperty = 0x3000; - pub const UCHAR_DOUBLE_START : UProperty = 0x3000; + pub static UCHAR_NUMERIC_VALUE : UProperty = 0x3000; + pub static UCHAR_DOUBLE_START : UProperty = 0x3000; // = UCHAR_NUMERIC_VALUE - pub const UCHAR_DOUBLE_LIMIT : UProperty = 0x3001; + pub static UCHAR_DOUBLE_LIMIT : UProperty = 0x3001; - pub const UCHAR_AGE : UProperty = 0x4000; - pub const UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE - pub const UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001; - pub const UCHAR_CASE_FOLDING : UProperty = 0x4002; + pub static UCHAR_AGE : UProperty = 0x4000; + pub static UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE + pub static UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001; + pub static UCHAR_CASE_FOLDING : UProperty = 0x4002; - pub const UCHAR_ISO_COMMENT : UProperty = 0x4003; - pub const UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004; - pub const UCHAR_NAME : UProperty = 0x4005; - pub const UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006; + pub static UCHAR_ISO_COMMENT : UProperty = 0x4003; + pub static UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004; + pub static UCHAR_NAME : UProperty = 0x4005; + pub static UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006; - pub const UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007; - pub const UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008; - pub const UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009; - pub const UCHAR_TITLECASE_MAPPING : UProperty = 0x400A; + pub static UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007; + pub static UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008; + pub static UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009; + pub static UCHAR_TITLECASE_MAPPING : UProperty = 0x400A; - pub const UCHAR_UNICODE_1_NAME : UProperty = 0x400B; - pub const UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C; - pub const UCHAR_STRING_LIMIT : UProperty = 0x400D; + pub static UCHAR_UNICODE_1_NAME : UProperty = 0x400B; + pub static UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C; + pub static UCHAR_STRING_LIMIT : UProperty = 0x400D; - pub const UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000; - pub const UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000; + pub static UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000; + pub static UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000; // = UCHAR_SCRIPT_EXTENSIONS; - pub const UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001; + pub static UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001; - pub const UCHAR_INVALID_CODE : UProperty = -1; + pub static UCHAR_INVALID_CODE : UProperty = -1; pub mod libicu { #[link_name = "icuuc"] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c37d9d1c1c4f7..bef88e58a1795 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -132,8 +132,8 @@ pub struct def_id { node: node_id, } -pub const local_crate: crate_num = 0; -pub const crate_node_id: node_id = 0; +pub static local_crate: crate_num = 0; +pub static crate_node_id: node_id = 0; #[auto_encode] #[auto_decode] diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 46ded7ecf3dd0..a69b3e20eb1f1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -493,7 +493,7 @@ pub fn core_macros() -> ~str { mod $c { fn key(_x: @::core::condition::Handler<$in,$out>) { } - pub const cond : + pub static cond : ::core::condition::Condition/&static<$in,$out> = ::core::condition::Condition { name: stringify!($c), diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs index e2a89d2a28cc1..79adabec9b773 100644 --- a/src/libsyntax/parse/prec.rs +++ b/src/libsyntax/parse/prec.rs @@ -16,13 +16,13 @@ use parse::token::Token; use core::prelude::*; /// Unary operators have higher precedence than binary -pub const unop_prec: uint = 100u; +pub static unop_prec: uint = 100u; /** * Precedence of the `as` operator, which is a binary operator * but is not represented in the precedence table. */ -pub const as_prec: uint = 11u; +pub static as_prec: uint = 11u; /** * Maps a token to a record specifying the corresponding binary diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 8b78087e16f7d..074bb13e19908 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -309,50 +309,50 @@ pub fn is_bar(t: &Token) -> bool { pub mod special_idents { use ast::ident; - pub const underscore : ident = ident { repr: 0u }; - pub const anon : ident = ident { repr: 1u }; - pub const dtor : ident = ident { repr: 2u }; // 'drop', but that's + pub static underscore : ident = ident { repr: 0u }; + pub static anon : ident = ident { repr: 1u }; + pub static dtor : ident = ident { repr: 2u }; // 'drop', but that's // reserved - pub const invalid : ident = ident { repr: 3u }; // '' - pub const unary : ident = ident { repr: 4u }; - pub const not_fn : ident = ident { repr: 5u }; - pub const idx_fn : ident = ident { repr: 6u }; - pub const unary_minus_fn : ident = ident { repr: 7u }; - pub const clownshoes_extensions : ident = ident { repr: 8u }; + pub static invalid : ident = ident { repr: 3u }; // '' + pub static unary : ident = ident { repr: 4u }; + pub static not_fn : ident = ident { repr: 5u }; + pub static idx_fn : ident = ident { repr: 6u }; + pub static unary_minus_fn : ident = ident { repr: 7u }; + pub static clownshoes_extensions : ident = ident { repr: 8u }; - pub const self_ : ident = ident { repr: 9u }; // 'self' + pub static self_ : ident = ident { repr: 9u }; // 'self' /* for matcher NTs */ - pub const item : ident = ident { repr: 10u }; - pub const block : ident = ident { repr: 11u }; - pub const stmt : ident = ident { repr: 12u }; - pub const pat : ident = ident { repr: 13u }; - pub const expr : ident = ident { repr: 14u }; - pub const ty : ident = ident { repr: 15u }; - pub const ident : ident = ident { repr: 16u }; - pub const path : ident = ident { repr: 17u }; - pub const tt : ident = ident { repr: 18u }; - pub const matchers : ident = ident { repr: 19u }; - - pub const str : ident = ident { repr: 20u }; // for the type + pub static item : ident = ident { repr: 10u }; + pub static block : ident = ident { repr: 11u }; + pub static stmt : ident = ident { repr: 12u }; + pub static pat : ident = ident { repr: 13u }; + pub static expr : ident = ident { repr: 14u }; + pub static ty : ident = ident { repr: 15u }; + pub static ident : ident = ident { repr: 16u }; + pub static path : ident = ident { repr: 17u }; + pub static tt : ident = ident { repr: 18u }; + pub static matchers : ident = ident { repr: 19u }; + + pub static str : ident = ident { repr: 20u }; // for the type /* outside of libsyntax */ - pub const ty_visitor : ident = ident { repr: 21u }; - pub const arg : ident = ident { repr: 22u }; - pub const descrim : ident = ident { repr: 23u }; - pub const clownshoe_abi : ident = ident { repr: 24u }; - pub const clownshoe_stack_shim : ident = ident { repr: 25u }; - pub const tydesc : ident = ident { repr: 26u }; - pub const literally_dtor : ident = ident { repr: 27u }; - pub const main : ident = ident { repr: 28u }; - pub const opaque : ident = ident { repr: 29u }; - pub const blk : ident = ident { repr: 30u }; - pub const static : ident = ident { repr: 31u }; - pub const intrinsic : ident = ident { repr: 32u }; - pub const clownshoes_foreign_mod: ident = ident { repr: 33 }; - pub const unnamed_field: ident = ident { repr: 34 }; - pub const c_abi: ident = ident { repr: 35 }; - pub const type_self: ident = ident { repr: 36 }; // `Self` + pub static ty_visitor : ident = ident { repr: 21u }; + pub static arg : ident = ident { repr: 22u }; + pub static descrim : ident = ident { repr: 23u }; + pub static clownshoe_abi : ident = ident { repr: 24u }; + pub static clownshoe_stack_shim : ident = ident { repr: 25u }; + pub static tydesc : ident = ident { repr: 26u }; + pub static literally_dtor : ident = ident { repr: 27u }; + pub static main : ident = ident { repr: 28u }; + pub static opaque : ident = ident { repr: 29u }; + pub static blk : ident = ident { repr: 30u }; + pub static static : ident = ident { repr: 31u }; + pub static intrinsic : ident = ident { repr: 32u }; + pub static clownshoes_foreign_mod: ident = ident { repr: 33 }; + pub static unnamed_field: ident = ident { repr: 34 }; + pub static c_abi: ident = ident { repr: 35 }; + pub static type_self: ident = ident { repr: 36 }; // `Self` } pub struct ident_interner { diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index d002267547351..af9cb7b841ef6 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -139,7 +139,7 @@ pub struct print_stack_elt { pbreak: print_stack_break } -pub const size_infinity: int = 0xffff; +pub static size_infinity: int = 0xffff; pub fn mk_printer(out: @io::Writer, linewidth: uint) -> @mut Printer { // Yes 3, it makes the ring buffers big enough to never diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ce12e0a7b875f..9b061faa2abfa 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -92,10 +92,10 @@ pub fn rust_printer(writer: @io::Writer, intr: @ident_interner) -> @ps { }; } -pub const indent_unit: uint = 4u; -pub const match_indent_unit: uint = 2u; +pub static indent_unit: uint = 4u; +pub static match_indent_unit: uint = 2u; -pub const default_columns: uint = 78u; +pub static default_columns: uint = 78u; // Requires you to pass an input filename and reader so that // it can scan the input text for comments and literals to diff --git a/src/test/auxiliary/cci_const.rs b/src/test/auxiliary/cci_const.rs index 945004ede6de8..17029b9d3778a 100644 --- a/src/test/auxiliary/cci_const.rs +++ b/src/test/auxiliary/cci_const.rs @@ -11,6 +11,6 @@ pub extern fn bar() { } -pub const foopy: &'static str = "hi there"; -pub const uint_val: uint = 12; -pub const uint_expr: uint = (1 << uint_val) - 1; +pub static foopy: &'static str = "hi there"; +pub static uint_val: uint = 12; +pub static uint_expr: uint = (1 << uint_val) - 1; diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 6ce9fce881a6a..97907025bd1a0 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -167,10 +167,10 @@ pub mod NBodySystem { pub mod Body { use Body; - pub const PI: float = 3.141592653589793; - pub const SOLAR_MASS: float = 39.478417604357432; + pub static PI: float = 3.141592653589793; + pub static SOLAR_MASS: float = 39.478417604357432; // was 4 * PI * PI originally - pub const DAYS_PER_YEAR: float = 365.24; + pub static DAYS_PER_YEAR: float = 365.24; pub struct Props { x: float, diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 1e32697eb1073..4964cea28ad91 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -153,7 +153,7 @@ pub impl Sudoku { // Stores available colors as simple bitfield, bit 0 is always unset struct Colors(u16); -const heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */ +static heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */ impl Colors { fn new(start_color: u8) -> Colors { @@ -182,7 +182,7 @@ impl Colors { } } -const default_sudoku: [[u8 * 9] * 9] = [ +static default_sudoku: [[u8 * 9] * 9] = [ /* 0 1 2 3 4 5 6 7 8 */ /* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8], /* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8], @@ -196,7 +196,7 @@ const default_sudoku: [[u8 * 9] * 9] = [ ]; #[cfg(test)] -const default_solution: [[u8 * 9] * 9] = [ +static default_solution: [[u8 * 9] * 9] = [ /* 0 1 2 3 4 5 6 7 8 */ /* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8], /* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8], diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index e35d5e79bde65..a66c00d5411b4 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -10,5 +10,5 @@ // error-pattern:expected `~str` but found `int` -const i: str = 10i; +static i: ~str = 10i; fn main() { debug!(i); } diff --git a/src/test/compile-fail/borrowck-assign-to-constants.rs b/src/test/compile-fail/borrowck-assign-to-constants.rs index 78a95cb33c0c3..0d65aacb65b7a 100644 --- a/src/test/compile-fail/borrowck-assign-to-constants.rs +++ b/src/test/compile-fail/borrowck-assign-to-constants.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const foo: int = 5; +static foo: int = 5; fn main() { // assigning to various global constants diff --git a/src/test/compile-fail/const-cast-different-types.rs b/src/test/compile-fail/const-cast-different-types.rs index 45e39b47d2371..56ec0bb929636 100644 --- a/src/test/compile-fail/const-cast-different-types.rs +++ b/src/test/compile-fail/const-cast-different-types.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: &'static str = &"foo"; -const b: *u8 = a as *u8; //~ ERROR non-scalar cast -const c: *u8 = &a as *u8; //~ ERROR mismatched types +static a: &'static str = &"foo"; +static b: *u8 = a as *u8; //~ ERROR non-scalar cast +static c: *u8 = &a as *u8; //~ ERROR mismatched types fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/const-cast-wrong-type.rs b/src/test/compile-fail/const-cast-wrong-type.rs index fe91056d47b6f..677f4318db759 100644 --- a/src/test/compile-fail/const-cast-wrong-type.rs +++ b/src/test/compile-fail/const-cast-wrong-type.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; -const b: *i8 = &a as *i8; //~ ERROR mismatched types +static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; +static b: *i8 = &a as *i8; //~ ERROR mismatched types fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/const-recursive.rs b/src/test/compile-fail/const-recursive.rs index f565a44c97f97..9c633e082b194 100644 --- a/src/test/compile-fail/const-recursive.rs +++ b/src/test/compile-fail/const-recursive.rs @@ -9,8 +9,8 @@ // except according to those terms. // error-pattern: recursive constant -const a: int = b; -const b: int = a; +static a: int = b; +static b: int = a; fn main() { } diff --git a/src/test/compile-fail/issue-2478.rs b/src/test/compile-fail/issue-2478.rs index 2b52cab7fe79a..d5663e57f4bf7 100644 --- a/src/test/compile-fail/issue-2478.rs +++ b/src/test/compile-fail/issue-2478.rs @@ -12,5 +12,5 @@ fn foo() -> &'a int { return &x; } -const x: int = 5; +static x: int = 5; fn main() {} diff --git a/src/test/compile-fail/issue-3521-2.rs b/src/test/compile-fail/issue-3521-2.rs index 39c14b4d316b0..431f98d8181a0 100644 --- a/src/test/compile-fail/issue-3521-2.rs +++ b/src/test/compile-fail/issue-3521-2.rs @@ -11,7 +11,7 @@ fn main() { let foo = 100; - const y: int = foo + 1; //~ ERROR: attempt to use a non-constant value in a constant + static y: int = foo + 1; //~ ERROR: attempt to use a non-constant value in a constant error!(y); } diff --git a/src/test/compile-fail/issue-3668-2.rs b/src/test/compile-fail/issue-3668-2.rs index be96918b25055..f7637f684be5a 100644 --- a/src/test/compile-fail/issue-3668-2.rs +++ b/src/test/compile-fail/issue-3668-2.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f(x:int) { - const child: int = x + 1; //~ ERROR attempt to use a non-constant value in a constant + static child: int = x + 1; //~ ERROR attempt to use a non-constant value in a constant } fn main() {} diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index 1b121878697de..77e2e4f21e8a1 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -15,7 +15,7 @@ trait PTrait { impl PTrait for P { fn getChildOption(&self) -> Option<@P> { - const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant + static childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant fail!(); } } diff --git a/src/test/compile-fail/issue-4523.rs b/src/test/compile-fail/issue-4523.rs index e8e2702937110..6d072ce210e2d 100644 --- a/src/test/compile-fail/issue-4523.rs +++ b/src/test/compile-fail/issue-4523.rs @@ -10,7 +10,7 @@ fn foopy() {} -const f: &'static fn() = foopy; //~ ERROR mismatched types: expected `&'static fn()` +static f: &'static fn() = foopy; //~ ERROR mismatched types: expected `&'static fn()` fn main () { f(); diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index 315c2affe349c..fc0c29e9a7987 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -10,7 +10,7 @@ // Regression test for issue #4968 -const A: (int,int) = (4,2); +static A: (int,int) = (4,2); fn main() { match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) } diff --git a/src/test/compile-fail/regions-in-consts.rs b/src/test/compile-fail/regions-in-consts.rs index 2ba27e888cbe0..c34e5fb29de5a 100644 --- a/src/test/compile-fail/regions-in-consts.rs +++ b/src/test/compile-fail/regions-in-consts.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const c_x: &'blk int = &22; //~ ERROR Illegal lifetime 'blk: only 'static is allowed here -const c_y: &int = &22; //~ ERROR Illegal anonymous lifetime: only 'static is allowed here -const c_z: &'static int = &22; +static c_x: &'blk int = &22; //~ ERROR Illegal lifetime 'blk: only 'static is allowed here +static c_y: &int = &22; //~ ERROR Illegal anonymous lifetime: only 'static is allowed here +static c_z: &'static int = &22; fn main() { } diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 613480e3a63cd..779fd3e490416 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -63,8 +63,8 @@ fn main() { let ty = quote_ty!(int); check_pp(ext_cx, ty, pprust::print_type, ~"int"); - let item = quote_item!(const x : int = 10;).get(); - check_pp(ext_cx, item, pprust::print_item, ~"const x: int = 10;"); + let item = quote_item!(static x : int = 10;).get(); + check_pp(ext_cx, item, pprust::print_item, ~"static x: int = 10;"); let stmt = quote_stmt!(let x = 20;); check_pp(ext_cx, *stmt, pprust::print_stmt, ~"let x = 20;"); diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index f324f2d198b0b..ccee163eafe5b 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -19,7 +19,7 @@ fn syntax_extension(ext_cx: @ext_ctxt) { let p_toks : ~[syntax::ast::token_tree] = quote_tokens!((x, 1 .. 4, *)); let a: @syntax::ast::expr = quote_expr!(1 + 2); - let _b: Option<@syntax::ast::item> = quote_item!( const foo : int = $e_toks; ); + let _b: Option<@syntax::ast::item> = quote_item!( static foo : int = $e_toks; ); let _c: @syntax::ast::pat = quote_pat!( (x, 1 .. 4, *) ); let _d: @syntax::ast::stmt = quote_stmt!( let x = $a; ); let _e: @syntax::ast::expr = quote_expr!( match foo { $p_toks => 10 } ); diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 38854abff47f1..194f0e71b1733 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -15,9 +15,9 @@ use flippity; #[cfg(bogus)] -const b: bool = false; +static b: bool = false; -const b: bool = true; +static b: bool = true; mod rustrt { #[cfg(bogus)] @@ -102,8 +102,8 @@ fn test_in_fn_ctxt() { f(); #[cfg(bogus)] - const i: int = 0; - const i: int = 1; + static i: int = 0; + static i: int = 1; fail_unless!((i == 1)); } diff --git a/src/test/run-pass/const-autoderef-newtype.rs b/src/test/run-pass/const-autoderef-newtype.rs index cb56ab3633565..a157c46403bf3 100644 --- a/src/test/run-pass/const-autoderef-newtype.rs +++ b/src/test/run-pass/const-autoderef-newtype.rs @@ -9,8 +9,8 @@ // except according to those terms. struct S(&'static [int]); -const C0: S = S([3]); -const C1: int = C0[0]; +static C0: S = S([3]); +static C1: int = C0[0]; pub fn main() { fail_unless!(C1 == 3); diff --git a/src/test/run-pass/const-autoderef.rs b/src/test/run-pass/const-autoderef.rs index 9fb6c4aa0dbd9..fa482c38d145b 100644 --- a/src/test/run-pass/const-autoderef.rs +++ b/src/test/run-pass/const-autoderef.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const A: [u8 * 1] = ['h' as u8]; -const B: u8 = (&A)[0]; -const C: &'static &'static &'static &'static [u8 * 1] = & & & &A; -const D: u8 = (&C)[0]; +static A: [u8 * 1] = ['h' as u8]; +static B: u8 = (&A)[0]; +static C: &'static &'static &'static &'static [u8 * 1] = & & & &A; +static D: u8 = (&C)[0]; pub fn main() { fail_unless!(B == A[0]); diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index a7d1739a56b9c..97544da41c024 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -14,7 +14,7 @@ enum Foo { Quux(u64, u16) } -const X: Foo = Baz; +static X: Foo = Baz; pub fn main() { match X { @@ -34,5 +34,5 @@ pub fn main() { } } -const Y: Foo = Bar(2654435769); -const Z: Foo = Quux(0x123456789abcdef0, 0x1234); +static Y: Foo = Bar(2654435769); +static Z: Foo = Quux(0x123456789abcdef0, 0x1234); diff --git a/src/test/run-pass/const-cast-ptr-int.rs b/src/test/run-pass/const-cast-ptr-int.rs index 2d7dc349c0085..eefd1aa642e1c 100644 --- a/src/test/run-pass/const-cast-ptr-int.rs +++ b/src/test/run-pass/const-cast-ptr-int.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: *u8 = 0 as *u8; +static a: *u8 = 0 as *u8; fn main() { fail_unless!(a == ptr::null()); diff --git a/src/test/run-pass/const-cast.rs b/src/test/run-pass/const-cast.rs index 64c6f368f2bfb..83f365a632018 100644 --- a/src/test/run-pass/const-cast.rs +++ b/src/test/run-pass/const-cast.rs @@ -10,10 +10,10 @@ extern fn foo() {} -const x: *u8 = foo; -const y: *libc::c_void = x as *libc::c_void; -const a: &'static int = &10; -const b: *int = a as *int; +static x: *u8 = foo; +static y: *libc::c_void = x as *libc::c_void; +static a: &'static int = &10; +static b: *int = a as *int; fn main() { fail_unless!(x as *libc::c_void == y); diff --git a/src/test/run-pass/const-const.rs b/src/test/run-pass/const-const.rs index 142bcb7f9a8e2..3f8a7da4c149d 100644 --- a/src/test/run-pass/const-const.rs +++ b/src/test/run-pass/const-const.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: int = 1; -const b: int = a + 2; +static a: int = 1; +static b: int = a + 2; pub fn main() { fail_unless!(b == 3); diff --git a/src/test/run-pass/const-contents.rs b/src/test/run-pass/const-contents.rs index 72db11c64e885..379089cc2a2d2 100644 --- a/src/test/run-pass/const-contents.rs +++ b/src/test/run-pass/const-contents.rs @@ -10,12 +10,12 @@ // Issue #570 -const lsl : int = 1 << 2; -const add : int = 1 + 2; -const addf : float = 1.0f + 2.0f; -const not : int = !0; -const notb : bool = !true; -const neg : int = -(1); +static lsl : int = 1 << 2; +static add : int = 1 + 2; +static addf : float = 1.0f + 2.0f; +static not : int = !0; +static notb : bool = !true; +static neg : int = -(1); pub fn main() { fail_unless!((lsl == 4)); diff --git a/src/test/run-pass/const-cross-crate-const.rs b/src/test/run-pass/const-cross-crate-const.rs index e01519ae8a547..130f43cfddd34 100644 --- a/src/test/run-pass/const-cross-crate-const.rs +++ b/src/test/run-pass/const-cross-crate-const.rs @@ -12,9 +12,9 @@ // aux-build:cci_const.rs extern mod cci_const; -const foo: &'static str = cci_const::foopy; -const a: uint = cci_const::uint_val; -const b: uint = cci_const::uint_expr + 5; +static foo: &'static str = cci_const::foopy; +static a: uint = cci_const::uint_val; +static b: uint = cci_const::uint_expr + 5; fn main() { fail_unless!(a == 12); diff --git a/src/test/run-pass/const-cross-crate-extern.rs b/src/test/run-pass/const-cross-crate-extern.rs index e1a4fc634bae8..723835a46d849 100644 --- a/src/test/run-pass/const-cross-crate-extern.rs +++ b/src/test/run-pass/const-cross-crate-extern.rs @@ -13,7 +13,7 @@ extern mod cci_const; use cci_const::bar; -const foo: *u8 = bar; +static foo: *u8 = bar; fn main() { fail_unless!(foo == cci_const::bar); diff --git a/src/test/run-pass/const-deref.rs b/src/test/run-pass/const-deref.rs index 71ae273aaa3b2..a69ca9cb93979 100644 --- a/src/test/run-pass/const-deref.rs +++ b/src/test/run-pass/const-deref.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const C: &'static int = &1000; -const D: int = *C; +static C: &'static int = &1000; +static D: int = *C; struct S(&'static int); -const E: &'static S = &S(C); -const F: int = ***E; +static E: &'static S = &S(C); +static F: int = ***E; pub fn main() { fail_unless!(D == 1000); diff --git a/src/test/run-pass/const-enum-byref-self.rs b/src/test/run-pass/const-enum-byref-self.rs index 57cfdd2f9d470..c4e1ea727e47e 100644 --- a/src/test/run-pass/const-enum-byref-self.rs +++ b/src/test/run-pass/const-enum-byref-self.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V, VV(int) } -const C: E = V; +static C: E = V; pub impl E { fn method(&self) { diff --git a/src/test/run-pass/const-enum-byref.rs b/src/test/run-pass/const-enum-byref.rs index a8d24dc300a85..83fafad4f99bb 100644 --- a/src/test/run-pass/const-enum-byref.rs +++ b/src/test/run-pass/const-enum-byref.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V, VV(int) } -const C: E = V; +static C: E = V; fn f(a: &E) { match *a { diff --git a/src/test/run-pass/const-enum-cast.rs b/src/test/run-pass/const-enum-cast.rs index ac0bbfda20d9b..20d7a94ccacf6 100644 --- a/src/test/run-pass/const-enum-cast.rs +++ b/src/test/run-pass/const-enum-cast.rs @@ -12,10 +12,10 @@ enum A { A1, A2 } enum B { B1=0, B2=2 } fn main () { - const c1: int = A2 as int; - const c2: int = B2 as int; - const c3: float = A2 as float; - const c4: float = B2 as float; + static c1: int = A2 as int; + static c2: int = B2 as int; + static c3: float = A2 as float; + static c4: float = B2 as float; let a1 = A2 as int; let a2 = B2 as int; let a3 = A2 as float; diff --git a/src/test/run-pass/const-enum-ptr.rs b/src/test/run-pass/const-enum-ptr.rs index 594350d29885c..c1e3889d613d9 100644 --- a/src/test/run-pass/const-enum-ptr.rs +++ b/src/test/run-pass/const-enum-ptr.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V0, V1(int) } -const C: &'static E = &V0; +static C: &'static E = &V0; pub fn main() { match *C { diff --git a/src/test/run-pass/const-enum-struct.rs b/src/test/run-pass/const-enum-struct.rs index 8ab470461eb61..7da171cc00653 100644 --- a/src/test/run-pass/const-enum-struct.rs +++ b/src/test/run-pass/const-enum-struct.rs @@ -10,7 +10,7 @@ enum E { V16(u16), V32(u32) } struct S { a: E, b: u16, c: u16 } -const C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD }; +static C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; diff --git a/src/test/run-pass/const-enum-struct2.rs b/src/test/run-pass/const-enum-struct2.rs index 49078b8efe2f2..c24db8414c416 100644 --- a/src/test/run-pass/const-enum-struct2.rs +++ b/src/test/run-pass/const-enum-struct2.rs @@ -10,7 +10,7 @@ enum E { V0, V16(u16) } struct S { a: E, b: u16, c: u16 } -const C: S = S { a: V0, b: 0x600D, c: 0xBAD }; +static C: S = S { a: V0, b: 0x600D, c: 0xBAD }; pub fn main() { let n = C.b; diff --git a/src/test/run-pass/const-enum-structlike.rs b/src/test/run-pass/const-enum-structlike.rs index 3faad1fee7e5e..86640bcc408e1 100644 --- a/src/test/run-pass/const-enum-structlike.rs +++ b/src/test/run-pass/const-enum-structlike.rs @@ -13,7 +13,7 @@ enum E { S1 { u: uint } } -const C: E = S1 { u: 23 }; +static C: E = S1 { u: 23 }; fn main() { match C { diff --git a/src/test/run-pass/const-enum-tuple.rs b/src/test/run-pass/const-enum-tuple.rs index d46207ea8123b..acefd4ff878b8 100644 --- a/src/test/run-pass/const-enum-tuple.rs +++ b/src/test/run-pass/const-enum-tuple.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V16(u16), V32(u32) } -const C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD); +static C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; diff --git a/src/test/run-pass/const-enum-tuple2.rs b/src/test/run-pass/const-enum-tuple2.rs index 08007b5b67d0e..63f1f41d9ab5a 100644 --- a/src/test/run-pass/const-enum-tuple2.rs +++ b/src/test/run-pass/const-enum-tuple2.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V0, V16(u16) } -const C: (E, u16, u16) = (V0, 0x600D, 0xBAD); +static C: (E, u16, u16) = (V0, 0x600D, 0xBAD); pub fn main() { let (_, n, _) = C; diff --git a/src/test/run-pass/const-enum-tuplestruct.rs b/src/test/run-pass/const-enum-tuplestruct.rs index a88bbca7919d3..b0d321abb09e7 100644 --- a/src/test/run-pass/const-enum-tuplestruct.rs +++ b/src/test/run-pass/const-enum-tuplestruct.rs @@ -10,7 +10,7 @@ enum E { V16(u16), V32(u32) } struct S(E, u16, u16); -const C: S = S(V16(0xDEAD), 0x600D, 0xBAD); +static C: S = S(V16(0xDEAD), 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; diff --git a/src/test/run-pass/const-enum-tuplestruct2.rs b/src/test/run-pass/const-enum-tuplestruct2.rs index 4bbadd40574b5..7fa04af3f9a58 100644 --- a/src/test/run-pass/const-enum-tuplestruct2.rs +++ b/src/test/run-pass/const-enum-tuplestruct2.rs @@ -10,7 +10,7 @@ enum E { V0, V16(u16) } struct S(E, u16, u16); -const C: S = S(V0, 0x600D, 0xBAD); +static C: S = S(V0, 0x600D, 0xBAD); pub fn main() { let S(_, n, _) = C; diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index 6dde7cc41ec7c..fd11fc422726f 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -9,9 +9,9 @@ // except according to those terms. enum E { V1(int), V0 } -const C: &'static [E] = &[V0, V1(0xDEADBEE)]; -const C0: E = C[0]; -const C1: E = C[1]; +static C: &'static [E] = &[V0, V1(0xDEADBEE)]; +static C0: E = C[0]; +static C1: E = C[1]; pub fn main() { match C0 { diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index b398bfbf0d5c1..8d152dca54c31 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V1(int), V0 } -const C: &'static [E] = &[V0, V1(0xDEADBEE), V0]; +static C: &'static [E] = &[V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 48b3c774e3969..db7982c451fa0 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V1(int), V0 } -const C: [E * 3] = [V0, V1(0xDEADBEE), V0]; +static C: [E * 3] = [V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { diff --git a/src/test/run-pass/const-expr-in-fixed-length-vec.rs b/src/test/run-pass/const-expr-in-fixed-length-vec.rs index aa5c4cbbc1d0f..69585c9d31c9e 100644 --- a/src/test/run-pass/const-expr-in-fixed-length-vec.rs +++ b/src/test/run-pass/const-expr-in-fixed-length-vec.rs @@ -13,7 +13,7 @@ fn main() { - const FOO: int = 2; + static FOO: int = 2; let _v: [int * FOO*3]; } diff --git a/src/test/run-pass/const-expr-in-vec-repeat.rs b/src/test/run-pass/const-expr-in-vec-repeat.rs index 76952ef730fa1..a04c588c07bc1 100644 --- a/src/test/run-pass/const-expr-in-vec-repeat.rs +++ b/src/test/run-pass/const-expr-in-vec-repeat.rs @@ -12,7 +12,7 @@ fn main() { - const FOO: int = 2; + static FOO: int = 2; let _v = [0, ..FOO*3*2/2]; } diff --git a/src/test/run-pass/const-extern-function.rs b/src/test/run-pass/const-extern-function.rs index 6b6a3e4d0a4e8..5e7ac4e4518ae 100644 --- a/src/test/run-pass/const-extern-function.rs +++ b/src/test/run-pass/const-extern-function.rs @@ -10,8 +10,8 @@ extern fn foopy() {} -const f: *u8 = foopy; -const s: S = S { f: foopy }; +static f: *u8 = foopy; +static s: S = S { f: foopy }; struct S { f: *u8 diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index c13215bb23621..a3611c5eb2658 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -8,22 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const x : [int * 4] = [1,2,3,4]; -const p : int = x[2]; -const y : &'static [int] = &[1,2,3,4]; -const q : int = y[2]; +static x : [int * 4] = [1,2,3,4]; +static p : int = x[2]; +static y : &'static [int] = &[1,2,3,4]; +static q : int = y[2]; struct S {a: int, b: int} -const s : S = S {a: 10, b: 20}; -const t : int = s.b; +static s : S = S {a: 10, b: 20}; +static t : int = s.b; struct K {a: int, b: int, c: D} struct D { d: int, e: int } -const k : K = K {a: 10, b: 20, c: D {d: 30, - e: 40}}; -const m : int = k.c.e; +static k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; +static m : int = k.c.e; pub fn main() { io::println(fmt!("%?", p)); diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index c3d09a58b5b7b..1c0cfa64d88f2 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -14,7 +14,7 @@ fn foo() -> int { struct Bar { f: &'self fn() -> int } -const b : Bar/&static = Bar { f: foo }; +static b : Bar/&static = Bar { f: foo }; pub fn main() { fail_unless!((b.f)() == 0xca7f000d); diff --git a/src/test/run-pass/const-negative.rs b/src/test/run-pass/const-negative.rs index a255082933165..e2add6409f75d 100644 --- a/src/test/run-pass/const-negative.rs +++ b/src/test/run-pass/const-negative.rs @@ -10,7 +10,7 @@ // Issue #358 -const toplevel_mod: int = -1; +static toplevel_mod: int = -1; pub fn main() { fail_unless!(toplevel_mod == -1); diff --git a/src/test/run-pass/const-nullary-enum.rs b/src/test/run-pass/const-nullary-enum.rs index cbc862185a8d8..bc61c8e9aecf5 100644 --- a/src/test/run-pass/const-nullary-enum.rs +++ b/src/test/run-pass/const-nullary-enum.rs @@ -14,7 +14,7 @@ enum Foo { Boo, } -const X: Foo = Bar; +static X: Foo = Bar; pub fn main() { match X { @@ -27,4 +27,4 @@ pub fn main() { } } -const Y: Foo = Baz; +static Y: Foo = Baz; diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index 184a9da6fb791..75fd2774095c1 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -12,11 +12,11 @@ enum Foo { Bar = 0xDEADBEE } -const X: Foo = Bar; +static X: Foo = Bar; pub fn main() { fail_unless!(((X as uint) == 0xDEADBEE)); fail_unless!(((Y as uint) == 0xDEADBEE)); } -const Y: Foo = Bar; +static Y: Foo = Bar; diff --git a/src/test/run-pass/const-rec-and-tup.rs b/src/test/run-pass/const-rec-and-tup.rs index ff1f3338e444a..77d4521e70943 100644 --- a/src/test/run-pass/const-rec-and-tup.rs +++ b/src/test/run-pass/const-rec-and-tup.rs @@ -12,11 +12,11 @@ struct Pair { a: float, b: float } struct AnotherPair { x: (i64, i64), y: Pair } -const x : (i32,i32) = (0xfeedf00dd,0xca11ab1e); -const y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, - 0xabababab_abababab), - y: Pair { a: 3.14159265358979323846, - b: 2.7182818284590452354 }}; +static x : (i32,i32) = (0xfeedf00dd,0xca11ab1e); +static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, + 0xabababab_abababab), + y: Pair { a: 3.14159265358979323846, + b: 2.7182818284590452354 }}; pub fn main() { let (p, _) = y.x; diff --git a/src/test/run-pass/const-region-ptrs-noncopy.rs b/src/test/run-pass/const-region-ptrs-noncopy.rs index 078ae7661cff4..23d1d63f18996 100644 --- a/src/test/run-pass/const-region-ptrs-noncopy.rs +++ b/src/test/run-pass/const-region-ptrs-noncopy.rs @@ -10,8 +10,8 @@ type Big = [u64 * 8]; struct Pair { a: int, b: &'self Big } -const x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); -const y: &'static Pair<'static> = &Pair {a: 15, b: x}; +static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); +static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { fail_unless!(ptr::addr_of(x) == ptr::addr_of(y.b)); diff --git a/src/test/run-pass/const-region-ptrs.rs b/src/test/run-pass/const-region-ptrs.rs index dbb3abe7dafb1..32c5f65bf3ade 100644 --- a/src/test/run-pass/const-region-ptrs.rs +++ b/src/test/run-pass/const-region-ptrs.rs @@ -11,9 +11,9 @@ struct Pair { a: int, b: &'self int } -const x: &'static int = &10; +static x: &'static int = &10; -const y: &'static Pair<'static> = &Pair {a: 15, b: x}; +static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { io::println(fmt!("x = %?", *x)); diff --git a/src/test/run-pass/const-str-ptr.rs b/src/test/run-pass/const-str-ptr.rs index a1637f6ebb831..2560431b53209 100644 --- a/src/test/run-pass/const-str-ptr.rs +++ b/src/test/run-pass/const-str-ptr.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; -const c: &'static [u8 * 3] = &a; -const b: *u8 = c as *u8; +static a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; +static c: &'static [u8 * 3] = &a; +static b: *u8 = c as *u8; fn main() { let foo = &a as *u8; diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index f2b5be4e36ff9..a826f7bf564cd 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -20,9 +20,9 @@ impl cmp::Eq for foo { fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } } -const x : foo = foo { a:1, b:2, c: 3 }; -const y : foo = foo { b:2, c:3, a: 1 }; -const z : &'static foo = &foo { a: 10, b: 22, c: 12 }; +static x : foo = foo { a:1, b:2, c: 3 }; +static y : foo = foo { b:2, c:3, a: 1 }; +static z : &'static foo = &foo { a: 10, b: 22, c: 12 }; pub fn main() { fail_unless!(x.b == 2); diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index 9a25a2eb1aa89..857997b29d264 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -10,7 +10,7 @@ struct Bar(int, int); -const X: Bar = Bar(1, 2); +static X: Bar = Bar(1, 2); pub fn main() { match X { diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs index bc996314e0335..b4acde098baf3 100644 --- a/src/test/run-pass/const-unit-struct.rs +++ b/src/test/run-pass/const-unit-struct.rs @@ -10,7 +10,7 @@ struct Foo; -const X: Foo = Foo; +static X: Foo = Foo; pub fn main() { match X { diff --git a/src/test/run-pass/const-vec-of-fns.rs b/src/test/run-pass/const-vec-of-fns.rs index 5598756ac75a6..deb1a0769f73c 100644 --- a/src/test/run-pass/const-vec-of-fns.rs +++ b/src/test/run-pass/const-vec-of-fns.rs @@ -9,16 +9,16 @@ // except according to those terms. /*! - * Try to double-check that const fns have the right size (with or + * Try to double-check that static fns have the right size (with or * without dummy env ptr, as appropriate) by iterating a size-2 array. - * If the const size differs from the runtime size, the second element + * If the static size differs from the runtime size, the second element * should be read as a null or otherwise wrong pointer and crash. */ fn f() { } -const bare_fns: &'static [extern fn()] = &[f, f]; +static bare_fns: &'static [extern fn()] = &[f, f]; struct S<'self>(&'self fn()); -const closures: &'static [S<'static>] = &[S(f), S(f)]; +static closures: &'static [S<'static>] = &[S(f), S(f)]; pub fn main() { for bare_fns.each |&bare_fn| { bare_fn() } diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 1e86ff3515b4f..736335464b24d 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const x : [int * 4] = [1,2,3,4]; -const y : &'static [int] = &[1,2,3,4]; +static x : [int * 4] = [1,2,3,4]; +static y : &'static [int] = &[1,2,3,4]; pub fn main() { io::println(fmt!("%?", x[1])); diff --git a/src/test/run-pass/const.rs b/src/test/run-pass/const.rs index e935a2cd434d9..d9d84c3fd5048 100644 --- a/src/test/run-pass/const.rs +++ b/src/test/run-pass/const.rs @@ -10,6 +10,6 @@ -const i: int = 10; +static i: int = 10; pub fn main() { debug!("%i", i); } diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index e68414958806a..5e79838c4b7a3 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const FOO: int = 10; -const BAR: int = 3; +static FOO: int = 10; +static BAR: int = 3; pub fn main() { let x: int = 3; diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 1a21fa0a5d759..3e48b8f05baee 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -9,7 +9,7 @@ // except according to those terms. -const tau: float = 2.0*3.14159265358979323; +static tau: float = 2.0*3.14159265358979323; struct Point {x: float, y: float} struct Size {w: float, h: float} diff --git a/src/test/run-pass/export-glob-imports-target.rs b/src/test/run-pass/export-glob-imports-target.rs index ae17d6ca8b3d5..6b97c9031f0a9 100644 --- a/src/test/run-pass/export-glob-imports-target.rs +++ b/src/test/run-pass/export-glob-imports-target.rs @@ -18,7 +18,7 @@ mod foo { use foo::bar::*; pub mod bar { - pub const a : int = 10; + pub static a : int = 10; } pub fn zum() { let b = a; diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs index f66ffbd0e0e65..430da7a3f608b 100644 --- a/src/test/run-pass/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign-mod-unused-const.rs @@ -11,7 +11,7 @@ mod foo { #[nolink] pub extern { - pub const errno: int; + pub static errno: int; } } diff --git a/src/test/run-pass/issue-1660.rs b/src/test/run-pass/issue-1660.rs index da8dfbf679224..5c8b4be0cee1a 100644 --- a/src/test/run-pass/issue-1660.rs +++ b/src/test/run-pass/issue-1660.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - const _x: int = 1<<2; + static _x: int = 1<<2; } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index c769c33390fa5..f3a81771c2137 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -const generations: uint = 1024+256+128+49; +static generations: uint = 1024+256+128+49; fn child_no(x: uint) -> ~fn() { || { diff --git a/src/test/run-pass/issue-2428.rs b/src/test/run-pass/issue-2428.rs index 766bc23173c60..a571c49c438b7 100644 --- a/src/test/run-pass/issue-2428.rs +++ b/src/test/run-pass/issue-2428.rs @@ -10,7 +10,7 @@ pub fn main() { let foo = 100; - const quux: int = 5; + static quux: int = 5; enum Stuff { Bar = quux diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 5de3e88acc0e4..24fe671337287 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -29,7 +29,7 @@ mod test_first_item_in_file_mod {} mod test_single_attr_outer { #[attr = "val"] - pub const x: int = 10; + pub static x: int = 10; #[attr = "val"] pub fn f() { } @@ -47,7 +47,7 @@ mod test_single_attr_outer { mod test_multi_attr_outer { #[attr1 = "val"] #[attr2 = "val"] - pub const x: int = 10; + pub static x: int = 10; #[attr1 = "val"] #[attr2 = "val"] @@ -72,7 +72,7 @@ mod test_multi_attr_outer { mod test_stmt_single_attr_outer { pub fn f() { #[attr = "val"] - const x: int = 10; + static x: int = 10; #[attr = "val"] fn f() { } @@ -95,7 +95,7 @@ mod test_stmt_multi_attr_outer { #[attr1 = "val"] #[attr2 = "val"] - const x: int = 10; + static x: int = 10; #[attr1 = "val"] #[attr2 = "val"] diff --git a/src/test/run-pass/mod-merge-hack-inst.rs b/src/test/run-pass/mod-merge-hack-inst.rs index e8cf244c6b18c..999c6ac2a71d5 100644 --- a/src/test/run-pass/mod-merge-hack-inst.rs +++ b/src/test/run-pass/mod-merge-hack-inst.rs @@ -12,5 +12,5 @@ mod inst { pub type T = i32; - pub const bits: uint = 32; + pub static bits: uint = 32; } diff --git a/src/test/run-pass/mod-merge-hack-template.rs b/src/test/run-pass/mod-merge-hack-template.rs index 8628d84d4e7db..7f7dd33dc099f 100644 --- a/src/test/run-pass/mod-merge-hack-template.rs +++ b/src/test/run-pass/mod-merge-hack-template.rs @@ -12,5 +12,5 @@ use T = self::inst::T; -pub const bits: uint = inst::bits; +pub static bits: uint = inst::bits; pub fn min(x: T, y: T) -> T { if x < y { x } else { y } } diff --git a/src/test/run-pass/resolve-issue-2428.rs b/src/test/run-pass/resolve-issue-2428.rs index 20cda911cdd47..799db4ed2125a 100644 --- a/src/test/run-pass/resolve-issue-2428.rs +++ b/src/test/run-pass/resolve-issue-2428.rs @@ -10,6 +10,6 @@ // xfail-test -const foo: int = 4 >> 1; +static foo: int = 4 >> 1; enum bs { thing = foo } pub fn main() { fail_unless!((thing as int == foo)); } diff --git a/src/test/run-pass/shift.rs b/src/test/run-pass/shift.rs index c6165c1530a22..cea32fc745eca 100644 --- a/src/test/run-pass/shift.rs +++ b/src/test/run-pass/shift.rs @@ -54,28 +54,28 @@ fn test_expr() { } fn test_const() { - const r1_1: uint = 10u >> 2u8; - const r2_1: uint = 10u << 4u8; + static r1_1: uint = 10u >> 2u8; + static r2_1: uint = 10u << 4u8; fail_unless!(r1_1 == 2 as uint); fail_unless!(r2_1 == 160 as uint); - const r1_2: u8 = 10u8 >> 2u; - const r2_2: u8 = 10u8 << 4u; + static r1_2: u8 = 10u8 >> 2u; + static r2_2: u8 = 10u8 << 4u; fail_unless!(r1_2 == 2 as u8); fail_unless!(r2_2 == 160 as u8); - const r1_3: int = 10 >> 2i8; - const r2_3: int = 10 << 4i8; + static r1_3: int = 10 >> 2i8; + static r2_3: int = 10 << 4i8; fail_unless!(r1_3 == 2 as int); fail_unless!(r2_3 == 160 as int); - const r1_4: i8 = 10i8 >> 2; - const r2_4: i8 = 10i8 << 4; + static r1_4: i8 = 10i8 >> 2; + static r2_4: i8 = 10i8 << 4; fail_unless!(r1_4 == 2 as i8); fail_unless!(r2_4 == 160 as i8); - const r1_5: uint = 10u >> 2i8; - const r2_5: uint = 10u << 4i8; + static r1_5: uint = 10u >> 2i8; + static r2_5: uint = 10u << 4i8; fail_unless!(r1_5 == 2 as uint); fail_unless!(r2_5 == 160 as uint); } From a8dc8317c76f1ce48fc9cd9b8fd91b7ee9a9b7c6 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 14:51:35 -0700 Subject: [PATCH 04/10] libsyntax: Stop parsing `const`. --- src/libsyntax/parse/obsolete.rs | 6 ++++++ src/libsyntax/parse/parser.rs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index a987ae948a48f..0f4de9257c99c 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -60,6 +60,7 @@ pub enum ObsoleteSyntax { ObsoleteConstManagedPointer, ObsoletePurity, ObsoleteStaticMethod, + ObsoleteConstItem, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -203,6 +204,11 @@ pub impl Parser { "`static` notation", "`static` is superfluous; remove it" ), + ObsoleteConstItem => ( + "`const` item", + "`const` items are now `static` items; replace `const` with \ + `static`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6f2c0f7ddf5cd..b7cc0b3502386 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -81,6 +81,7 @@ use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf}; use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer}; use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod}; +use parse::obsolete::{ObsoleteConstItem}; 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}; @@ -3563,7 +3564,9 @@ pub impl Parser { let lo = self.span.lo; // XXX: Obsolete; remove after snap. - if !self.eat_keyword(&~"const") { + if self.eat_keyword(&~"const") { + self.obsolete(*self.last_span, ObsoleteConstItem); + } else { self.expect_keyword(&~"static"); } @@ -3959,6 +3962,9 @@ pub impl Parser { (self.is_keyword(&~"static") && !self.token_is_keyword(&~"fn", &self.look_ahead(1)))) { // CONST ITEM + if self.is_keyword(&~"const") { + self.obsolete(*self.span, ObsoleteConstItem); + } self.bump(); let (ident, item_, extra_attrs) = self.parse_item_const(); return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_, From f11a53cb9d1fb350210ce479d8c1996440066cce Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 15:52:50 -0700 Subject: [PATCH 05/10] librustc: Add explicit lifetime binders and new lifetime notation in core/std/syntax/rustc --- src/libcore/condition.rs | 14 +-- src/libcore/unstable/finally.rs | 4 +- src/librustc/middle/borrowck/preserve.rs | 2 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/lang_items.rs | 10 +- src/librustc/middle/trans/_match.rs | 105 ++++++++++++--------- src/librustc/middle/typeck/check/method.rs | 2 +- src/libstd/arc.rs | 12 +-- src/libstd/flatpipes.rs | 4 +- src/libstd/json.rs | 4 +- src/libstd/sort.rs | 12 +-- src/libstd/sync.rs | 39 ++++---- src/libstd/treemap.rs | 22 ++--- src/libstd/workcache.rs | 15 ++- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- 16 files changed, 135 insertions(+), 116 deletions(-) diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index 66e9b970fa789..767b6ecfad4b8 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -22,11 +22,11 @@ pub struct Handler { pub struct Condition { name: &'static str, - key: task::local_data::LocalDataKey/&self> + key: task::local_data::LocalDataKey<'self, Handler> } -pub impl Condition/&self { - fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self { +pub impl Condition<'self, T, U> { + fn trap(&self, h: &'self fn(T) -> U) -> Trap<'self, T, U> { unsafe { let p : *RustClosure = ::cast::transmute(&h); let prev = task::local_data::local_data_get(self.key); @@ -65,11 +65,11 @@ pub impl Condition/&self { } struct Trap { - cond: &'self Condition/&self, + cond: &'self Condition<'self, T, U>, handler: @Handler } -pub impl Trap/&self { +pub impl Trap<'self, T, U> { fn in(&self, inner: &'self fn() -> V) -> V { unsafe { let _g = Guard { cond: self.cond }; @@ -81,11 +81,11 @@ pub impl Trap/&self { } struct Guard { - cond: &'self Condition/&self + cond: &'self Condition<'self, T, U> } #[unsafe_destructor] -impl Drop for Guard/&self { +impl Drop for Guard<'self, T, U> { fn finalize(&self) { unsafe { debug!("Guard: popping handler from TLS"); diff --git a/src/libcore/unstable/finally.rs b/src/libcore/unstable/finally.rs index c96889cebc8be..04d1d6f11b929 100644 --- a/src/libcore/unstable/finally.rs +++ b/src/libcore/unstable/finally.rs @@ -41,12 +41,12 @@ impl Finally for &'self fn() -> T { } } -struct Finallyalizer { +struct Finallyalizer<'self> { dtor: &'self fn() } #[unsafe_destructor] -impl Drop for Finallyalizer/&self { +impl<'self> Drop for Finallyalizer<'self> { fn finalize(&self) { (self.dtor)(); } diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 962af48a70c8f..0440f4525ff36 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -79,7 +79,7 @@ struct PreserveCtxt { root_managed_data: bool } -pub impl PreserveCtxt/&self { +pub impl<'self> PreserveCtxt<'self> { fn tcx(&self) -> ty::ctxt { self.bccx.tcx } fn preserve(&self, cmt: cmt) -> bckres { diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 75247e78acaa9..02b0e17a346b8 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -481,7 +481,7 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { } /// This is rather subtle. When we are casting a value to a -/// instantiated trait like `a as trait/&r`, regionck already ensures +/// instantiated trait like `a as trait<'r>`, regionck already ensures /// that any borrowed pointers that appear in the type of `a` are /// bounded by `&r`. However, it is possible that there are *type /// parameters* in the type of `a`, and those *type parameters* may diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index c319ca891052f..669587205d546 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -255,10 +255,10 @@ pub impl LanguageItems { } } -fn LanguageItemCollector(crate: @crate, - session: Session, - items: &'r mut LanguageItems) - -> LanguageItemCollector/&r { +fn LanguageItemCollector<'r>(crate: @crate, + session: Session, + items: &'r mut LanguageItems) + -> LanguageItemCollector<'r> { let item_refs = HashMap(); item_refs.insert(@~"const", ConstTraitLangItem as uint); @@ -320,7 +320,7 @@ struct LanguageItemCollector { item_refs: HashMap<@~str, uint>, } -pub impl LanguageItemCollector/&self { +pub impl<'self> LanguageItemCollector<'self> { fn match_and_collect_meta_item(&self, item_def_id: def_id, meta_item: @meta_item) { match meta_item.node { diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index a529fd669394a..7529b2132fd9e 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -331,9 +331,9 @@ pub struct ArmData { bindings_map: BindingsMap } -pub struct Match { +pub struct Match<'self> { pats: ~[@ast::pat], - data: @ArmData/&self + data: @ArmData<'self> } pub fn match_to_str(bcx: block, m: &Match) -> ~str { @@ -359,9 +359,11 @@ pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool { return false; } -pub fn expand_nested_bindings(bcx: block, m: &[@Match/&r], - col: uint, val: ValueRef) - -> ~[@Match/&r] { +pub fn expand_nested_bindings<'r>(bcx: block, + m: &[@Match<'r>], + col: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -402,9 +404,13 @@ pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) { } } -pub fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r], - col: uint, val: ValueRef, e: enter_pat) - -> ~[@Match/&r] { +pub fn enter_match<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef, + e: enter_pat) + -> ~[@Match<'r>] { debug!("enter_match(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -445,9 +451,12 @@ pub fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r], return result; } -pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r], - col: uint, val: ValueRef) - -> ~[@Match/&r] { +pub fn enter_default<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("enter_default(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -488,9 +497,13 @@ pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r], // so all patterns must either be records (resp. tuples) or // wildcards -pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, - variant_size: uint, val: ValueRef) - -> ~[@Match/&r] { +pub fn enter_opt<'r>(bcx: block, + m: &[@Match<'r>], + opt: &Opt, + col: uint, + variant_size: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("enter_opt(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -599,11 +612,11 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint, pub fn enter_rec_or_struct(bcx: block, dm: DefMap, - m: &[@Match/&r], + m: &[@Match<'r>], col: uint, fields: &[ast::ident], val: ValueRef) - -> ~[@Match/&r] { + -> ~[@Match<'r>] { debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -632,9 +645,13 @@ pub fn enter_rec_or_struct(bcx: block, } } -pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r], - col: uint, val: ValueRef, n_elts: uint) - -> ~[@Match/&r] { +pub fn enter_tup<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef, + n_elts: uint) + -> ~[@Match<'r>] { debug!("enter_tup(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -656,13 +673,13 @@ pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r], } } -pub fn enter_tuple_struct(bcx: block, - dm: DefMap, - m: &[@Match/&r], - col: uint, - val: ValueRef, - n_elts: uint) - -> ~[@Match/&r] { +pub fn enter_tuple_struct<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef, + n_elts: uint) + -> ~[@Match<'r>] { debug!("enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -682,12 +699,12 @@ pub fn enter_tuple_struct(bcx: block, } } -pub fn enter_box(bcx: block, - dm: DefMap, - m: &[@Match/&r], - col: uint, - val: ValueRef) - -> ~[@Match/&r] { +pub fn enter_box<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("enter_box(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -709,12 +726,12 @@ pub fn enter_box(bcx: block, } } -pub fn enter_uniq(bcx: block, - dm: DefMap, - m: &[@Match/&r], - col: uint, - val: ValueRef) - -> ~[@Match/&r] { +pub fn enter_uniq<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("enter_uniq(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -736,12 +753,12 @@ pub fn enter_uniq(bcx: block, } } -pub fn enter_region(bcx: block, - dm: DefMap, - m: &[@Match/&r], - col: uint, - val: ValueRef) - -> ~[@Match/&r] { +pub fn enter_region<'r>(bcx: block, + dm: DefMap, + m: &[@Match<'r>], + col: uint, + val: ValueRef) + -> ~[@Match<'r>] { debug!("enter_region(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 2973492cac4b9..c550e5c71e491 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -192,7 +192,7 @@ pub enum TransformTypeFlag { TransformTypeForObject, } -pub impl LookupContext/&self { +pub impl<'self> LookupContext<'self> { fn do_lookup(&self, self_ty: ty::t) -> Option { let mut self_ty = structurally_resolved_type(self.fcx, self.self_expr.span, diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 5a08884777c18..d037acff0ede7 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -25,13 +25,13 @@ use core::ptr; use core::task; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. -pub struct Condvar { +pub struct Condvar<'self> { is_mutex: bool, failed: &'self mut bool, - cond: &'self sync::Condvar/&self + cond: &'self sync::Condvar<'self> } -pub impl Condvar/&self { +pub impl<'self> Condvar<'self> { /// Atomically exit the associated ARC and block until a signal is sent. #[inline(always)] fn wait(&self) { self.wait_on(0) } @@ -375,7 +375,7 @@ pub impl RWARC { } /// To be called inside of the write_downgrade block. - fn downgrade(&self, token: RWWriteMode/&a) -> RWReadMode/&a { + fn downgrade(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; let RWWriteMode { @@ -420,7 +420,7 @@ pub struct RWReadMode<'self, T> { token: sync::RWlockReadMode<'self>, } -pub impl RWWriteMode/&self { +pub impl RWWriteMode<'self, T> { /// Access the pre-downgrade RWARC in write mode. fn write(&self, blk: &fn(x: &mut T) -> U) -> U { match *self { @@ -458,7 +458,7 @@ pub impl RWWriteMode/&self { } } -pub impl RWReadMode/&self { +pub impl RWReadMode<'self, T> { /// Access the post-downgrade rwlock in read mode. fn read(&self, blk: &fn(x: &T) -> U) -> U { match *self { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 01d672c9b26f5..587509af9fa84 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -466,8 +466,8 @@ pub mod flatteners { fn from_writer(w: @Writer) -> Self; } - impl FromReader for json::Decoder/&self { - fn from_reader(r: @Reader) -> json::Decoder/&self { + impl FromReader for json::Decoder<'self> { + fn from_reader(r: @Reader) -> json::Decoder<'self> { match json::from_reader(r) { Ok(json) => { json::Decoder(json) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 0973e90dad3d2..f1f736e01a162 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -749,7 +749,7 @@ pub fn Decoder(json: Json) -> Decoder { Decoder { json: json, stack: ~[] } } -priv impl Decoder/&self { +priv impl Decoder<'self> { fn peek(&self) -> &'self Json { if vec::uniq_len(&const self.stack) == 0 { self.stack.push(&self.json); @@ -765,7 +765,7 @@ priv impl Decoder/&self { } } -impl serialize::Decoder for Decoder/&self { +impl serialize::Decoder for Decoder<'self> { fn read_nil(&self) -> () { debug!("read_nil"); match *self.pop() { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 33f585d32fc9f..1dc990526f0b6 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1191,7 +1191,7 @@ mod big_tests { } #[unsafe_destructor] - impl Drop for LVal/&self { + impl<'self> Drop for LVal<'self> { fn finalize(&self) { let x = unsafe { task::local_data::local_data_get(self.key) }; match x { @@ -1205,17 +1205,17 @@ mod big_tests { } } - impl Ord for LVal/&self { - fn lt(&self, other: &'a LVal/&self) -> bool { + impl<'self> Ord for LVal<'self> { + fn lt(&self, other: &'a LVal<'self>) -> bool { (*self).val < other.val } - fn le(&self, other: &'a LVal/&self) -> bool { + fn le(&self, other: &'a LVal<'self>) -> bool { (*self).val <= other.val } - fn gt(&self, other: &'a LVal/&self) -> bool { + fn gt(&self, other: &'a LVal<'self>) -> bool { (*self).val > other.val } - fn ge(&self, other: &'a LVal/&self) -> bool { + fn ge(&self, other: &'a LVal<'self>) -> bool { (*self).val >= other.val } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 00de601da6fa3..569c67eac93fb 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -168,7 +168,7 @@ type SemAndSignalRelease = SemReleaseGeneric<'self, ~[Waitqueue]>; struct SemReleaseGeneric { sem: &'self Sem } #[unsafe_destructor] -impl Drop for SemReleaseGeneric/&self { +impl Drop for SemReleaseGeneric<'self, Q> { fn finalize(&self) { unsafe { self.sem.release(); @@ -176,26 +176,26 @@ impl Drop for SemReleaseGeneric/&self { } } -fn SemRelease(sem: &'r Sem<()>) -> SemRelease/&r { +fn SemRelease(sem: &'r Sem<()>) -> SemRelease<'r> { SemReleaseGeneric { sem: sem } } fn SemAndSignalRelease(sem: &'r Sem<~[Waitqueue]>) - -> SemAndSignalRelease/&r { + -> SemAndSignalRelease<'r> { SemReleaseGeneric { sem: sem } } /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. -pub struct Condvar { priv sem: &'self Sem<~[Waitqueue]> } +pub struct Condvar<'self> { priv sem: &'self Sem<~[Waitqueue]> } #[unsafe_destructor] -impl Drop for Condvar/&self { fn finalize(&self) {} } +impl<'self> Drop for Condvar<'self> { fn finalize(&self) {} } -pub impl Condvar/&self { +pub impl Condvar<'self> { /** * Atomically drop the associated lock, and block until a signal is sent. * @@ -266,7 +266,7 @@ pub impl Condvar/&self { } #[unsafe_destructor] - impl Drop for SemAndSignalReacquire/&self { + impl<'self> Drop for SemAndSignalReacquire<'self> { fn finalize(&self) { unsafe { // Needs to succeed, instead of itself dying. @@ -278,7 +278,7 @@ pub impl Condvar/&self { } fn SemAndSignalReacquire(sem: &'r Sem<~[Waitqueue]>) - -> SemAndSignalReacquire/&r { + -> SemAndSignalReacquire<'r> { SemAndSignalReacquire { sem: sem } @@ -586,7 +586,9 @@ pub impl RWlock { } /// To be called inside of the write_downgrade block. - fn downgrade(&self, token: RWlockWriteMode/&a) -> RWlockReadMode/&a { + fn downgrade<'a>(&self, + token: RWlockWriteMode<'a>) + -> RWlockReadMode<'a> { if !ptr::ref_eq(self, token.lock) { fail!(~"Can't downgrade() with a different rwlock's write_mode!"); } @@ -619,7 +621,7 @@ struct RWlockReleaseRead { } #[unsafe_destructor] -impl Drop for RWlockReleaseRead/&self { +impl<'self> Drop for RWlockReleaseRead<'self> { fn finalize(&self) { unsafe { do task::unkillable { @@ -641,7 +643,7 @@ impl Drop for RWlockReleaseRead/&self { } } -fn RWlockReleaseRead(lock: &'r RWlock) -> RWlockReleaseRead/&r { +fn RWlockReleaseRead<'r>(lock: &'r RWlock) -> RWlockReleaseRead<'r> { RWlockReleaseRead { lock: lock } @@ -655,7 +657,7 @@ struct RWlockReleaseDowngrade { } #[unsafe_destructor] -impl Drop for RWlockReleaseDowngrade/&self { +impl<'self> Drop for RWlockReleaseDowngrade<'self> { fn finalize(&self) { unsafe { do task::unkillable { @@ -685,23 +687,24 @@ impl Drop for RWlockReleaseDowngrade/&self { } } -fn RWlockReleaseDowngrade(lock: &'r RWlock) -> RWlockReleaseDowngrade/&r { +fn RWlockReleaseDowngrade<'r>(lock: &'r RWlock) + -> RWlockReleaseDowngrade<'r> { RWlockReleaseDowngrade { lock: lock } } /// The "write permission" token used for rwlock.write_downgrade(). -pub struct RWlockWriteMode { priv lock: &'self RWlock } +pub struct RWlockWriteMode<'self> { priv lock: &'self RWlock } #[unsafe_destructor] -impl Drop for RWlockWriteMode/&self { fn finalize(&self) {} } +impl<'self> Drop for RWlockWriteMode<'self> { fn finalize(&self) {} } /// The "read permission" token used for rwlock.write_downgrade(). pub struct RWlockReadMode { priv lock: &'self RWlock } #[unsafe_destructor] -impl Drop for RWlockReadMode/&self { fn finalize(&self) {} } +impl<'self> Drop for RWlockReadMode<'self> { fn finalize(&self) {} } -pub impl RWlockWriteMode/&self { +pub impl<'self> RWlockWriteMode<'self> { /// Access the pre-downgrade rwlock in write mode. fn write(&self, blk: &fn() -> U) -> U { blk() } /// Access the pre-downgrade rwlock in write mode with a condvar. @@ -710,7 +713,7 @@ pub impl RWlockWriteMode/&self { } } -pub impl RWlockReadMode/&self { +pub impl<'self> RWlockReadMode<'self> { /// Access the post-downgrade rwlock in read mode. fn read(&self, blk: &fn() -> U) -> U { blk() } } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index e42c659072441..9fab2fce71171 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -190,7 +190,7 @@ pub impl TreeMap { /// Get a lazy iterator over the key-value pairs in the map. /// Requires that it be frozen (immutable). - fn iter(&self) -> TreeMapIterator/&self { + fn iter(&self) -> TreeMapIterator<'self, K, V> { TreeMapIterator{stack: ~[], node: &self.root} } } @@ -204,8 +204,8 @@ pub struct TreeMapIterator { /// Advance the iterator to the next node (in order) and return a /// tuple with a reference to the key and value. If there are no /// more nodes, return `None`. -pub fn map_next(iter: &mut TreeMapIterator/&r) - -> Option<(&'r K, &'r V)> { +pub fn map_next<'r, K, V>(iter: &mut TreeMapIterator<'r, K, V>) + -> Option<(&'r K, &'r V)> { while !iter.stack.is_empty() || iter.node.is_some() { match *iter.node { Some(ref x) => { @@ -223,8 +223,8 @@ pub fn map_next(iter: &mut TreeMapIterator/&r) } /// Advance the iterator through the map -pub fn map_advance(iter: &mut TreeMapIterator/&r, - f: &fn((&'r K, &'r V)) -> bool) { +pub fn map_advance<'r, K, V>(iter: &mut TreeMapIterator<'r, K, V>, + f: &fn((&'r K, &'r V)) -> bool) { loop { match map_next(iter) { Some(x) => { @@ -506,27 +506,27 @@ pub impl TreeSet { /// Get a lazy iterator over the values in the set. /// Requires that it be frozen (immutable). #[inline(always)] - fn iter(&self) -> TreeSetIterator/&self { + fn iter(&self) -> TreeSetIterator<'self, T> { TreeSetIterator{iter: self.map.iter()} } } /// Lazy forward iterator over a set -pub struct TreeSetIterator { - priv iter: TreeMapIterator/&self +pub struct TreeSetIterator<'self, T> { + priv iter: TreeMapIterator<'self, T, ()> } /// Advance the iterator to the next node (in order). If this iterator is /// finished, does nothing. #[inline(always)] -pub fn set_next(iter: &mut TreeSetIterator/&r) -> Option<&'r T> { +pub fn set_next<'r, T>(iter: &mut TreeSetIterator<'r, T>) -> Option<&'r T> { do map_next(&mut iter.iter).map |&(value, _)| { value } } /// Advance the iterator through the set #[inline(always)] -pub fn set_advance(iter: &mut TreeSetIterator/&r, - f: &fn(&'r T) -> bool) { +pub fn set_advance<'r, T>(iter: &mut TreeSetIterator<'r, T>, + f: &fn(&'r T) -> bool) { do map_advance(&mut iter.iter) |(k, _)| { f(k) } } diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index b26b4b1c3330b..f477a8c9f910b 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -234,9 +234,8 @@ fn json_encode>(t: &T) -> ~str { } } -fn json_decode>( // FIXME(#5121) - s: &str) -> T -{ +// FIXME(#5121) +fn json_decode>>(s: &str) -> T { do io::with_str_reader(s) |rdr| { let j = result::unwrap(json::from_reader(rdr)); Decodable::decode(&json::Decoder(j)) @@ -266,7 +265,7 @@ pub impl Context { fn prep + - Decodable>( // FIXME(#5121) + Decodable>>( // FIXME(#5121) @self, fn_name:&str, blk: &fn(@Mut)->Work) -> Work { @@ -284,7 +283,7 @@ trait TPrep { fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool; fn exec + - Decodable>( // FIXME(#5121) + Decodable>>( // FIXME(#5121) &self, blk: ~fn(&Exec) -> T) -> Work; } @@ -325,7 +324,7 @@ impl TPrep for @Mut { fn exec + - Decodable>( // FIXME(#5121) + Decodable>>( // FIXME(#5121) &self, blk: ~fn(&Exec) -> T) -> Work { let mut bo = Some(blk); @@ -366,7 +365,7 @@ impl TPrep for @Mut { pub impl + - Decodable> Work { // FIXME(#5121) + Decodable>> Work { // FIXME(#5121) fn new(p: @Mut, e: Either>) -> Work { Work { prep: p, res: Some(e) } } @@ -375,7 +374,7 @@ pub impl + - Decodable>( // FIXME(#5121) + Decodable>>( // FIXME(#5121) w: Work) -> T { let mut ww = w; let mut s = None; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a69b3e20eb1f1..fb9d96a783174 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -494,7 +494,7 @@ pub fn core_macros() -> ~str { fn key(_x: @::core::condition::Handler<$in,$out>) { } pub static cond : - ::core::condition::Condition/&static<$in,$out> = + ::core::condition::Condition<'static,$in,$out> = ::core::condition::Condition { name: stringify!($c), key: key diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index b0628437bb0ff..688d7a57d91a5 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -109,7 +109,7 @@ pub fn is_some(&&mpu: matcher_pos_up) -> bool { } pub struct MatcherPos { - elts: ~[ast::matcher], // maybe should be /&? Need to understand regions. + elts: ~[ast::matcher], // maybe should be <'>? Need to understand regions. sep: Option, idx: uint, up: matcher_pos_up, // mutable for swapping only From bb2c1579372fa7ccf625cea7a982524ec14e9cad Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 16:07:55 -0700 Subject: [PATCH 06/10] test: Add lifetime binders and new-style lifetime parameters to the test suite --- ...gions-infer-contravariance-due-to-immutability.rs | 2 +- .../regions-infer-contravariance-due-to-ret.rs | 12 ++++++------ .../regions-infer-covariance-due-to-arg.rs | 10 +++++----- .../regions-infer-invariance-due-to-arg-and-ret.rs | 8 ++++---- .../regions-infer-invariance-due-to-mutability-3.rs | 12 ++++++------ .../regions-infer-invariance-due-to-mutability-4.rs | 12 ++++++------ .../regions-infer-invariance-due-to-mutability.rs | 8 ++++---- src/test/compile-fail/regions-trait-3.rs | 6 +++--- src/test/run-pass/const-fn-val.rs | 2 +- src/test/run-pass/issue-2502.rs | 4 ++-- src/test/run-pass/issue-2735-2.rs | 4 ++-- src/test/run-pass/issue-2735-3.rs | 4 ++-- src/test/run-pass/issue-2748-a.rs | 2 +- src/test/run-pass/regions-copy-closure.rs | 2 +- src/test/run-pass/regions-infer-contravariance.rs | 2 +- src/test/run-pass/regions-mock-trans.rs | 2 +- src/test/run-pass/regions-static-closure.rs | 2 +- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-immutability.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-immutability.rs index fca8f759da0b2..0b7477a30989e 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-immutability.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-immutability.rs @@ -20,7 +20,7 @@ fn to_shorter_lifetime(bi: contravariant<'r>) { let bj: contravariant<'blk> = bi; } -fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant/&static { +fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs index d93713f3f2335..15f40a9173582 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs @@ -13,19 +13,19 @@ // You can upcast to a *smaller region* but not a larger one. This is // the normal case. -struct contravariant { +struct contravariant<'self> { f: @fn() -> &'self int } -fn to_same_lifetime(bi: contravariant/&r) { - let bj: contravariant/&r = bi; +fn to_same_lifetime<'r>(bi: contravariant<'r>) { + let bj: contravariant<'r> = bi; } -fn to_shorter_lifetime(bi: contravariant/&r) { - let bj: contravariant/&blk = bi; +fn to_shorter_lifetime<'r>(bi: contravariant<'r>) { + let bj: contravariant<'blk> = bi; } -fn to_longer_lifetime(bi: contravariant/&r) -> contravariant/&static { +fn to_longer_lifetime<'r>(bi: contravariant<'r>) -> contravariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs index c527cdf233d6c..c92d770b1b6e4 100644 --- a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs +++ b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs @@ -16,15 +16,15 @@ struct covariant { f: @fn(x: &'self int) -> int } -fn to_same_lifetime(bi: covariant/&r) { - let bj: covariant/&r = bi; +fn to_same_lifetime<'r>(bi: covariant<'r>) { + let bj: covariant<'r> = bi; } -fn to_shorter_lifetime(bi: covariant/&r) { - let bj: covariant/&blk = bi; //~ ERROR mismatched types +fn to_shorter_lifetime<'r>(bi: covariant<'r>) { + let bj: covariant<'blk> = bi; //~ ERROR mismatched types } -fn to_longer_lifetime(bi: covariant/&r) -> covariant/&static { +fn to_longer_lifetime<'r>(bi: covariant<'r>) -> covariant<'static> { bi } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-arg-and-ret.rs b/src/test/compile-fail/regions-infer-invariance-due-to-arg-and-ret.rs index 3ad841923e313..0d4d4056a4401 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-arg-and-ret.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-arg-and-ret.rs @@ -12,19 +12,19 @@ // // You cannot convert between regions. -struct invariant { +struct invariant<'self> { f: &'self fn(x: &'self int) -> &'self int } -fn to_same_lifetime(bi: invariant<'r>) { +fn to_same_lifetime<'r>(bi: invariant<'r>) { let bj: invariant<'r> = bi; } -fn to_shorter_lifetime(bi: invariant<'r>) { +fn to_shorter_lifetime<'r>(bi: invariant<'r>) { let bj: invariant<'blk> = bi; //~ ERROR mismatched types } -fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static { +fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs index 15b39d772f08b..4c9d397f971da 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs @@ -8,19 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct invariant { +struct invariant<'self> { f: @fn(x: @mut &'self int) } -fn to_same_lifetime(bi: invariant/&r) { - let bj: invariant/&r = bi; +fn to_same_lifetime<'r>(bi: invariant<'r>) { + let bj: invariant<'r> = bi; } -fn to_shorter_lifetime(bi: invariant/&r) { - let bj: invariant/&blk = bi; //~ ERROR mismatched types +fn to_shorter_lifetime(bi: invariant<'r>) { + let bj: invariant<'blk> = bi; //~ ERROR mismatched types } -fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static { +fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index ff2b4246f01b8..6789476974b7a 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -8,19 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct invariant { +struct invariant<'self> { f: @fn() -> @mut &'self int } -fn to_same_lifetime(bi: invariant/&r) { - let bj: invariant/&r = bi; +fn to_same_lifetime(bi: invariant<'r>) { + let bj: invariant<'r> = bi; } -fn to_shorter_lifetime(bi: invariant/&r) { - let bj: invariant/&blk = bi; //~ ERROR mismatched types +fn to_shorter_lifetime(bi: invariant<'r>) { + let bj: invariant<'blk> = bi; //~ ERROR mismatched types } -fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static { +fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs index f9c6e2e36ec95..c2a7f29a8ab5b 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs @@ -8,19 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct invariant { +struct invariant<'self> { f: @mut &'self int } -fn to_same_lifetime(bi: invariant<'r>) { +fn to_same_lifetime<'r>(bi: invariant<'r>) { let bj: invariant<'r> = bi; } -fn to_shorter_lifetime(bi: invariant<'r>) { +fn to_shorter_lifetime<'r>(bi: invariant<'r>) { let bj: invariant<'blk> = bi; //~ ERROR mismatched types } -fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static { +fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> { bi //~ ERROR mismatched types } diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index e947dbf93083a..072b0e83fdf58 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -11,11 +11,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait get_ctxt { +trait get_ctxt<'self> { fn get_ctxt(self) -> &'self uint; } -fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b { +fn make_gc1(gc: @get_ctxt<'a>) -> @get_ctxt<'b> { return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a` } @@ -27,7 +27,7 @@ impl get_ctxt for Foo<'self> { fn get_ctxt(&self) -> &'self uint { self.r } } -fn make_gc2(foo: Foo/&a) -> @get_ctxt/&b { +fn make_gc2<'a,'b>(foo: Foo<'a>) -> @get_ctxt<'b> { return @foo as @get_ctxt; //~ ERROR cannot infer an appropriate lifetime } diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index 1c0cfa64d88f2..b3667d4f81ebe 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -14,7 +14,7 @@ fn foo() -> int { struct Bar { f: &'self fn() -> int } -static b : Bar/&static = Bar { f: foo }; +static b : Bar<'static> = Bar { f: foo }; pub fn main() { fail_unless!((b.f)() == 0xca7f000d); diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index cfae757aee82e..6dd8e3d83de87 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -12,13 +12,13 @@ struct font { fontbuf: &'self ~[u8], } -pub impl font/&self { +pub impl<'self> font<'self> { fn buf(&self) -> &'self ~[u8] { self.fontbuf } } -fn font(fontbuf: &'r ~[u8]) -> font/&r { +fn font(fontbuf: &'r ~[u8]) -> font<'r> { font { fontbuf: fontbuf } diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index 52a5f19344794..3f13b9f9e67ad 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -14,7 +14,7 @@ struct defer { } #[unsafe_destructor] -impl Drop for defer/&self { +impl<'self> Drop for defer<'self> { fn finalize(&self) { unsafe { *(self.b) = true; @@ -22,7 +22,7 @@ impl Drop for defer/&self { } } -fn defer(b: &'r mut bool) -> defer/&r { +fn defer<'r>(b: &'r mut bool) -> defer<'r> { defer { b: b } diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index 02e9f6f8b67e3..40c71eec4d38a 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -14,7 +14,7 @@ struct defer { } #[unsafe_destructor] -impl Drop for defer/&self { +impl<'self> Drop for defer<'self> { fn finalize(&self) { unsafe { *(self.b) = true; @@ -22,7 +22,7 @@ impl Drop for defer/&self { } } -fn defer(b: &'r mut bool) -> defer/&r { +fn defer(b: &'r mut bool) -> defer<'r> { defer { b: b } diff --git a/src/test/run-pass/issue-2748-a.rs b/src/test/run-pass/issue-2748-a.rs index f36b364aadda4..8a0f64b32d497 100644 --- a/src/test/run-pass/issue-2748-a.rs +++ b/src/test/run-pass/issue-2748-a.rs @@ -12,7 +12,7 @@ struct CMap { buf: &'self [u8], } -fn CMap(buf: &'r [u8]) -> CMap/&r { +fn CMap<'r>(buf: &'r [u8]) -> CMap<'r> { CMap { buf: buf } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 6bd42769cec0a..0fc8cb49f0777 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -12,7 +12,7 @@ struct closure_box { cl: &'self fn(), } -fn box_it(+x: &'r fn()) -> closure_box/&r { +fn box_it<'r>(+x: &'r fn()) -> closure_box<'r> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions-infer-contravariance.rs b/src/test/run-pass/regions-infer-contravariance.rs index 7d966b06e3532..ef2be398b64d1 100644 --- a/src/test/run-pass/regions-infer-contravariance.rs +++ b/src/test/run-pass/regions-infer-contravariance.rs @@ -20,7 +20,7 @@ fn with(bi: &'r boxed_int) { // Here, the upcast is allowed because the `boxed_int` type is // contravariant with respect to `&r`. See also // compile-fail/regions-infer-invariance-due-to-mutability.rs - let bi: &'blk boxed_int/&blk = bi; + let bi: &'blk boxed_int<'blk> = bi; fail_unless!(*get(bi) == 22); } diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index b249a4470cb9e..717588ab4cb9d 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -26,7 +26,7 @@ struct Ccx { fn alloc(_bcx : &'a arena) -> &'a Bcx<'a> { unsafe { return cast::reinterpret_cast( - &libc::malloc(sys::size_of::() as libc::size_t)); + &libc::malloc(sys::size_of::>() as libc::size_t)); } } diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index 0351f031e0937..5673a1e50f070 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -16,7 +16,7 @@ fn box_it(+x: &'r fn()) -> closure_box<'r> { closure_box {cl: x} } -fn call_static_closure(cl: closure_box/&static) { +fn call_static_closure(cl: closure_box<'static>) { (cl.cl)(); } From d5e3cf0128434dca7f145c55a83aab4ffc9f8c42 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 16:28:54 -0700 Subject: [PATCH 07/10] libsyntax: Stop parsing old lifetime syntax --- src/librust/rust.rc | 8 ++++---- src/libsyntax/parse/parser.rs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librust/rust.rc b/src/librust/rust.rc index 2ebc162eb6aec..b0edff033c329 100644 --- a/src/librust/rust.rc +++ b/src/librust/rust.rc @@ -47,14 +47,14 @@ enum UsageSource { UsgStr(&'self str) } -struct Command { +struct Command<'self> { cmd: &'self str, - action: Action/&self, + action: Action<'self>, usage_line: &'self str, - usage_full: UsageSource/&self + usage_full: UsageSource<'self>, } -static commands: &'static [Command/&static] = &[ +static commands: &'static [Command<'static>] = &[ Command{ cmd: "build", action: Exec("rustc"), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b7cc0b3502386..af64bf07b7c3e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -910,6 +910,7 @@ pub impl Parser { && self.look_ahead(1u) == token::BINOP(token::AND) { self.bump(); self.bump(); + self.obsolete(*self.last_span, ObsoleteLifetimeNotation); match *self.token { token::IDENT(sid, _) => { let span = copy self.span; From bc5cda3424827cfe2028a1eac552cdae80d25e1c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 17:24:26 -0700 Subject: [PATCH 08/10] libcore: Fix obsolete syntax in extfmt --- src/libcore/unstable/extfmt.rs | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index 029205f6bfae3..6773a015c6a36 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -483,12 +483,12 @@ pub mod rt { use vec; use option::{Some, None, Option}; - pub const flag_none : u32 = 0u32; - pub const flag_left_justify : u32 = 0b00000000000001u32; - pub const flag_left_zero_pad : u32 = 0b00000000000010u32; - pub const flag_space_for_sign : u32 = 0b00000000000100u32; - pub const flag_sign_always : u32 = 0b00000000001000u32; - pub const flag_alternate : u32 = 0b00000000010000u32; + pub static flag_none : u32 = 0u32; + pub static flag_left_justify : u32 = 0b00000000000001u32; + pub static flag_left_zero_pad : u32 = 0b00000000000010u32; + pub static flag_space_for_sign : u32 = 0b00000000000100u32; + pub static flag_sign_always : u32 = 0b00000000001000u32; + pub static flag_alternate : u32 = 0b00000000010000u32; pub enum Count { CountIs(uint), CountImplied, } @@ -501,7 +501,7 @@ pub mod rt { ty: Ty, } - pub pure fn conv_int(cv: Conv, i: int, buf: &mut ~str) { + pub fn conv_int(cv: Conv, i: int, buf: &mut ~str) { let radix = 10; let prec = get_int_precision(cv); let mut s : ~str = uint_to_str_prec(int::abs(i) as uint, radix, prec); @@ -517,7 +517,7 @@ pub mod rt { } else { Some('-') }; unsafe { pad(cv, s, head, PadSigned, buf) }; } - pub pure fn conv_uint(cv: Conv, u: uint, buf: &mut ~str) { + pub fn conv_uint(cv: Conv, u: uint, buf: &mut ~str) { let prec = get_int_precision(cv); let mut rs = match cv.ty { @@ -529,16 +529,16 @@ pub mod rt { }; unsafe { pad(cv, rs, None, PadUnsigned, buf) }; } - pub pure fn conv_bool(cv: Conv, b: bool, buf: &mut ~str) { + pub fn conv_bool(cv: Conv, b: bool, buf: &mut ~str) { let s = if b { "true" } else { "false" }; // run the boolean conversion through the string conversion logic, // giving it the same rules for precision, etc. conv_str(cv, s, buf); } - pub pure fn conv_char(cv: Conv, c: char, buf: &mut ~str) { + pub fn conv_char(cv: Conv, c: char, buf: &mut ~str) { unsafe { pad(cv, "", Some(c), PadNozero, buf) }; } - pub pure fn conv_str(cv: Conv, s: &str, buf: &mut ~str) { + pub fn conv_str(cv: Conv, s: &str, buf: &mut ~str) { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -551,7 +551,7 @@ pub mod rt { }; unsafe { pad(cv, unpadded, None, PadNozero, buf) }; } - pub pure fn conv_float(cv: Conv, f: float, buf: &mut ~str) { + pub fn conv_float(cv: Conv, f: float, buf: &mut ~str) { let (to_str, digits) = match cv.precision { CountIs(c) => (float::to_str_exact, c as uint), CountImplied => (float::to_str_digits, 6u) @@ -568,7 +568,7 @@ pub mod rt { } else { None }; unsafe { pad(cv, s, head, PadFloat, buf) }; } - pub pure fn conv_poly(cv: Conv, v: &T, buf: &mut ~str) { + pub fn conv_poly(cv: Conv, v: &T, buf: &mut ~str) { let s = sys::log_str(v); conv_str(cv, s, buf); } @@ -576,8 +576,7 @@ pub mod rt { // Convert a uint to string with a minimum number of digits. If precision // is 0 and num is 0 then the result is the empty string. Could move this // to uint: but it doesn't seem all that useful. - pub pure fn uint_to_str_prec(num: uint, radix: uint, - prec: uint) -> ~str { + pub fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str { return if prec == 0u && num == 0u { ~"" } else { @@ -590,7 +589,7 @@ pub mod rt { } else { s } }; } - pub pure fn get_int_precision(cv: Conv) -> uint { + pub fn get_int_precision(cv: Conv) -> uint { return match cv.precision { CountIs(c) => c as uint, CountImplied => 1u @@ -637,7 +636,7 @@ pub mod rt { PadFloat => (true, true), PadUnsigned => (true, false) }; - pure fn have_precision(cv: Conv) -> bool { + fn have_precision(cv: Conv) -> bool { return match cv.precision { CountImplied => false, _ => true }; } let zero_padding = { @@ -672,7 +671,7 @@ pub mod rt { buf.push_str(s); } #[inline(always)] - pub pure fn have_flag(flags: u32, f: u32) -> bool { + pub fn have_flag(flags: u32, f: u32) -> bool { flags & f != 0 } } From fd6c4cb554f86eaac4bf93010ccf073e569c70fa Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 17:58:50 -0700 Subject: [PATCH 09/10] libcore: Change `[const T]` to `const [T]` everywhere --- src/libcore/at_vec.rs | 22 ++++----- src/libcore/flate.rs | 4 +- src/libcore/hash.rs | 6 +-- src/libcore/io.rs | 18 ++++---- src/libcore/str.rs | 6 +-- src/libcore/to_bytes.rs | 2 +- src/libcore/vec.rs | 46 +++++++++---------- src/libstd/arena.rs | 2 +- src/libstd/net_tcp.rs | 2 +- src/libstd/sha1.rs | 6 +-- src/libstd/sort.rs | 29 +++++++----- src/test/bench/shootout-mandelbrot.rs | 2 +- src/test/bench/shootout-spectralnorm.rs | 6 +-- src/test/compile-fail/issue-2150.rs | 2 +- .../compile-fail/mutable-huh-vec-assign.rs | 20 -------- .../tag-that-dare-not-speak-its-name.rs | 2 +- src/test/compile-fail/vec-add.rs | 44 +----------------- src/test/compile-fail/vec-concat-bug.rs | 23 ---------- .../run-pass/coerce-reborrow-imm-vec-arg.rs | 2 +- .../run-pass/coerce-reborrow-imm-vec-rcvr.rs | 2 +- src/test/run-pass/impl-variance.rs | 26 ----------- src/test/run-pass/maybe-mutable.rs | 26 ----------- .../run-pass/mutable-huh-variance-vec1.rs | 23 ---------- .../run-pass/mutable-huh-variance-vec2.rs | 23 ---------- 24 files changed, 85 insertions(+), 259 deletions(-) delete mode 100644 src/test/compile-fail/mutable-huh-vec-assign.rs delete mode 100644 src/test/compile-fail/vec-concat-bug.rs delete mode 100644 src/test/run-pass/impl-variance.rs delete mode 100644 src/test/run-pass/maybe-mutable.rs delete mode 100644 src/test/run-pass/mutable-huh-variance-vec1.rs delete mode 100644 src/test/run-pass/mutable-huh-variance-vec2.rs diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index dbc132899d90e..9a8645723a42f 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -38,7 +38,7 @@ pub mod rustrt { /// Returns the number of elements the vector can hold without reallocating #[inline(always)] -pub fn capacity(v: @[const T]) -> uint { +pub fn capacity(v: @[T]) -> uint { unsafe { let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(&v)); @@ -60,7 +60,7 @@ pub fn capacity(v: @[const T]) -> uint { */ #[inline(always)] pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] { - let mut vec: @[const A] = @[]; + let mut vec: @[A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, x) }); return unsafe { transmute(vec) }; @@ -102,7 +102,7 @@ pub fn build_sized_opt(size: Option, // Appending #[inline(always)] -pub fn append(lhs: @[T], rhs: &[const T]) -> @[T] { +pub fn append(lhs: @[T], rhs: &const [T]) -> @[T] { do build_sized(lhs.len() + rhs.len()) |push| { for vec::each(lhs) |x| { push(*x); } for uint::range(0, rhs.len()) |i| { push(rhs[i]); } @@ -174,9 +174,9 @@ pub mod traits { use kinds::Copy; use ops::Add; - impl Add<&'self [const T],@[T]> for @[T] { + impl Add<&'self const [T],@[T]> for @[T] { #[inline(always)] - fn add(&self, rhs: & &'self [const T]) -> @[T] { + fn add(&self, rhs: & &'self const [T]) -> @[T] { append(*self, (*rhs)) } } @@ -207,13 +207,13 @@ pub mod raw { * the vector is actually the specified size. */ #[inline(always)] - pub unsafe fn set_len(v: @[const T], new_len: uint) { + pub unsafe fn set_len(v: @[T], new_len: uint) { let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(&v)); (**repr).unboxed.fill = new_len * sys::size_of::(); } #[inline(always)] - pub unsafe fn push(v: &mut @[const T], initval: T) { + pub unsafe fn push(v: &mut @[T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; if (**repr).unboxed.alloc > fill { @@ -225,7 +225,7 @@ pub mod raw { } #[inline(always)] // really pretty please - pub unsafe fn push_fast(v: &mut @[const T], initval: T) { + pub unsafe fn push_fast(v: &mut @[T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); @@ -234,7 +234,7 @@ pub mod raw { move_val_init(&mut(*p), initval); } - pub unsafe fn push_slow(v: &mut @[const T], initval: T) { + pub unsafe fn push_slow(v: &mut @[T], initval: T) { reserve_at_least(&mut *v, v.len() + 1u); push_fast(v, initval); } @@ -250,7 +250,7 @@ pub mod raw { * * v - A vector * * n - The number of elements to reserve space for */ - pub unsafe fn reserve(v: &mut @[const T], n: uint) { + pub unsafe fn reserve(v: &mut @[T], n: uint) { // Only make the (slow) call into the runtime if we have to if capacity(*v) < n { let ptr: **VecRepr = transmute(v); @@ -274,7 +274,7 @@ pub mod raw { * * v - A vector * * n - The number of elements to reserve space for */ - pub unsafe fn reserve_at_least(v: &mut @[const T], n: uint) { + pub unsafe fn reserve_at_least(v: &mut @[T], n: uint) { reserve(v, uint::next_power_of_two(n)); } diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index d9dc89097d03d..b9ba300472950 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -46,7 +46,7 @@ static lz_fast : c_int = 0x1; // LZ with only one probe static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal" static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best" -pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] { +pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] { do vec::as_const_buf(bytes) |b, len| { unsafe { let mut outsz : size_t = 0; @@ -64,7 +64,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] { } } -pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] { +pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] { do vec::as_const_buf(bytes) |b, len| { unsafe { let mut outsz : size_t = 0; diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 1bfa0e9522ddd..c1e9e658df0c7 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -65,7 +65,7 @@ impl HashUtil for A { /// Streaming hash-functions should implement this. pub trait Streaming { - fn input(&self, (&[const u8])); + fn input(&self, (&const [u8])); // These can be refactored some when we have default methods. fn result_bytes(&self) -> ~[u8]; fn result_str(&self) -> ~str; @@ -221,7 +221,7 @@ impl io::Writer for SipState { // Methods for io::writer #[inline(always)] - fn write(&self, msg: &[const u8]) { + fn write(&self, msg: &const [u8]) { let length = msg.len(); self.length += length; @@ -299,7 +299,7 @@ impl io::Writer for SipState { impl Streaming for SipState { #[inline(always)] - fn input(&self, buf: &[const u8]) { + fn input(&self, buf: &const [u8]) { self.write(buf); } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index fb305560ba333..2b66fdb38ab11 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -667,7 +667,7 @@ pub enum WriterType { Screen, File } pub trait Writer { /// Write all of the given bytes. - fn write(&self, v: &[const u8]); + fn write(&self, v: &const [u8]); /// Move the current position within the stream. The second parameter /// determines the position that the first parameter is relative to. @@ -684,7 +684,7 @@ pub trait Writer { } impl Writer for @Writer { - fn write(&self, v: &[const u8]) { self.write(v) } + fn write(&self, v: &const [u8]) { self.write(v) } fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) } fn tell(&self) -> uint { self.tell() } fn flush(&self) -> int { self.flush() } @@ -692,7 +692,7 @@ impl Writer for @Writer { } impl Writer for Wrapper { - fn write(&self, bs: &[const u8]) { self.base.write(bs); } + fn write(&self, bs: &const [u8]) { self.base.write(bs); } fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); } fn tell(&self) -> uint { self.base.tell() } fn flush(&self) -> int { self.base.flush() } @@ -700,7 +700,7 @@ impl Writer for Wrapper { } impl Writer for *libc::FILE { - fn write(&self, v: &[const u8]) { + fn write(&self, v: &const [u8]) { unsafe { do vec::as_const_buf(v) |vbuf, len| { let nout = libc::fwrite(vbuf as *c_void, @@ -750,7 +750,7 @@ pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer { } impl Writer for fd_t { - fn write(&self, v: &[const u8]) { + fn write(&self, v: &const [u8]) { unsafe { let mut count = 0u; do vec::as_const_buf(v) |vbuf, len| { @@ -907,8 +907,10 @@ pub fn u64_to_be_bytes(n: u64, size: uint, } } -pub fn u64_from_be_bytes(data: &[const u8], - start: uint, size: uint) -> u64 { +pub fn u64_from_be_bytes(data: &const [u8], + start: uint, + size: uint) + -> u64 { let mut sz = size; fail_unless!((sz <= 8u)); let mut val = 0_u64; @@ -1140,7 +1142,7 @@ pub struct BytesWriter { } impl Writer for BytesWriter { - fn write(&self, v: &[const u8]) { + fn write(&self, v: &const [u8]) { let v_len = v.len(); let bytes_len = vec::uniq_len(&const self.bytes); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index f26d9ee349264..67bd99da5d65b 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -44,7 +44,7 @@ Section: Creating a string * * Fails if invalid UTF-8 */ -pub fn from_bytes(vv: &[const u8]) -> ~str { +pub fn from_bytes(vv: &const [u8]) -> ~str { fail_unless!(is_utf8(vv)); return unsafe { raw::from_bytes(vv) }; } @@ -1574,7 +1574,7 @@ Section: Misc */ /// Determines if a vector of bytes contains valid UTF-8 -pub fn is_utf8(v: &[const u8]) -> bool { +pub fn is_utf8(v: &const [u8]) -> bool { let mut i = 0u; let total = vec::len::(v); while i < total { @@ -2131,7 +2131,7 @@ pub mod raw { } /// Converts a vector of bytes to a string. - pub unsafe fn from_bytes(v: &[const u8]) -> ~str { + pub unsafe fn from_bytes(v: &const [u8]) -> ~str { do vec::as_const_buf(v) |buf, len| { from_buf_len(buf, len) } diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index f379878c8eb0b..32b123979cd5a 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -19,7 +19,7 @@ use io::Writer; use option::{None, Option, Some}; use str; -pub type Cb = &'self fn(buf: &[const u8]) -> bool; +pub type Cb = &'self fn(buf: &const [u8]) -> bool; /** * A trait to implement in order to make a type hashable; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 56d547874d8de..ed80cda0c1be2 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -47,12 +47,12 @@ pub mod rustrt { } /// Returns true if a vector contains no elements -pub fn is_empty(v: &[const T]) -> bool { +pub fn is_empty(v: &const [T]) -> bool { as_const_buf(v, |_p, len| len == 0u) } /// Returns true if two vectors have the same length -pub fn same_length(xs: &[const T], ys: &[const U]) -> bool { +pub fn same_length(xs: &const [T], ys: &const [U]) -> bool { xs.len() == ys.len() } @@ -114,7 +114,7 @@ pub fn capacity(v: &const ~[T]) -> uint { /// Returns the length of a vector #[inline(always)] -pub fn len(v: &[const T]) -> uint { +pub fn len(v: &const [T]) -> uint { as_const_buf(v, |_p, len| len) } @@ -292,8 +292,8 @@ pub fn mut_slice(v: &'r mut [T], start: uint, end: uint) -> &'r mut [T] { /// Return a slice that points into another slice. #[inline(always)] -pub fn const_slice(v: &'r [const T], start: uint, end: uint) - -> &'r [const T] { +pub fn const_slice(v: &'r const [T], start: uint, end: uint) + -> &'r const [T] { fail_unless!(start <= end); fail_unless!(end <= len(v)); do as_const_buf(v) |p, _len| { @@ -624,7 +624,7 @@ fn push_slow(v: &mut ~[T], initval: T) { } #[inline(always)] -pub fn push_all(v: &mut ~[T], rhs: &[const T]) { +pub fn push_all(v: &mut ~[T], rhs: &const [T]) { let new_len = v.len() + rhs.len(); reserve(&mut *v, new_len); @@ -708,7 +708,7 @@ pub fn dedup(v: &mut ~[T]) { // Appending #[inline(always)] -pub fn append(lhs: ~[T], rhs: &[const T]) -> ~[T] { +pub fn append(lhs: ~[T], rhs: &const [T]) -> ~[T] { let mut v = lhs; unsafe { v.push_all(rhs); @@ -1242,7 +1242,7 @@ pub fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { /** * Convert two vectors to a vector of pairs, by reference. As zip(). */ -pub fn zip_slice(v: &[const T], u: &[const U]) +pub fn zip_slice(v: &const [T], u: &const [U]) -> ~[(T, U)] { let mut zipped = ~[]; let sz = len(v); @@ -1293,7 +1293,7 @@ pub fn reverse(v: &mut [T]) { } /// Returns a vector with the order of elements reversed -pub fn reversed(v: &[const T]) -> ~[T] { +pub fn reversed(v: &const [T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::(v); if i == 0 { return (rs); } else { i -= 1; } @@ -1345,7 +1345,7 @@ pub fn reversed(v: &[const T]) -> ~[T] { #[inline(always)] pub fn each(v: &'r [T], f: &fn(&'r T) -> bool) { // ^^^^ - // NB---this CANNOT be &[const T]! The reason + // NB---this CANNOT be &const [T]! The reason // is that you are passing it to `f()` using // an immutable. @@ -1381,7 +1381,7 @@ pub fn each_mut(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) { /// Like `each()`, but for the case where you have a vector that *may or may /// not* have mutable contents. #[inline(always)] -pub fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { +pub fn each_const(v: &const [T], f: &fn(elem: &const T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1508,7 +1508,7 @@ pub fn as_imm_buf(s: &[T], /* NB---this CANNOT be const, see below */ f: &fn(*T, uint) -> U) -> U { - // NB---Do not change the type of s to `&[const T]`. This is + // NB---Do not change the type of s to `&const [T]`. This is // unsound. The reason is that we are going to create immutable pointers // into `s` and pass them to `f()`, but in fact they are potentially // pointing at *mutable memory*. Use `as_const_buf` or `as_mut_buf` @@ -1524,7 +1524,7 @@ pub fn as_imm_buf(s: &[T], /// Similar to `as_imm_buf` but passing a `*const T` #[inline(always)] -pub fn as_const_buf(s: &[const T], f: &fn(*const T, uint) -> U) -> U { +pub fn as_const_buf(s: &const [T], f: &fn(*const T, uint) -> U) -> U { unsafe { let v : *(*const T,uint) = ::cast::reinterpret_cast(&addr_of(&s)); @@ -1685,15 +1685,15 @@ pub mod traits { use ops::Add; use vec::append; - impl Add<&'self [const T],~[T]> for ~[T] { + impl Add<&'self const [T],~[T]> for ~[T] { #[inline(always)] - fn add(&self, rhs: & &'self [const T]) -> ~[T] { + fn add(&self, rhs: & &'self const [T]) -> ~[T] { append(copy *self, (*rhs)) } } } -impl Container for &'self [const T] { +impl Container for &'self const [T] { /// Returns true if a vector contains no elements #[inline] fn is_empty(&const self) -> bool { is_empty(*self) } @@ -1708,7 +1708,7 @@ pub trait CopyableVector { } /// Extension methods for vectors -impl CopyableVector for &'self [const T] { +impl CopyableVector for &'self const [T] { /// Returns a copy of `v`. #[inline] fn to_owned(&self) -> ~[T] { @@ -2041,14 +2041,14 @@ impl Mutable for ~[T] { } pub trait OwnedCopyableVector { - fn push_all(&mut self, rhs: &[const T]); + fn push_all(&mut self, rhs: &const [T]); fn grow(&mut self, n: uint, initval: &T); fn grow_set(&mut self, index: uint, initval: &T, val: T); } impl OwnedCopyableVector for ~[T] { #[inline] - fn push_all(&mut self, rhs: &[const T]) { + fn push_all(&mut self, rhs: &const [T]) { push_all(self, rhs); } @@ -2146,7 +2146,7 @@ pub mod raw { /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_const_ptr(v: &[const T]) -> *const T { + pub unsafe fn to_const_ptr(v: &const [T]) -> *const T { let repr: **SliceRepr = ::cast::transmute(&v); ::cast::reinterpret_cast(&addr_of(&((**repr).data))) } @@ -2190,7 +2190,7 @@ pub mod raw { * Unchecked vector indexing. */ #[inline(always)] - pub unsafe fn get(v: &[const T], i: uint) -> T { + pub unsafe fn get(v: &const [T], i: uint) -> T { as_const_buf(v, |p, _len| *ptr::const_offset(p, i)) } @@ -2234,7 +2234,7 @@ pub mod raw { * may overlap. */ #[inline(always)] - pub unsafe fn copy_memory(dst: &mut [T], src: &[const T], + pub unsafe fn copy_memory(dst: &mut [T], src: &const [T], count: uint) { fail_unless!(dst.len() >= count); fail_unless!(src.len() >= count); @@ -2300,7 +2300,7 @@ pub mod bytes { * may overlap. */ #[inline(always)] - pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) { + pub fn copy_memory(dst: &mut [u8], src: &const [u8], count: uint) { // Bound checks are done at vec::raw::copy_memory. unsafe { vec::raw::copy_memory(dst, src, count) } } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index a26132d92ca01..683e4a629756f 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -101,7 +101,7 @@ impl Drop for Arena { } fn chunk(size: uint, is_pod: bool) -> Chunk { - let mut v: @[const u8] = @[]; + let mut v: @[u8] = @[]; unsafe { at_vec::raw::reserve(&mut v, size); } Chunk { data: unsafe { cast::transmute(v) }, diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index c49f65d0f99b8..c1743c98c9bf1 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -972,7 +972,7 @@ impl io::Reader for TcpSocketBuf { /// Implementation of `io::Reader` trait for a buffered `net::tcp::TcpSocket` impl io::Writer for TcpSocketBuf { - pub fn write(&self, data: &[const u8]) { + pub fn write(&self, data: &const [u8]) { unsafe { let socket_data_ptr = ptr::addr_of(&(*((*(self.data)).sock).socket_data)); diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 64399defd54f7..b603e2eb1cc66 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -35,7 +35,7 @@ use core::vec; /// The SHA-1 interface trait Sha1 { /// Provide message input as bytes - fn input(&mut self, &[const u8]); + fn input(&mut self, &const [u8]); /// Provide message input as string fn input_str(&mut self, &str); /** @@ -73,7 +73,7 @@ pub fn sha1() -> @Sha1 { computed: bool, work_buf: @mut ~[u32]}; - fn add_input(st: &mut Sha1State, msg: &[const u8]) { + fn add_input(st: &mut Sha1State, msg: &const [u8]) { fail_unless!((!st.computed)); for vec::each_const(msg) |element| { st.msg_block[st.msg_block_idx] = *element; @@ -241,7 +241,7 @@ pub fn sha1() -> @Sha1 { self.h[4] = 0xC3D2E1F0u32; self.computed = false; } - fn input(&mut self, msg: &[const u8]) { add_input(self, msg); } + fn input(&mut self, msg: &const [u8]) { add_input(self, msg); } fn input_str(&mut self, msg: &str) { let bs = str::to_bytes(msg); add_input(self, bs); diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 1dc990526f0b6..7e528f96ca72b 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -24,12 +24,12 @@ type Le = &'self fn(v1: &T, v2: &T) -> bool; * Has worst case O(n log n) performance, best case O(n), but * is not space efficient. This is a stable sort. */ -pub fn merge_sort(v: &[const T], le: Le) -> ~[T] { +pub fn merge_sort(v: &const [T], le: Le) -> ~[T] { type Slice = (uint, uint); unsafe {return merge_sort_(v, (0u, len(v)), le);} - fn merge_sort_(v: &[const T], slice: Slice, le: Le) + fn merge_sort_(v: &const [T], slice: Slice, le: Le) -> ~[T] { let begin = slice.first(); let end = slice.second(); @@ -290,8 +290,10 @@ fn count_run_ascending(array: &mut [T]) -> uint { return run; } -fn gallop_left(key: &const T, array: &[const T], - hint: uint) -> uint { +fn gallop_left(key: &const T, + array: &const [T], + hint: uint) + -> uint { let size = array.len(); fail_unless!(size != 0 && hint < size); @@ -339,8 +341,10 @@ fn gallop_left(key: &const T, array: &[const T], return ofs; } -fn gallop_right(key: &const T, array: &[const T], - hint: uint) -> uint { +fn gallop_right(key: &const T, + array: &const [T], + hint: uint) + -> uint { let size = array.len(); fail_unless!(size != 0 && hint < size); @@ -709,8 +713,11 @@ impl MergeState { } #[inline(always)] -fn copy_vec(dest: &mut [T], s1: uint, - from: &[const T], s2: uint, len: uint) { +fn copy_vec(dest: &mut [T], + s1: uint, + from: &const [T], + s2: uint, + len: uint) { fail_unless!(s1+len <= dest.len() && s2+len <= from.len()); let mut slice = ~[]; @@ -1026,7 +1033,7 @@ mod big_tests { tabulate_managed(low, high); } - fn multiplyVec(arr: &[const T], num: uint) -> ~[T] { + fn multiplyVec(arr: &const [T], num: uint) -> ~[T] { let size = arr.len(); let res = do vec::from_fn(num) |i| { arr[i % size] @@ -1042,7 +1049,7 @@ mod big_tests { } fn tabulate_unique(lo: uint, hi: uint) { - fn isSorted(arr: &[const T]) { + fn isSorted(arr: &const [T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { fail!(~"Array not sorted"); @@ -1114,7 +1121,7 @@ mod big_tests { } fn tabulate_managed(lo: uint, hi: uint) { - fn isSorted(arr: &[const @T]) { + fn isSorted(arr: &const [@T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { fail!(~"Array not sorted"); diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index ada5ff7be2fa8..1764ef48412cc 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -101,7 +101,7 @@ fn chanmb(i: uint, size: uint, depth: uint) -> Line struct Devnull(); impl io::Writer for Devnull { - fn write(&self, _b: &[const u8]) {} + fn write(&self, _b: &const [u8]) {} fn seek(&self, _i: int, _s: io::SeekStyle) {} fn tell(&self) -> uint {0_u} fn flush(&self) -> int {0} diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 2b9a030fdf4ce..6e39b755b22af 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -16,7 +16,7 @@ fn eval_A(i: uint, j: uint) -> float { 1.0/(((i+j)*(i+j+1u)/2u+i+1u) as float) } -fn eval_A_times_u(u: &[const float], Au: &mut [float]) { +fn eval_A_times_u(u: &const [float], Au: &mut [float]) { let N = vec::len(u); let mut i = 0u; while i < N { @@ -30,7 +30,7 @@ fn eval_A_times_u(u: &[const float], Au: &mut [float]) { } } -fn eval_At_times_u(u: &[const float], Au: &mut [float]) { +fn eval_At_times_u(u: &const [float], Au: &mut [float]) { let N = vec::len(u); let mut i = 0u; while i < N { @@ -44,7 +44,7 @@ fn eval_At_times_u(u: &[const float], Au: &mut [float]) { } } -fn eval_AtA_times_u(u: &[const float], AtAu: &mut [float]) { +fn eval_AtA_times_u(u: &const [float], AtAu: &mut [float]) { let mut v = vec::from_elem(vec::len(u), 0.0); eval_A_times_u(u, v); eval_At_times_u(v, AtAu); diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 3ab8f765ad545..9f2f9a855ed52 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn fail_len(v: ~[const int]) -> uint { +fn fail_len(v: ~[int]) -> uint { let mut i = fail!(); for v.each |x| { i += 1u; } //~^ WARNING unreachable statement diff --git a/src/test/compile-fail/mutable-huh-vec-assign.rs b/src/test/compile-fail/mutable-huh-vec-assign.rs deleted file mode 100644 index 83cfd2403563a..0000000000000 --- a/src/test/compile-fail/mutable-huh-vec-assign.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - fn f(&&v: ~[const int]) { - // This shouldn't be possible - v[0] = 1 //~ ERROR assigning to const vec content - } - - let v = ~[0]; - - f(v); -} diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index a05d6a324de7b..af99c0e5f2953 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -15,7 +15,7 @@ extern mod core; -fn last(v: ~[const &T]) -> core::Option { +fn last(v: ~[&T]) -> core::Option { fail!(); } diff --git a/src/test/compile-fail/vec-add.rs b/src/test/compile-fail/vec-add.rs index 0f51d34fc2ff2..f30a050211ec6 100644 --- a/src/test/compile-fail/vec-add.rs +++ b/src/test/compile-fail/vec-add.rs @@ -14,7 +14,7 @@ // the right hand side in all cases. We are getting compiler errors // about this now, so I'm xfailing the test for now. -eholk -fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { +fn add(i: ~[int], mut m: ~[int]) { // Check that: // (1) vectors of any two mutabilities can be added @@ -36,10 +36,6 @@ fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { m + m, m); - add(i + c, - m + c, - c); - add(m + ~[3], //~ ERROR mismatched types m + ~[3], m + ~[3]); @@ -48,12 +44,6 @@ fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { i + ~[3], //~ ERROR mismatched types i + ~[3]); - add(c + ~[3], //~ ERROR mismatched types - //~^ ERROR binary operation + cannot be applied - c + ~[3], //~ ERROR binary operation + cannot be applied - //~^ mismatched types - ~[3]); - add(m + ~[3], //~ ERROR mismatched types m + ~[3], m + ~[3]); @@ -62,12 +52,6 @@ fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { i + ~[3], //~ ERROR mismatched types i + ~[3]); - add(c + ~[3], //~ ERROR binary operation + cannot be applied - //~^ mismatched types - c + ~[3], //~ ERROR binary operation + cannot be applied - //~^ mismatched types - ~[3]); - add(m + i, //~ ERROR mismatched types m + i, m + i); @@ -76,12 +60,6 @@ fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { i + i, //~ ERROR mismatched types i + i); - add(c + i, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - c + i, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - i); - add(m + m, //~ ERROR mismatched types m + m, m + m); @@ -89,26 +67,6 @@ fn add(i: ~[int], mut m: ~[int], c: ~[const int]) { add(i + m, i + m, //~ ERROR mismatched types i + m); - - add(c + m, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - c + m, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - m); - - add(m + c, //~ ERROR mismatched types - m + c, - m + c); - - add(i + c, - i + c, //~ ERROR mismatched types - i + c); - - add(c + c, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - c + c, //~ ERROR binary operation + cannot be applied - //~^ ERROR mismatched types - c); } fn main() { diff --git a/src/test/compile-fail/vec-concat-bug.rs b/src/test/compile-fail/vec-concat-bug.rs deleted file mode 100644 index 478e01ccd042e..0000000000000 --- a/src/test/compile-fail/vec-concat-bug.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn concat(v: ~[const ~[const T]]) -> ~[T] { - let mut r = ~[]; - - // Earlier versions of our type checker accepted this: - vec::each(v, |inner: &~[T]| { - //~^ ERROR values differ in mutability - r += *inner; true - }); - - return r; -} - -fn main() {} diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs index ad5eb50ccef30..3f12c0d635311 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs @@ -14,7 +14,7 @@ fn sum_imm(y: &[int]) -> int { sum(y) } -fn sum_const(y: &[const int]) -> int { +fn sum_const(y: &const [int]) -> int { sum(y) } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index bf86472d900d7..7dcf49ef1ac44 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -1,6 +1,6 @@ // xfail-test -fn foo(v: &[const uint]) -> ~[uint] { +fn foo(v: &const [uint]) -> ~[uint] { v.to_vec() } diff --git a/src/test/run-pass/impl-variance.rs b/src/test/run-pass/impl-variance.rs deleted file mode 100644 index 31375edb5de04..0000000000000 --- a/src/test/run-pass/impl-variance.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait foo { - fn foo(&self) -> uint; -} - -impl foo for ~[const T] { - fn foo(&self) -> uint { vec::len(*self) } -} - -pub fn main() { - let v = ~[const 0]; - fail_unless!(v.foo() == 1u); - let v = ~[0]; - fail_unless!(v.foo() == 1u); - let mut v = ~[0]; - fail_unless!(v.foo() == 1u); -} diff --git a/src/test/run-pass/maybe-mutable.rs b/src/test/run-pass/maybe-mutable.rs deleted file mode 100644 index 155046bccccc6..0000000000000 --- a/src/test/run-pass/maybe-mutable.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - - -// -*- rust -*- -fn len(v: ~[const int]) -> uint { - let mut i = 0u; - while i < vec::len(v) { i += 1u; } - return i; -} - -pub fn main() { - let v0 = ~[1, 2, 3, 4, 5]; - debug!(len(v0)); - let mut v1 = ~[1, 2, 3, 4, 5]; - debug!(len(v1)); -} diff --git a/src/test/run-pass/mutable-huh-variance-vec1.rs b/src/test/run-pass/mutable-huh-variance-vec1.rs deleted file mode 100644 index 8db2705de2b4e..0000000000000 --- a/src/test/run-pass/mutable-huh-variance-vec1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -pub fn main() { - let v = ~[~[0]]; - - // This is ok because the outer vec is covariant with respect - // to the inner vec. If the outer vec was mut then we - // couldn't do this. - fn f(&&v: ~[~[const int]]) { - } - - f(v); -} diff --git a/src/test/run-pass/mutable-huh-variance-vec2.rs b/src/test/run-pass/mutable-huh-variance-vec2.rs deleted file mode 100644 index 7c48744000d4f..0000000000000 --- a/src/test/run-pass/mutable-huh-variance-vec2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -pub fn main() { - let v = ~[~[0]]; - - // This is ok because the outer vec is covariant with respect - // to the inner vec. If the outer vec was mut then we - // couldn't do this. - fn f(&&v: ~[const ~[const int]]) { - } - - f(v); -} From 975a7160ff4ba4a2b660d095e35bff29e4a73c5a Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Mar 2013 18:24:37 -0700 Subject: [PATCH 10/10] libsyntax: Stop parsing `[const T]`. --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index af64bf07b7c3e..63c5d833e7823 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1176,7 +1176,7 @@ pub impl Parser { } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); - if mutbl == m_mutbl { // `m_const` too after snapshot + if mutbl == m_mutbl || mutbl == m_const { self.obsolete(*self.last_span, ObsoleteMutVector); }