From 4af7ebcd8f72356880abccc411a1632e8f07e1c1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 28 Jun 2013 14:33:58 -0700 Subject: [PATCH 1/8] Rename #[non_sendable] to #[no_send] --- src/libextra/rc.rs | 4 ++-- src/librustc/middle/ty.rs | 4 ++-- src/test/compile-fail/non_owned-enum.rs | 2 +- src/test/compile-fail/non_owned-struct.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 009d68ac02601..31fed541bb123 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -36,7 +36,7 @@ struct RcBox { /// Immutable reference counted pointer type #[unsafe_no_drop_flag] -#[non_sendable] +#[no_send] pub struct Rc { priv ptr: *mut RcBox, } @@ -168,7 +168,7 @@ struct RcMutBox { /// Mutable reference counted pointer type #[non_owned] -#[non_sendable] +#[no_send] #[mutable] #[unsafe_no_drop_flag] pub struct RcMut { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 175529be20629..03a73c847ee6e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1969,7 +1969,7 @@ static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits: 0b0001_0000_0000}; /// An enum with no variants. static TC_EMPTY_ENUM: TypeContents = TypeContents{bits: 0b0010_0000_0000}; -/// Contains a type marked with `#[non_sendable]` +/// Contains a type marked with `#[no_send]` static TC_NON_SENDABLE: TypeContents = TypeContents{bits: 0b0100_0000_0000}; /// Is a bare vector, str, function, trait, etc (only relevant at top level). @@ -2207,7 +2207,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { if has_attr(cx, did, "mutable") { tc = tc + TC_MUTABLE; } - if has_attr(cx, did, "non_sendable") { + if has_attr(cx, did, "no_send") { tc = tc + TC_NON_SENDABLE; } tc diff --git a/src/test/compile-fail/non_owned-enum.rs b/src/test/compile-fail/non_owned-enum.rs index 20b571ad61410..b436bfb8b0fdb 100644 --- a/src/test/compile-fail/non_owned-enum.rs +++ b/src/test/compile-fail/non_owned-enum.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[non_sendable] +#[no_send] enum Foo { A } fn bar(_: T) {} diff --git a/src/test/compile-fail/non_owned-struct.rs b/src/test/compile-fail/non_owned-struct.rs index d4b8e6755a126..542c3aa212bb9 100644 --- a/src/test/compile-fail/non_owned-struct.rs +++ b/src/test/compile-fail/non_owned-struct.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[non_sendable] +#[no_send] struct Foo { a: int } fn bar(_: T) {} From 22b7eb38024afc38dbcfaa18796371b7d6b5b1d0 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 28 Jun 2013 14:36:33 -0700 Subject: [PATCH 2/8] Rename #[mutable] to #[no_freeze] --- src/libextra/arc.rs | 3 ++- src/libextra/arena.rs | 3 ++- src/libextra/rc.rs | 3 ++- src/librustc/middle/ty.rs | 2 +- src/libstd/cell.rs | 3 ++- src/test/compile-fail/mutable-enum.rs | 2 +- src/test/compile-fail/mutable-struct.rs | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 2fb03fecb5988..30067c92300cc 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -276,7 +276,8 @@ struct RWARCInner { lock: RWlock, failed: bool, data: T } * * Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested. */ -#[mutable] +#[mutable] // XXX remove after snap +#[no_freeze] struct RWARC { x: UnsafeAtomicRcBox>, } diff --git a/src/libextra/arena.rs b/src/libextra/arena.rs index 2f18b0562e0fe..2c6e7a30448ce 100644 --- a/src/libextra/arena.rs +++ b/src/libextra/arena.rs @@ -65,7 +65,8 @@ struct Chunk { is_pod: bool, } -#[mutable] +#[mutable] // XXX remove after snap +#[no_freeze] pub struct Arena { // The head is separated out from the list as a unbenchmarked // microoptimization, to avoid needing to case on the list to diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 31fed541bb123..613c0b1ae417f 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -169,7 +169,8 @@ struct RcMutBox { /// Mutable reference counted pointer type #[non_owned] #[no_send] -#[mutable] +#[mutable] // XXX remove after snap +#[no_freeze] #[unsafe_no_drop_flag] pub struct RcMut { priv ptr: *mut RcMutBox, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 03a73c847ee6e..f1172fb1da65f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2204,7 +2204,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } fn apply_tc_attr(cx: ctxt, did: def_id, mut tc: TypeContents) -> TypeContents { - if has_attr(cx, did, "mutable") { + if has_attr(cx, did, "no_freeze") { tc = tc + TC_MUTABLE; } if has_attr(cx, did, "no_send") { diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index e1d2b246dd370..53ea11f2b0592 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -22,7 +22,8 @@ A dynamic, mutable location. Similar to a mutable option type, but friendlier. */ -#[mutable] +#[mutable] // XXX remove after snap +#[no_freeze] #[deriving(Clone, DeepClone, Eq)] #[allow(missing_doc)] pub struct Cell { diff --git a/src/test/compile-fail/mutable-enum.rs b/src/test/compile-fail/mutable-enum.rs index db2172b2e570f..35842a53a315b 100644 --- a/src/test/compile-fail/mutable-enum.rs +++ b/src/test/compile-fail/mutable-enum.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[mutable] +#[no_freeze] enum Foo { A } fn bar(_: T) {} diff --git a/src/test/compile-fail/mutable-struct.rs b/src/test/compile-fail/mutable-struct.rs index 8511bcdcd3501..6f29fcfd96d20 100644 --- a/src/test/compile-fail/mutable-struct.rs +++ b/src/test/compile-fail/mutable-struct.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[mutable] +#[no_freeze] struct Foo { a: int } fn bar(_: T) {} From 28a3613a1da0f73da52b9becc7c0d973abdf122e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 28 Jun 2013 20:09:22 -0400 Subject: [PATCH 3/8] fix zsh completion for lint and debug flags this correctly makes them accept 1 argument, and auto-completes the comma-separated list of lint flags --- src/etc/zsh/_rust | 71 ++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/etc/zsh/_rust b/src/etc/zsh/_rust index faa21a2961694..86dcbab93fde6 100644 --- a/src/etc/zsh/_rust +++ b/src/etc/zsh/_rust @@ -29,36 +29,30 @@ _rustc_opts_switches=( --target'[Target triple cpu-manufacturer-kernel\[-os\] to compile]' --target-feature'[Target specific attributes (llc -mattr=help for detail)]' --android-cross-path'[The path to the Android NDK]' - {-W,--warn}'[Set lint warnings]' - {-A,--allow}'[Set lint allowed]' - {-D,--deny}'[Set lint denied]' - {-F,--forbid}'[Set lint forbidden]' - -Z'[Set internal debugging options]' {-v,--version}'[Print version info and exit]' ) - _rustc_opts_lint=( - 'path-statement:path statements with no effect' - 'deprecated-pattern:warn about deprecated uses of pattern bindings' - 'non-implicitly-copyable-typarams:passing non implicitly copyable types as copy type params' - 'missing-trait-doc:detects missing documentation for traits' - 'missing-struct-doc:detects missing documentation for structs' - 'ctypes:proper use of core::libc types in foreign modules' - 'implicit-copies:implicit copies of non implicitly copyable data' - "unused-mut:detect mut variables which don't need to be mutable" - 'unused-imports:imports that are never used' - 'heap-memory:use of any (~ type or @ type) heap memory' - 'default-methods:allow default methods' - 'unused-variable:detect variables which are not used in any way' - 'dead-assignment:detect assignments that will never be read' - 'unrecognized-lint:unrecognized lint attribute' - 'type-limits:comparisons made useless by limits of the types involved' - 'unused-unsafe:unnecessary use of an `unsafe` block' - 'while-true:suggest using loop { } instead of while(true) { }' - 'non-camel-case-types:types, variants and traits should have camel case names' - 'managed-heap-memory:use of managed (@ type) heap memory' - 'unnecessary-allocation:detects unnecessary allocations that can be eliminated' - 'owned-heap-memory:use of owned (~ type) heap memory' + 'path-statement[path statements with no effect]' + 'deprecated-pattern[warn about deprecated uses of pattern bindings]' + 'non-implicitly-copyable-typarams[passing non implicitly copyable types as copy type params]' + 'missing-trait-doc[detects missing documentation for traits]' + 'missing-struct-doc[detects missing documentation for structs]' + 'ctypes[proper use of core::libc types in foreign modules]' + 'implicit-copies[implicit copies of non implicitly copyable data]' + "unused-mut[detect mut variables which don't need to be mutable]" + 'unused-imports[imports that are never used]' + 'heap-memory[use of any (~ type or @ type) heap memory]' + 'default-methods[allow default methods]' + 'unused-variable[detect variables which are not used in any way]' + 'dead-assignment[detect assignments that will never be read]' + 'unrecognized-lint[unrecognized lint attribute]' + 'type-limits[comparisons made useless by limits of the types involved]' + 'unused-unsafe[unnecessary use of an `unsafe` block]' + 'while-true[suggest using loop { } instead of while(true) { }]' + 'non-camel-case-types[types, variants and traits should have camel case names]' + 'managed-heap-memory[use of managed (@ type) heap memory]' + 'unnecessary-allocation[detects unnecessary allocations that can be eliminated]' + 'owned-heap-memory[use of owned (~ type) heap memory]' ) _rustc_opts_debug=( @@ -90,13 +84,20 @@ _rustc_opts_debug=( 'lint-llvm:Run the LLVM lint pass on the pre-optimization IR' ) -_rustc() { - case $words[2] in - -[WADF]) _describe 'options' _rustc_opts_lint ;; - -Z) _describe 'options' _rustc_opts_debug ;; - -) _arguments -s -w : "$_rustc_opts_switches[@]" ;; - *) _files -g "*.rs" ;; - esac +_rustc_opts_fun_lint(){ + _values -s , 'options' \ + "$_rustc_opts_lint[@]" +} + +_rustc_opts_fun_debug(){ + _describe 'options' _rustc_opts_debug } -_rustc "$@" +_arguments -s : \ + '(-W --warn)'{-W,--warn}'[Set lint warnings]:lint options:_rustc_opts_fun_lint' \ + '(-A --allow)'{-A,--allow}'[Set lint allowed]:lint options:_rustc_opts_fun_lint' \ + '(-D --deny)'{-D,--deny}'[Set lint denied]:lint options:_rustc_opts_fun_lint' \ + '(-F --forbid)'{-F,--forbid}'[Set lint forbidden]:lint options:_rustc_opts_fun_lint' \ + '*-Z[Set internal debugging options]:debug options:_rustc_opts_fun_debug' \ + "$_rustc_opts_switches[@]" \ + '*::files:_files -g "*.rs"' From a0c31ece9dba3665e0a44650ea492ae6f3e5604a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 28 Jun 2013 19:29:50 +0200 Subject: [PATCH 4/8] Remove unused variable --- src/librustpkg/path_util.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index c0425b4d26064..f0a3f24c307bd 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -40,7 +40,6 @@ static path_entry_separator: &'static str = ":"; /// DIR/.rust for any DIR that's the current working directory /// or an ancestor of it pub fn rust_path() -> ~[Path] { - let env_path: ~str = os::getenv("RUST_PATH").get_or_default(~""); let mut env_rust_path: ~[Path] = match os::getenv("RUST_PATH") { Some(env_path) => { let env_path_components: ~[&str] = From ee7307e6cb9e942fc1ef27109bfbc6fbf730ee3c Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Fri, 28 Jun 2013 20:29:04 -0700 Subject: [PATCH 5/8] Smarter warning in extra::term::Terminal.reset() Don't spew a warn!() in reset() if num_colors is 0, because non-color-supporting terminals are legit. Use debug!() there instead. Continue spewing warn!() if we believe the terminal to support colors. Use a better warning when the `op` capability can't be found. --- src/libextra/term.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libextra/term.rs b/src/libextra/term.rs index 880b89f2bbe17..d448a1588a674 100644 --- a/src/libextra/term.rs +++ b/src/libextra/term.rs @@ -120,13 +120,15 @@ impl Terminal { pub fn reset(&self) { let mut vars = Variables::new(); let s = do self.ti.strings.find_equiv(&("op")) - .map_consume_default(Err(~"can't find op")) |&op| { + .map_consume_default(Err(~"can't find terminfo capability `op`")) |&op| { expand(op, [], &mut vars) }; if s.is_ok() { self.out.write(s.unwrap()); - } else { + } else if self.num_colors > 0 { warn!("%s", s.unwrap_err()); + } else { + debug!("%s", s.unwrap_err()); } } From b9cf6a33d2b5c0006f780c01bcaae4047551eb75 Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Fri, 28 Jun 2013 13:52:37 +0200 Subject: [PATCH 6/8] iterator: UnfoldrIterator::new should have function argument last To match Rust conventions and enable use of `do` etc, make sure the closure is the last argument to the `new` method. --- src/libstd/iterator.rs | 4 ++-- src/test/run-pass/unfoldr-cross-crate.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 78940143f4e3d..765bf3b36f285 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -983,7 +983,7 @@ impl<'self, A, St> UnfoldrIterator<'self, A, St> { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the iterator #[inline] - pub fn new<'a>(f: &'a fn(&mut St) -> Option, initial_state: St) + pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option) -> UnfoldrIterator<'a, A, St> { UnfoldrIterator { f: f, @@ -1174,7 +1174,7 @@ mod tests { } } - let mut it = UnfoldrIterator::new(count, 0); + let mut it = UnfoldrIterator::new(0, count); let mut i = 0; for it.advance |counted| { assert_eq!(counted, i); diff --git a/src/test/run-pass/unfoldr-cross-crate.rs b/src/test/run-pass/unfoldr-cross-crate.rs index 4e98543ae826e..7fcae90a8d117 100644 --- a/src/test/run-pass/unfoldr-cross-crate.rs +++ b/src/test/run-pass/unfoldr-cross-crate.rs @@ -24,7 +24,7 @@ fn main() { } } - let mut it = UnfoldrIterator::new(count, 0); + let mut it = UnfoldrIterator::new(0, count); let mut i = 0; for it.advance |counted| { assert_eq!(counted, i); From 51beba6cf91ef8fcc06a32482c78bfc59b37bd73 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 29 Jun 2013 14:06:42 +0900 Subject: [PATCH 7/8] libextra: unused import fix for android AGAIN --- src/libextra/ebml.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs index 69eb9afad853b..4634a7db05e3c 100644 --- a/src/libextra/ebml.rs +++ b/src/libextra/ebml.rs @@ -97,11 +97,14 @@ pub mod reader { use core::cast::transmute; use core::int; use core::io; + use core::option::{None, Option, Some}; #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] - use core::option::{None, Option, Some}; use core::ptr::offset; + + #[cfg(target_arch = "x86")] + #[cfg(target_arch = "x86_64")] use core::unstable::intrinsics::bswap32; // ebml reading From 21cc0ccea10bb9d1b83612d26c8e62d06fe365a1 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Sat, 29 Jun 2013 14:07:24 +0900 Subject: [PATCH 8/8] librustc: fix #7467 for android --- src/librustc/middle/trans/meth.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index fc0c9c06c450b..7d6a5b5fef9ca 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -28,7 +28,7 @@ use middle::trans::type_of::*; use middle::ty; use middle::typeck; use util::common::indenter; -use util::ppaux::{Repr, ty_to_str}; +use util::ppaux::Repr; use middle::trans::type_::Type; @@ -36,7 +36,6 @@ use core::vec; use syntax::ast_map::{path, path_mod, path_name}; use syntax::ast_util; use syntax::{ast, ast_map}; -use syntax::parse::token; /** The main "translation" pass for methods. Generates code @@ -755,10 +754,9 @@ pub fn make_vtable(ccx: &mut CrateContext, components.push(ptr) } - let name = fmt!("%s_vtable_%u", ty_to_str(ccx.tcx, tydesc.ty), token::gensym("vtable")); - let tbl = C_struct(components); - let vt_gvar = do name.as_c_str |buf| { + let vtable = ccx.sess.str_of(gensym_name("vtable")); + let vt_gvar = do vtable.as_c_str |buf| { llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl).to_ref(), buf) }; llvm::LLVMSetInitializer(vt_gvar, tbl);