From ba9c51d20fe258f385d3a3334613955c8ce20af0 Mon Sep 17 00:00:00 2001 From: Falco Hirschenberger Date: Fri, 4 Apr 2014 18:22:55 +0200 Subject: [PATCH 1/9] Update README.md Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a25d916d931..c94b112e48e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ documentation. ## Quick Start -1. Download a [binary insaller][installer] for your platform. +1. Download a [binary installer][installer] for your platform. 2. Read the [tutorial]. 3. Enjoy! From 73b0186290d41e228e61b343c4b4a90570b580e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Fri, 4 Apr 2014 02:55:06 +0200 Subject: [PATCH 2/9] Fix inner attribute syntax from `#[foo];` to `#![foo]` From the 0.10 changelog: * The inner attribute syntax has changed from `#[foo];` to `#![foo]`. --- src/doc/guide-unsafe.md | 12 ++++++------ src/doc/po/ja/rust.md.po | 4 ++-- src/etc/combine-tests.py | 2 +- src/liblog/lib.rs | 4 ++-- src/liblog/macros.rs | 12 ++++++------ src/test/auxiliary/issue_2316_b.rs | 4 ++-- src/test/auxiliary/logging_right_crate.rs | 4 ++-- src/test/compile-fail/import-glob-0.rs | 4 ++-- src/test/compile-fail/import-glob-circular.rs | 4 ++-- src/test/compile-fail/name-clash-nullary.rs | 4 ++-- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- src/test/debug-info/simd.rs | 2 +- src/test/pretty/raw-str-nonexpr.rs | 2 +- src/test/run-fail/glob-use-std.rs | 4 ++-- src/test/run-fail/rt-set-exit-status-fail.rs | 4 ++-- src/test/run-fail/rt-set-exit-status-fail2.rs | 4 ++-- src/test/run-fail/rt-set-exit-status.rs | 4 ++-- .../macro-crate-outlive-expansion-phase.rs | 2 +- src/test/run-pass-fulldeps/macro-crate.rs | 2 +- .../phase-syntax-link-does-resolve.rs | 2 +- src/test/run-pass-fulldeps/qquote.rs | 2 +- src/test/run-pass-fulldeps/quote-tokens.rs | 2 +- .../run-pass-fulldeps/quote-unused-sp-no-warning.rs | 2 +- .../run-pass-fulldeps/syntax-extension-fourcc.rs | 2 +- .../run-pass-fulldeps/syntax-extension-hexfloat.rs | 2 +- src/test/run-pass/asm-concat-src.rs | 2 +- src/test/run-pass/asm-in-out-operand.rs | 2 +- src/test/run-pass/asm-out-assign.rs | 2 +- src/test/run-pass/capturing-logging.rs | 2 +- src/test/run-pass/conditional-debug-macro-off.rs | 2 +- src/test/run-pass/export-glob-imports-target.rs | 2 +- src/test/run-pass/ifmt.rs | 2 +- src/test/run-pass/import-glob-0.rs | 2 +- src/test/run-pass/import-glob-crate.rs | 2 +- src/test/run-pass/import-in-block.rs | 4 ++-- src/test/run-pass/intrinsics-integer.rs | 2 +- src/test/run-pass/issue-2526-a.rs | 2 +- src/test/run-pass/item-attributes.rs | 4 ++-- src/test/run-pass/linkage1.rs | 2 +- src/test/run-pass/logging-enabled-debug.rs | 2 +- src/test/run-pass/logging-enabled.rs | 2 +- src/test/run-pass/macro-crate-def-only.rs | 2 +- src/test/run-pass/macro-export-inner-module.rs | 2 +- src/test/run-pass/out-of-stack.rs | 2 +- src/test/run-pass/phase-use-ignored.rs | 2 +- src/test/run-pass/privacy-ns.rs | 2 +- src/test/run-pass/reexport-star.rs | 2 +- src/test/run-pass/simd-binop.rs | 4 ++-- src/test/run-pass/simd-generics.rs | 2 +- src/test/run-pass/simd-issue-10604.rs | 4 ++-- src/test/run-pass/simd-type.rs | 2 +- src/test/run-pass/tag-exports.rs | 2 +- src/test/run-pass/tcp-stress.rs | 2 +- src/test/run-pass/warn-ctypes-inhibit.rs | 4 ++-- 55 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 4c8e32982c1..47b629ac4d0 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -294,7 +294,7 @@ asm!(assembly template ); ``` -Any use of `asm` is feature gated (requires `#[feature(asm)];` on the +Any use of `asm` is feature gated (requires `#![feature(asm)]` on the crate to allow) and of course requires an `unsafe` block. > **Note**: the examples here are given in x86/x86-64 assembly, but all @@ -306,7 +306,7 @@ The `assembly template` is the only required parameter and must be a literal string (i.e `""`) ``` -#[feature(asm)]; +#![feature(asm)] #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] @@ -334,7 +334,7 @@ Output operands, input operands, clobbers and options are all optional but you must add the right number of `:` if you skip them: ``` -# #[feature(asm)]; +# #![feature(asm)] # #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] # fn main() { unsafe { asm!("xor %eax, %eax" @@ -348,7 +348,7 @@ asm!("xor %eax, %eax" Whitespace also doesn't matter: ``` -# #[feature(asm)]; +# #![feature(asm)] # #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] # fn main() { unsafe { asm!("xor %eax, %eax" ::: "eax"); @@ -362,7 +362,7 @@ Input and output operands follow the same format: `: expressions must be mutable lvalues: ``` -# #[feature(asm)]; +# #![feature(asm)] # #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] fn add(a: int, b: int) -> int { let mut c = 0; @@ -390,7 +390,7 @@ compiler not to assume any values loaded into those registers will stay valid. ``` -# #[feature(asm)]; +# #![feature(asm)] # #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] # fn main() { unsafe { // Put the value 0x200 in eax diff --git a/src/doc/po/ja/rust.md.po b/src/doc/po/ja/rust.md.po index 0e96f4db84b..de0164cc6b6 100644 --- a/src/doc/po/ja/rust.md.po +++ b/src/doc/po/ja/rust.md.po @@ -1,5 +1,5 @@ # Japanese translations for Rust package -# Copyright (C) 2013 The Rust Project Developers +# Copyright (C) 2013-2014 The Rust Project Developers # This file is distributed under the same license as the Rust package. # Automatically generated, 2013. # @@ -886,7 +886,7 @@ msgstr "" #: src/doc/rust.md:2008 #, fuzzy #| msgid "~~~~ use std::task::spawn;" -msgid "~~~~ {.ignore} #[warn(unstable)];" +msgid "~~~~ {.ignore} #![warn(unstable)]" msgstr "" "~~~~\n" "use std::task::spawn;" diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index a7f23405de5..68423b416f6 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -54,7 +54,7 @@ c.write( #[crate_id=\"run_pass_stage2#0.1\"]; #[crate_id=\"run_pass_stage2#0.1\"]; #[feature(globs, macro_rules, struct_variant, managed_boxes)]; -#[allow(warnings)]; +#![allow(warnings)] extern crate collections; """ ) diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index eb481c8b217..0656dd1f641 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -15,7 +15,7 @@ Utilities for program-wide and customizable logging ## Example ``` -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; fn main() { diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index e57deb77a89..f1d4a318bf0 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -21,7 +21,7 @@ /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { @@ -45,7 +45,7 @@ macro_rules! log( /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { @@ -63,7 +63,7 @@ macro_rules! error( /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { @@ -81,7 +81,7 @@ macro_rules! warn( /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { @@ -101,7 +101,7 @@ macro_rules! info( /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { @@ -118,7 +118,7 @@ macro_rules! debug( /// # Example /// /// ``` -/// #[feature(phase)]; +/// #![feature(phase)] /// #[phase(syntax, link)] extern crate log; /// /// # fn main() { diff --git a/src/test/auxiliary/issue_2316_b.rs b/src/test/auxiliary/issue_2316_b.rs index 36af01fe6c6..4530fa4bc25 100644 --- a/src/test/auxiliary/issue_2316_b.rs +++ b/src/test/auxiliary/issue_2316_b.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -9,7 +9,7 @@ // except according to those terms. #[allow(unused_imports)]; -#[feature(globs)]; +#![feature(globs)] extern crate issue_2316_a; diff --git a/src/test/auxiliary/logging_right_crate.rs b/src/test/auxiliary/logging_right_crate.rs index 10725981a06..b0a6e0f84fc 100644 --- a/src/test/auxiliary/logging_right_crate.rs +++ b/src/test/auxiliary/logging_right_crate.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; pub fn foo() { diff --git a/src/test/compile-fail/import-glob-0.rs b/src/test/compile-fail/import-glob-0.rs index 973e36e494c..210a47d2d03 100644 --- a/src/test/compile-fail/import-glob-0.rs +++ b/src/test/compile-fail/import-glob-0.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // error-pattern: unresolved name -#[feature(globs)]; +#![feature(globs)] use module_of_many_things::*; diff --git a/src/test/compile-fail/import-glob-circular.rs b/src/test/compile-fail/import-glob-circular.rs index 3f5127a55b8..39b18e1c445 100644 --- a/src/test/compile-fail/import-glob-circular.rs +++ b/src/test/compile-fail/import-glob-circular.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // error-pattern: unresolved -#[feature(globs)]; +#![feature(globs)] mod circ1 { pub use circ2::f2; diff --git a/src/test/compile-fail/name-clash-nullary.rs b/src/test/compile-fail/name-clash-nullary.rs index 246f0cb9e66..b5c0157cb5e 100644 --- a/src/test/compile-fail/name-clash-nullary.rs +++ b/src/test/compile-fail/name-clash-nullary.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] // error-pattern:declaration of `None` shadows use std::option::*; diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index 27201b76813..365a2fbe287 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -10,7 +10,7 @@ // ignore-test Can't use syntax crate here -#[feature(quote)]; +#![feature(quote)] extern crate syntax; diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index 97225c863e5..f202f1bb73c 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -10,7 +10,7 @@ // ignore-test Can't use syntax crate here -#[feature(quote)]; +#![feature(quote)] extern crate syntax; diff --git a/src/test/debug-info/simd.rs b/src/test/debug-info/simd.rs index e2a493e75e4..91d53339648 100644 --- a/src/test/debug-info/simd.rs +++ b/src/test/debug-info/simd.rs @@ -40,7 +40,7 @@ // debugger:continue -#[allow(experimental)]; +#![allow(experimental)] #[allow(unused_variable)]; use std::unstable::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2}; diff --git a/src/test/pretty/raw-str-nonexpr.rs b/src/test/pretty/raw-str-nonexpr.rs index 026293e7524..b76591048ce 100644 --- a/src/test/pretty/raw-str-nonexpr.rs +++ b/src/test/pretty/raw-str-nonexpr.rs @@ -11,7 +11,7 @@ // ignore-fast #[feature] doesn't work with check-fast // pp-exact -#[feature(asm)]; +#![feature(asm)] #[cfg = r#"just parse this"#] extern crate blah = r##"blah"##; diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs index 77177c8fcb8..a67ab3d2efc 100644 --- a/src/test/run-fail/glob-use-std.rs +++ b/src/test/run-fail/glob-use-std.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -11,7 +11,7 @@ // Issue #7580 // error-pattern:fail works -#[feature(globs)]; +#![feature(globs)] use std::*; diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs index 98d7d5cf437..385bc145204 100644 --- a/src/test/run-fail/rt-set-exit-status-fail.rs +++ b/src/test/run-fail/rt-set-exit-status-fail.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // error-pattern:whatever -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; use std::os; diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index 67f9f5a168f..3b5e27027b4 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // error-pattern:whatever -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; use std::os; use std::task; diff --git a/src/test/run-fail/rt-set-exit-status.rs b/src/test/run-fail/rt-set-exit-status.rs index 352e0f65644..b94045e5d12 100644 --- a/src/test/run-fail/rt-set-exit-status.rs +++ b/src/test/run-fail/rt-set-exit-status.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // error-pattern:whatever -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; use std::os; diff --git a/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs b/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs index eb705b8d8a0..cde78da3f61 100644 --- a/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs +++ b/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs @@ -14,7 +14,7 @@ // ignore-android // ignore-cross-compile #12102 -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate macro_crate_outlive_expansion_phase; diff --git a/src/test/run-pass-fulldeps/macro-crate.rs b/src/test/run-pass-fulldeps/macro-crate.rs index 6f412f01bb9..e30498bb3c1 100644 --- a/src/test/run-pass-fulldeps/macro-crate.rs +++ b/src/test/run-pass-fulldeps/macro-crate.rs @@ -14,7 +14,7 @@ // ignore-android // ignore-cross-compile #12102 -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate macro_crate_test; diff --git a/src/test/run-pass-fulldeps/phase-syntax-link-does-resolve.rs b/src/test/run-pass-fulldeps/phase-syntax-link-does-resolve.rs index a7b8297487d..ff82ff62a59 100644 --- a/src/test/run-pass-fulldeps/phase-syntax-link-does-resolve.rs +++ b/src/test/run-pass-fulldeps/phase-syntax-link-does-resolve.rs @@ -24,7 +24,7 @@ // can't run host binaries, and force-host to make this test build as the host // arch. -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate macro_crate_test; diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 1e26ce0c4f3..1def436b4de 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -11,7 +11,7 @@ // ignore-pretty // ignore-test -#[feature(quote)]; +#![feature(quote)] extern crate syntax; diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index 1bf601f71b4..5180ac68482 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -10,7 +10,7 @@ // ignore-test -#[feature(quote)]; +#![feature(quote)] #[feature(managed_boxes)]; extern crate syntax; diff --git a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs index ac8d361bf5a..ea2ffb8dcf8 100644 --- a/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs +++ b/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs @@ -10,7 +10,7 @@ // ignore-fast // ignore-android -#[feature(quote)]; +#![feature(quote)] #[deny(unused_variable)]; extern crate syntax; diff --git a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs index a6f118d77fa..54687c03da5 100644 --- a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs +++ b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs @@ -13,7 +13,7 @@ // ignore-pretty // ignore-cross-compile -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate fourcc; diff --git a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs b/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs index 6eeefabcf7c..eb25d82e549 100644 --- a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs +++ b/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs @@ -13,7 +13,7 @@ // ignore-cross-compile #12102 // ignore-fast -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate hexfloat; diff --git a/src/test/run-pass/asm-concat-src.rs b/src/test/run-pass/asm-concat-src.rs index 96c98a03720..5615089dcdc 100644 --- a/src/test/run-pass/asm-concat-src.rs +++ b/src/test/run-pass/asm-concat-src.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-fast #[feature] doesn't work with check-fast -#[feature(asm)]; +#![feature(asm)] pub fn main() { unsafe { asm!(concat!("", "")) }; diff --git a/src/test/run-pass/asm-in-out-operand.rs b/src/test/run-pass/asm-in-out-operand.rs index 11d4321b3e9..0b5502aa330 100644 --- a/src/test/run-pass/asm-in-out-operand.rs +++ b/src/test/run-pass/asm-in-out-operand.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-fast #[feature] doesn't work with check-fast -#[feature(asm)]; +#![feature(asm)] #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] diff --git a/src/test/run-pass/asm-out-assign.rs b/src/test/run-pass/asm-out-assign.rs index 2f6b87f26a7..de2630d1ca9 100644 --- a/src/test/run-pass/asm-out-assign.rs +++ b/src/test/run-pass/asm-out-assign.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-fast #[feature] doesn't work with check-fast -#[feature(asm)]; +#![feature(asm)] #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index 6c1b2f4653a..10976c5c612 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -12,7 +12,7 @@ // ignore-android (FIXME #11419) // exec-env:RUST_LOG=info -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index 8a2a00f5638..460846ef31c 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -12,7 +12,7 @@ // compile-flags: --cfg ndebug // exec-env:RUST_LOG=conditional-debug-macro-off=4 -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; diff --git a/src/test/run-pass/export-glob-imports-target.rs b/src/test/run-pass/export-glob-imports-target.rs index 3d8e7608788..e4f037e4563 100644 --- a/src/test/run-pass/export-glob-imports-target.rs +++ b/src/test/run-pass/export-glob-imports-target.rs @@ -15,7 +15,7 @@ // Modified to not use export since it's going away. --pcw -#[feature(globs)]; +#![feature(globs)] mod foo { use foo::bar::*; diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 7e9afc4de56..7cdd932faf6 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -11,7 +11,7 @@ // ignore-fast: check-fast screws up repr paths #[feature(macro_rules)]; -#[deny(warnings)]; +#![deny(warnings)] #[allow(unused_must_use)]; #[allow(deprecated_owned_vector)]; diff --git a/src/test/run-pass/import-glob-0.rs b/src/test/run-pass/import-glob-0.rs index dc5c7d11769..5f4bf557b23 100644 --- a/src/test/run-pass/import-glob-0.rs +++ b/src/test/run-pass/import-glob-0.rs @@ -10,7 +10,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] use module_of_many_things::*; use dug::too::greedily::and::too::deep::*; diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index a9a9f78943f..e1ca890f4fd 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -10,7 +10,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] #[allow(dead_assignment)]; use std::mem::*; diff --git a/src/test/run-pass/import-in-block.rs b/src/test/run-pass/import-in-block.rs index 7c0037c1e15..24196c22571 100644 --- a/src/test/run-pass/import-in-block.rs +++ b/src/test/run-pass/import-in-block.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] pub fn main() { use std::mem::replace; diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index 88c964462e8..867e12d4139 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -10,7 +10,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] mod rusti { extern "rust-intrinsic" { diff --git a/src/test/run-pass/issue-2526-a.rs b/src/test/run-pass/issue-2526-a.rs index b10871f78d4..00323b60649 100644 --- a/src/test/run-pass/issue-2526-a.rs +++ b/src/test/run-pass/issue-2526-a.rs @@ -11,7 +11,7 @@ // ignore-fast // aux-build:issue-2526.rs -#[feature(globs)]; +#![feature(globs)] #[allow(unused_imports)]; extern crate issue_2526; diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 22356764410..ae5a86c699e 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -160,7 +160,7 @@ mod test_foreign_items { use std::libc; extern { - #[attr]; + #![attr] #[attr] fn rust_get_test_int() -> libc::intptr_t; diff --git a/src/test/run-pass/linkage1.rs b/src/test/run-pass/linkage1.rs index c6f672c5d34..4b2c9861493 100644 --- a/src/test/run-pass/linkage1.rs +++ b/src/test/run-pass/linkage1.rs @@ -14,7 +14,7 @@ // ignore-macos // aux-build:linkage1.rs -#[feature(linkage)]; +#![feature(linkage)] extern crate other = "linkage1"; diff --git a/src/test/run-pass/logging-enabled-debug.rs b/src/test/run-pass/logging-enabled-debug.rs index b3a77aa9675..f5db1c7b1d6 100644 --- a/src/test/run-pass/logging-enabled-debug.rs +++ b/src/test/run-pass/logging-enabled-debug.rs @@ -12,7 +12,7 @@ // compile-flags:--cfg ndebug // exec-env:RUST_LOG=logging-enabled-debug=debug -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; diff --git a/src/test/run-pass/logging-enabled.rs b/src/test/run-pass/logging-enabled.rs index 587e0b9d4c5..31437586897 100644 --- a/src/test/run-pass/logging-enabled.rs +++ b/src/test/run-pass/logging-enabled.rs @@ -11,7 +11,7 @@ // ignore-fast // exec-env:RUST_LOG=logging-enabled=info -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; diff --git a/src/test/run-pass/macro-crate-def-only.rs b/src/test/run-pass/macro-crate-def-only.rs index 2c2ffd50eae..75b001a71d2 100644 --- a/src/test/run-pass/macro-crate-def-only.rs +++ b/src/test/run-pass/macro-crate-def-only.rs @@ -11,7 +11,7 @@ // aux-build:macro_crate_def_only.rs // ignore-fast -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate macro_crate_def_only; diff --git a/src/test/run-pass/macro-export-inner-module.rs b/src/test/run-pass/macro-export-inner-module.rs index 14c6423ce40..d77b360336c 100644 --- a/src/test/run-pass/macro-export-inner-module.rs +++ b/src/test/run-pass/macro-export-inner-module.rs @@ -12,7 +12,7 @@ //ignore-stage1 //ignore-fast -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] extern crate macro_export_inner_module; diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 71fde866703..00861bd9b21 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -10,7 +10,7 @@ // ignore-fast -#[feature(asm)]; +#![feature(asm)] use std::io::Process; use std::os; diff --git a/src/test/run-pass/phase-use-ignored.rs b/src/test/run-pass/phase-use-ignored.rs index 2b1a74c74ac..008a04eaa49 100644 --- a/src/test/run-pass/phase-use-ignored.rs +++ b/src/test/run-pass/phase-use-ignored.rs @@ -10,7 +10,7 @@ // ignore-fast -#[feature(phase)]; +#![feature(phase)] #[phase(syntax)] use std::mem; diff --git a/src/test/run-pass/privacy-ns.rs b/src/test/run-pass/privacy-ns.rs index c933e5bc919..bc7df6bb599 100644 --- a/src/test/run-pass/privacy-ns.rs +++ b/src/test/run-pass/privacy-ns.rs @@ -13,7 +13,7 @@ // Check we do the correct privacy checks when we import a name and there is an // item with that name in both the value and type namespaces. -#[feature(globs)]; +#![feature(globs)] #[allow(dead_code)]; #[allow(unused_imports)]; diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs index f6f7c9921ef..3b7696b548a 100644 --- a/src/test/run-pass/reexport-star.rs +++ b/src/test/run-pass/reexport-star.rs @@ -10,7 +10,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] // FIXME #3654 diff --git a/src/test/run-pass/simd-binop.rs b/src/test/run-pass/simd-binop.rs index 85c6555d7ce..0c2744f6838 100644 --- a/src/test/run-pass/simd-binop.rs +++ b/src/test/run-pass/simd-binop.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[allow(experimental)]; +#![allow(experimental)] use std::unstable::simd::{i32x4, f32x4, u32x4}; diff --git a/src/test/run-pass/simd-generics.rs b/src/test/run-pass/simd-generics.rs index 7ef8913a847..75062a46224 100644 --- a/src/test/run-pass/simd-generics.rs +++ b/src/test/run-pass/simd-generics.rs @@ -10,7 +10,7 @@ // ignore-fast -#[feature(simd)]; +#![feature(simd)] use std::ops; diff --git a/src/test/run-pass/simd-issue-10604.rs b/src/test/run-pass/simd-issue-10604.rs index 62dce696880..4e3c3afc5ad 100644 --- a/src/test/run-pass/simd-issue-10604.rs +++ b/src/test/run-pass/simd-issue-10604.rs @@ -10,8 +10,8 @@ // ignore-fast -#[allow(experimental)]; -#[feature(simd)]; +#![allow(experimental)] +#![feature(simd)] pub fn main() { let _o = None::; diff --git a/src/test/run-pass/simd-type.rs b/src/test/run-pass/simd-type.rs index 4506a694252..c79f285e486 100644 --- a/src/test/run-pass/simd-type.rs +++ b/src/test/run-pass/simd-type.rs @@ -10,7 +10,7 @@ // ignore-fast feature doesn't work -#[feature(simd)]; +#![feature(simd)] #[simd] struct RGBA { diff --git a/src/test/run-pass/tag-exports.rs b/src/test/run-pass/tag-exports.rs index 2fd6be40d11..bc749b5d905 100644 --- a/src/test/run-pass/tag-exports.rs +++ b/src/test/run-pass/tag-exports.rs @@ -10,7 +10,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(globs)]; +#![feature(globs)] use alder::*; diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 61478e3fdb4..d18e2ac7354 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -13,7 +13,7 @@ // ignore-android needs extra network permissions // exec-env:RUST_LOG=debug -#[feature(phase)]; +#![feature(phase)] #[phase(syntax, link)] extern crate log; diff --git a/src/test/run-pass/warn-ctypes-inhibit.rs b/src/test/run-pass/warn-ctypes-inhibit.rs index 30ce7715311..9b0a2340156 100644 --- a/src/test/run-pass/warn-ctypes-inhibit.rs +++ b/src/test/run-pass/warn-ctypes-inhibit.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,7 +10,7 @@ // compile-flags:-D ctypes -#[allow(ctypes)]; +#![allow(ctypes)] mod libc { extern { From b236f45e35554f89d490e7b5634354cde15d0126 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 4 Apr 2014 21:56:22 +1100 Subject: [PATCH 3/9] Add stdlib docs to the Linux binary tarball. These are not installed anywhere, but are included under `./doc` for those who want an offline copy with their nightlies. This increases the size of the (compressed) tarball from 76 to 83 MB. --- mk/dist.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mk/dist.mk b/mk/dist.mk index 8679aeed04f..43af4f90140 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -215,7 +215,7 @@ dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD) dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) dist-install-dir-$(1): PREPARE_CLEAN=true -dist-install-dir-$(1): prepare-base-dir-$(1) +dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs $$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \ > tmp/dist/manifest-$(1).in $$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in @@ -224,6 +224,7 @@ dist-install-dir-$(1): prepare-base-dir-$(1) $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR) $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR) $$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR) + $$(Q)cp -r doc $$(PREPARE_DEST_DIR) $$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR) dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1) From 7c48e53c1e8c1427cbb2e827a9d43bfa36847d65 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Fri, 4 Apr 2014 13:12:18 +0300 Subject: [PATCH 4/9] syntax: remove obsolete mutability from ExprVec and ExprRepeat. --- src/librustc/front/test.rs | 18 +++++++----------- src/librustc/middle/cfg/construct.rs | 4 ++-- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/const_eval.rs | 2 +- src/librustc/middle/dataflow.rs | 4 ++-- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/liveness.rs | 4 ++-- src/librustc/middle/moves.rs | 4 ++-- src/librustc/middle/region.rs | 2 +- src/librustc/middle/trans/consts.rs | 6 +++--- src/librustc/middle/trans/debuginfo.rs | 8 ++++---- src/librustc/middle/trans/tvec.rs | 8 ++++---- src/librustc/middle/typeck/check/mod.rs | 18 +++++++++--------- src/libsyntax/ast.rs | 4 ++-- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/fold.rs | 8 ++++---- src/libsyntax/parse/parser.rs | 9 ++++----- src/libsyntax/print/pprust.rs | 12 ++---------- src/libsyntax/visit.rs | 4 ++-- 19 files changed, 54 insertions(+), 67 deletions(-) diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 82e2e3147c9..86d2e039505 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -404,21 +404,17 @@ fn is_test_crate(krate: &ast::Crate) -> bool { } fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr { - let mut descs = Vec::new(); debug!("building test vector from {} tests", cx.testfns.borrow().len()); - for test in cx.testfns.borrow().iter() { - descs.push(mk_test_desc_and_fn_rec(cx, test)); - } - - let inner_expr = @ast::Expr { - id: ast::DUMMY_NODE_ID, - node: ast::ExprVec(descs, ast::MutImmutable), - span: DUMMY_SP, - }; @ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice), + node: ast::ExprVstore(@ast::Expr { + id: ast::DUMMY_NODE_ID, + node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| { + mk_test_desc_and_fn_rec(cx, test) + }).collect()), + span: DUMMY_SP, + }, ast::ExprVstoreSlice), span: DUMMY_SP, } } diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index a66e9191b33..d631340fc4e 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -347,7 +347,7 @@ impl<'a> CFGBuilder<'a> { self.add_node(expr.id, []) } - ast::ExprVec(ref elems, _) => { + ast::ExprVec(ref elems) => { self.straightline(expr, pred, elems.as_slice()) } @@ -379,7 +379,7 @@ impl<'a> CFGBuilder<'a> { self.straightline(expr, base_exit, field_exprs.as_slice()) } - ast::ExprRepeat(elem, count, _) => { + ast::ExprRepeat(elem, count) => { self.straightline(expr, pred, [elem, count]) } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 6d95202d2c1..e3a0a6a9782 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -157,7 +157,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) { } ExprVstore(_, ExprVstoreMutSlice) | ExprVstore(_, ExprVstoreSlice) | - ExprVec(_, MutImmutable) | + ExprVec(_) | ExprAddrOf(MutImmutable, _) | ExprParen(..) | ExprField(..) | diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index bd45956fbb2..aca8367f0b8 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -213,7 +213,7 @@ impl<'a> ConstEvalVisitor<'a> { join(self.classify(a), self.classify(b)), ast::ExprTup(ref es) | - ast::ExprVec(ref es, ast::MutImmutable) => + ast::ExprVec(ref es) => join_all(es.iter().map(|e| self.classify(*e))), ast::ExprVstore(e, vstore) => { diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 92d359887b9..2ef1adba771 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -538,11 +538,11 @@ impl<'a, 'b, O:DataFlowOperator> PropagationContext<'a, 'b, O> { self.walk_expr(l, in_out, loop_scopes); } - ast::ExprVec(ref exprs, _) => { + ast::ExprVec(ref exprs) => { self.walk_exprs(exprs.as_slice(), in_out, loop_scopes) } - ast::ExprRepeat(l, r, _) => { + ast::ExprRepeat(l, r) => { self.walk_expr(l, in_out, loop_scopes); self.walk_expr(r, in_out, loop_scopes); } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index a667e81f349..09f396e932f 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -309,7 +309,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) { let target_ty = ty::expr_ty(cx.tcx, e); check_trait_cast(cx, source_ty, target_ty, source.span); } - ExprRepeat(element, count_expr, _) => { + ExprRepeat(element, count_expr) => { let count = ty::eval_repeat_count(cx.tcx, count_expr); if count > 1 { let element_ty = ty::expr_ty(cx.tcx, element); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 42b7260a4ae..046103c439d 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1109,11 +1109,11 @@ impl<'a> Liveness<'a> { self.propagate_through_expr(expr, succ) } - ExprVec(ref exprs, _) => { + ExprVec(ref exprs) => { self.propagate_through_exprs(exprs.as_slice(), succ) } - ExprRepeat(element, count, _) => { + ExprRepeat(element, count) => { let succ = self.propagate_through_expr(count, succ); self.propagate_through_expr(element, succ) } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index f3ecfdefa75..dbc28f9fdd5 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -473,7 +473,7 @@ impl<'a> VisitContext<'a> { self.use_expr(base, expr_mode); } - ExprVec(ref exprs, _) => { + ExprVec(ref exprs) => { self.consume_exprs(exprs.as_slice()); } @@ -539,7 +539,7 @@ impl<'a> VisitContext<'a> { // } } - ExprRepeat(base, count, _) => { + ExprRepeat(base, count) => { self.consume_expr(base); self.consume_expr(count); } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index ad940113a86..8a5e0d3df17 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -724,7 +724,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, visitor.region_maps.record_rvalue_scope(subexpr.id, blk_id); record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id); } - ast::ExprVec(ref subexprs, _) | + ast::ExprVec(ref subexprs) | ast::ExprTup(ref subexprs) => { for &subexpr in subexprs.iter() { record_rvalue_scope_if_borrow_expr( diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 6aaae564fdf..a2b46b1f2a1 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -557,7 +557,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, inlineable.iter().fold(true, |a, &b| a && b)) }) } - ast::ExprVec(ref es, ast::MutImmutable) => { + ast::ExprVec(ref es) => { let (v, _, inlineable) = const_vec(cx, e, es.as_slice(), @@ -573,7 +573,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, _ => { cx.sess().span_bug(e.span, "bad const-slice lit") } } } - ast::ExprVec(ref es, ast::MutImmutable) => { + ast::ExprVec(ref es) => { let (cv, llunitty, _) = const_vec(cx, e, es.as_slice(), @@ -592,7 +592,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, _ => cx.sess().span_bug(e.span, "bad const-slice expr") } } - ast::ExprRepeat(elem, count, _) => { + ast::ExprRepeat(elem, count) => { let vec_ty = ty::expr_ty(cx.tcx(), e); let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty); let llunitty = type_of::type_of(cx, unit_ty); diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index df4598c0307..0a610538f31 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -2619,15 +2619,15 @@ fn populate_scope_map(cx: &CrateContext, walk_expr(cx, rhs, scope_stack, scope_map); } - ast::ExprVec(ref init_expressions, _) | - ast::ExprTup(ref init_expressions) => { + ast::ExprVec(ref init_expressions) | + ast::ExprTup(ref init_expressions) => { for ie in init_expressions.iter() { walk_expr(cx, *ie, scope_stack, scope_map); } } - ast::ExprAssign(sub_exp1, sub_exp2) | - ast::ExprRepeat(sub_exp1, sub_exp2, _) => { + ast::ExprAssign(sub_exp1, sub_exp2) | + ast::ExprRepeat(sub_exp1, sub_exp2) => { walk_expr(cx, sub_exp1, scope_stack, scope_map); walk_expr(cx, sub_exp2, scope_stack, scope_map); } diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 96368467163..b47f509aeee 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -392,7 +392,7 @@ pub fn write_content<'a>( } } } - ast::ExprVec(ref elements, _) => { + ast::ExprVec(ref elements) => { match dest { Ignore => { for element in elements.iter() { @@ -418,7 +418,7 @@ pub fn write_content<'a>( } return bcx; } - ast::ExprRepeat(element, count_expr, _) => { + ast::ExprRepeat(element, count_expr) => { match dest { Ignore => { return expr::trans_into(bcx, element, Ignore); @@ -486,8 +486,8 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { } } }, - ast::ExprVec(ref es, _) => es.len(), - ast::ExprRepeat(_, count_expr, _) => { + ast::ExprVec(ref es) => es.len(), + ast::ExprRepeat(_, count_expr) => { ty::eval_repeat_count(bcx.tcx(), count_expr) } _ => bcx.tcx().sess.span_bug(content_expr.span, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 8f9b67f81e8..a1e878b592e 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2482,13 +2482,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt, let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); ty::mk_str(tcx, tt) } - ast::ExprVec(ref args, mutbl) => { + ast::ExprVec(ref args) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); let mut any_error = false; let mut any_bot = false; let mutability = match vst { ast::ExprVstoreMutSlice => ast::MutMutable, - _ => mutbl, + _ => ast::MutImmutable, }; let t: ty::t = fcx.infcx().next_ty_var(); for e in args.iter() { @@ -2509,13 +2509,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt, ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutability}, tt) } } - ast::ExprRepeat(element, count_expr, mutbl) => { + ast::ExprRepeat(element, count_expr) => { check_expr_with_hint(fcx, count_expr, ty::mk_uint()); let _ = ty::eval_repeat_count(fcx, count_expr); let tt = ast_expr_vstore_to_vstore(fcx, ev, vst); let mutability = match vst { ast::ExprVstoreMutSlice => ast::MutMutable, - _ => mutbl, + _ => ast::MutImmutable, }; let t: ty::t = fcx.infcx().next_ty_var(); check_expr_has_type(fcx, element, t); @@ -3017,16 +3017,16 @@ fn check_expr_with_unifier(fcx: &FnCtxt, fcx.write_ty(id, t_1); } } - ast::ExprVec(ref args, mutbl) => { + ast::ExprVec(ref args) => { let t: ty::t = fcx.infcx().next_ty_var(); for e in args.iter() { check_expr_has_type(fcx, *e, t); } - let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl}, + let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable}, ty::vstore_fixed(args.len())); fcx.write_ty(id, typ); } - ast::ExprRepeat(element, count_expr, mutbl) => { + ast::ExprRepeat(element, count_expr) => { check_expr_with_hint(fcx, count_expr, ty::mk_uint()); let count = ty::eval_repeat_count(fcx, count_expr); let t: ty::t = fcx.infcx().next_ty_var(); @@ -3039,7 +3039,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, fcx.write_bot(id); } else { - let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl}, + let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable}, ty::vstore_fixed(count)); fcx.write_ty(id, t); } @@ -3864,7 +3864,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: &FnCtxt, // string literals and *empty slices* live in static memory ty::vstore_slice(ty::ReStatic) } - ast::ExprVec(ref elements, _) if elements.len() == 0 => { + ast::ExprVec(ref elements) if elements.len() == 0 => { // string literals and *empty slices* live in static memory ty::vstore_slice(ty::ReStatic) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 53d2ac97b49..6a5acff3fe0 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -493,7 +493,7 @@ pub enum Expr_ { ExprVstore(@Expr, ExprVstore), // First expr is the place; second expr is the value. ExprBox(@Expr, @Expr), - ExprVec(Vec<@Expr>, Mutability), + ExprVec(Vec<@Expr>), ExprCall(@Expr, Vec<@Expr>), ExprMethodCall(Ident, Vec>, Vec<@Expr>), ExprTup(Vec<@Expr>), @@ -536,7 +536,7 @@ pub enum Expr_ { ExprStruct(Path, Vec , Option<@Expr> /* base */), // A vector literal constructed from one repeated element. - ExprRepeat(@Expr /* element */, @Expr /* count */, Mutability), + ExprRepeat(@Expr /* element */, @Expr /* count */), // No-op: used solely so we can pretty-print faithfully ExprParen(@Expr) diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index ef62f0a01f6..b7c12cd4fdc 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprVstore(expr, vst)) } fn expr_vec(&self, sp: Span, exprs: Vec<@ast::Expr> ) -> @ast::Expr { - self.expr(sp, ast::ExprVec(exprs, ast::MutImmutable)) + self.expr(sp, ast::ExprVec(exprs)) } fn expr_vec_ng(&self, sp: Span) -> @ast::Expr { self.expr_call_global(sp, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 06bf892771d..e21f14e4a96 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -740,11 +740,11 @@ pub fn noop_fold_expr(e: @Expr, folder: &mut T) -> @Expr { ExprBox(p, e) => { ExprBox(folder.fold_expr(p), folder.fold_expr(e)) } - ExprVec(ref exprs, mutt) => { - ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect(), mutt) + ExprVec(ref exprs) => { + ExprVec(exprs.iter().map(|&x| folder.fold_expr(x)).collect()) } - ExprRepeat(expr, count, mutt) => { - ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt) + ExprRepeat(expr, count) => { + ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count)) } ExprTup(ref elts) => ExprTup(elts.iter().map(|x| folder.fold_expr(*x)).collect()), ExprCall(f, ref args) => { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2d78bfe5694..94f5458ba53 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1819,12 +1819,11 @@ impl<'a> Parser<'a> { return self.parse_block_expr(lo, UnsafeBlock(ast::UserProvided)); } else if self.token == token::LBRACKET { self.bump(); - let mutbl = MutImmutable; if self.token == token::RBRACKET { // Empty vector. self.bump(); - ex = ExprVec(Vec::new(), mutbl); + ex = ExprVec(Vec::new()); } else { // Nonempty vector. let first_expr = self.parse_expr(); @@ -1835,7 +1834,7 @@ impl<'a> Parser<'a> { self.bump(); let count = self.parse_expr(); self.expect(&token::RBRACKET); - ex = ExprRepeat(first_expr, count, mutbl); + ex = ExprRepeat(first_expr, count); } else if self.token == token::COMMA { // Vector with two or more elements. self.bump(); @@ -1846,11 +1845,11 @@ impl<'a> Parser<'a> { ); let mut exprs = vec!(first_expr); exprs.push_all_move(remaining_exprs); - ex = ExprVec(exprs, mutbl); + ex = ExprVec(exprs); } else { // Vector with one element. self.expect(&token::RBRACKET); - ex = ExprVec(vec!(first_expr), mutbl); + ex = ExprVec(vec!(first_expr)); } } hi = self.last_span.hi; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 1eee0fb87d6..7972852a3f4 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1110,25 +1110,17 @@ impl<'a> State<'a> { try!(self.word_space(")")); try!(self.print_expr(e)); } - ast::ExprVec(ref exprs, mutbl) => { + ast::ExprVec(ref exprs) => { try!(self.ibox(indent_unit)); try!(word(&mut self.s, "[")); - if mutbl == ast::MutMutable { - try!(word(&mut self.s, "mut")); - if exprs.len() > 0u { try!(self.nbsp()); } - } try!(self.commasep_exprs(Inconsistent, exprs.as_slice())); try!(word(&mut self.s, "]")); try!(self.end()); } - ast::ExprRepeat(element, count, mutbl) => { + ast::ExprRepeat(element, count) => { try!(self.ibox(indent_unit)); try!(word(&mut self.s, "[")); - if mutbl == ast::MutMutable { - try!(word(&mut self.s, "mut")); - try!(self.nbsp()); - } try!(self.print_expr(element)); try!(word(&mut self.s, ",")); try!(word(&mut self.s, "..")); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index eb03bb1f0bb..81e5e228027 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -635,10 +635,10 @@ pub fn walk_expr>(visitor: &mut V, expression: &Expr, en visitor.visit_expr(place, env.clone()); visitor.visit_expr(subexpression, env.clone()) } - ExprVec(ref subexpressions, _) => { + ExprVec(ref subexpressions) => { walk_exprs(visitor, subexpressions.as_slice(), env.clone()) } - ExprRepeat(element, count, _) => { + ExprRepeat(element, count) => { visitor.visit_expr(element, env.clone()); visitor.visit_expr(count, env.clone()) } From 8057faa2d320db0abdfb385ad1827f8902931cef Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 9 Oct 2013 09:55:00 -0700 Subject: [PATCH 5/9] std: TrieSet should implement container::{,Mutable}Set --- src/libcollections/trie.rs | 54 ++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 740a3637700..8b83e658386 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -293,6 +293,40 @@ impl Mutable for TrieSet { fn clear(&mut self) { self.map.clear() } } +impl Set for TrieSet { + #[inline] + fn contains(&self, value: &uint) -> bool { + self.map.contains_key(value) + } + + #[inline] + fn is_disjoint(&self, other: &TrieSet) -> bool { + self.iter().all(|v| !other.contains(&v)) + } + + #[inline] + fn is_subset(&self, other: &TrieSet) -> bool { + self.iter().all(|v| other.contains(&v)) + } + + #[inline] + fn is_superset(&self, other: &TrieSet) -> bool { + other.is_subset(self) + } +} + +impl MutableSet for TrieSet { + #[inline] + fn insert(&mut self, value: uint) -> bool { + self.map.insert(value, ()) + } + + #[inline] + fn remove(&mut self, value: &uint) -> bool { + self.map.remove(value) + } +} + impl TrieSet { /// Create an empty TrieSet #[inline] @@ -300,26 +334,6 @@ impl TrieSet { TrieSet{map: TrieMap::new()} } - /// Return true if the set contains a value - #[inline] - pub fn contains(&self, value: &uint) -> bool { - self.map.contains_key(value) - } - - /// Add a value to the set. Return true if the value was not already - /// present in the set. - #[inline] - pub fn insert(&mut self, value: uint) -> bool { - self.map.insert(value, ()) - } - - /// Remove a value from the set. Return true if the value was - /// present in the set. - #[inline] - pub fn remove(&mut self, value: &uint) -> bool { - self.map.remove(value) - } - /// Visit all values in reverse order #[inline] pub fn each_reverse(&self, f: |&uint| -> bool) -> bool { From 58ac1c3563679b51f0e6dae1188cb635f1e89292 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 3 Apr 2014 20:47:53 -0700 Subject: [PATCH 6/9] extra: Add with_capacity to PriorityQueue and SmallIntMap --- src/libcollections/priority_queue.rs | 5 +++++ src/libcollections/smallintmap.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 8c7eb1c6033..a13785104ab 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -117,6 +117,11 @@ impl PriorityQueue { /// Create an empty PriorityQueue pub fn new() -> PriorityQueue { PriorityQueue{data: ~[],} } + /// Create an empty PriorityQueue with capacity `capacity` + pub fn with_capacity(capacity: uint) -> PriorityQueue { + PriorityQueue { data: slice::with_capacity(capacity) } + } + /// Create a PriorityQueue from a vector (heapify) pub fn from_vec(xs: ~[T]) -> PriorityQueue { let mut q = PriorityQueue{data: xs,}; diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index db7fafe522b..bd4f85aa81a 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -112,6 +112,11 @@ impl SmallIntMap { /// Create an empty SmallIntMap pub fn new() -> SmallIntMap { SmallIntMap{v: ~[]} } + /// Create an empty SmallIntMap with capacity `capacity` + pub fn with_capacity(capacity: uint) -> SmallIntMap { + SmallIntMap { v: slice::with_capacity(capacity) } + } + pub fn get<'a>(&'a self, key: &uint) -> &'a V { self.find(key).expect("key not present") } From d250ec0bddf7ba84e34e893621234af3ebcfbca8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 3 Apr 2014 21:52:13 -0700 Subject: [PATCH 7/9] Register new snapshots --- src/libarena/lib.rs | 1 - src/libcollections/lib.rs | 2 -- src/libgetopts/lib.rs | 2 -- src/libnative/lib.rs | 2 -- src/librand/lib.rs | 2 -- src/librustc/lib.rs | 3 --- src/libstd/lib.rs | 4 +--- src/libsync/lib.rs | 4 +--- src/libsyntax/lib.rs | 2 -- src/libterm/lib.rs | 4 +--- src/snapshots.txt | 8 ++++++++ 11 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 17ab294a3f6..be42fab8b54 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -23,7 +23,6 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")] #![allow(missing_doc)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap extern crate collections; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 84c440aa3a9..ef5289ae373 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -22,8 +22,6 @@ #![feature(macro_rules, managed_boxes, default_type_params, phase)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap - extern crate rand; #[cfg(test)] extern crate test; diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index dfb91a477cb..9d4f2e2f8f0 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -87,8 +87,6 @@ #![deny(missing_doc)] #![deny(deprecated_owned_vector)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap - #[cfg(test)] #[phase(syntax, link)] extern crate log; use std::cmp::Eq; diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 8afbbda71c2..7e05c4c961c 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -51,8 +51,6 @@ #![deny(unused_result, unused_must_use)] #![allow(non_camel_case_types)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap - // NB this crate explicitly does *not* allow glob imports, please seriously // consider whether they're needed before adding that feature here (the // answer is that you don't need them) diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 8623e627e53..57b910093e0 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -71,8 +71,6 @@ println!("{:?}", tuple_ptr) html_root_url = "http://static.rust-lang.org/doc/master")] #![feature(macro_rules, managed_boxes, phase)] - -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap #![deny(deprecated_owned_vector)] #[cfg(test)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index cf653f816ac..893cc019ca7 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -31,9 +31,6 @@ This API is completely unstable and subject to change. #![feature(macro_rules, globs, struct_variant, managed_boxes, quote, default_type_params, phase)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap -#![allow(unrecognized_lint)] // NOTE: remove after a stage0 snap - extern crate flate; extern crate arena; extern crate syntax; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index f4f5be4d37a..42d35b60896 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -57,9 +57,7 @@ // Don't link to std. We are std. #![no_std] -// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap -#![allow(missing_doc)] // NOTE: remove after a stage0 snap -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap +#![deny(missing_doc)] #![allow(unknown_features)] // NOTE: remove after a stage0 snap // When testing libstd, bring in libuv as the I/O backend so tests can print diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index 7e7a6afc8ee..58bd837104c 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -22,9 +22,7 @@ #![feature(phase)] #![deny(deprecated_owned_vector)] -// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap -#![allow(missing_doc)] // NOTE: remove after a stage0 snap -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap +#![deny(missing_doc)] #[cfg(test)] #[phase(syntax, link)] extern crate log; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5570219bd8e..012bc50ecab 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -30,8 +30,6 @@ This API is completely unstable and subject to change. quote)] #![allow(deprecated)] -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap - extern crate serialize; extern crate term; extern crate collections; diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 05104d5729f..a94a13aa017 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -21,9 +21,7 @@ #![feature(macro_rules)] -// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap -#![allow(missing_doc)] // NOTE: remove after a stage0 snap -#![allow(visible_private_types)] // NOTE: remove after a stage0 snap +#![deny(missing_doc)] extern crate collections; diff --git a/src/snapshots.txt b/src/snapshots.txt index 59ea9834ed7..83a8e7bb965 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2014-04-03 e7fe207 + freebsd-x86_64 6d40f547d13896ab9d9dd4a4fdf2e72be553b01b + linux-i386 875a8f6956f7d703f7206db91ca2a9b67c244cf8 + linux-x86_64 4d90df12231d1c9f51b5ae6e75546ccddcf0534b + macos-i386 e5486efa1356abca8f8d5cac9aa6135c9626ab51 + macos-x86_64 8341419e4295d780f72950cfe2187195d0d03e83 + winnt-i386 60c2fb349ac8a7ad30c9ba2518a61e669debb7bf + S 2014-03-28 b8601a3 freebsd-x86_64 c6b0651b2a90697754920ad381c13f9b7942ab47 linux-i386 3bef5684fd0582fbd4ddebd4514182d4f72924f7 From bf1ffaf5f48f925bfb62f9dca3bc73cfcc246148 Mon Sep 17 00:00:00 2001 From: Michael Darakananda Date: Wed, 2 Apr 2014 23:10:36 -0400 Subject: [PATCH 8/9] Added grow_fn and retain to Vec --- src/libstd/vec.rs | 65 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index e414ff25d43..30416b28241 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -15,7 +15,7 @@ use cmp::{Ord, Eq, Ordering, TotalEq, TotalOrd}; use container::{Container, Mutable}; use default::Default; use fmt; -use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator}; +use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator, range}; use libc::{free, c_void}; use mem::{size_of, move_val_init}; use mem; @@ -1135,6 +1135,56 @@ impl Vec { pub fn as_mut_ptr(&mut self) -> *mut T { self.as_mut_slice().as_mut_ptr() } + + /// Retains only the elements specified by the predicate. + /// + /// In other words, remove all elements `e` such that `f(&e)` returns false. + /// This method operates in place and preserves the order the retained elements. + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(1i, 2, 3, 4); + /// vec.retain(|x| x%2 == 0); + /// assert_eq!(vec, vec!(2, 4)); + /// ``` + pub fn retain(&mut self, f: |&T| -> bool) { + let len = self.len(); + let mut del = 0u; + { + let v = self.as_mut_slice(); + + for i in range(0u, len) { + if !f(&v[i]) { + del += 1; + } else if del > 0 { + v.swap(i-del, i); + } + } + } + if del > 0 { + self.truncate(len - del); + } + } + + /// Expands a vector in place, initializing the new elements to the result of a function. + /// + /// The vector is grown by `n` elements. The i-th new element are initialized to the value + /// returned by `f(i)` where `i` is in the range [0, n). + /// + /// # Example + /// + /// ```rust + /// let mut vec = vec!(0u, 1); + /// vec.grow_fn(3, |i| i); + /// assert_eq!(vec, vec!(0, 1, 0, 1, 2)); + /// ``` + pub fn grow_fn(&mut self, n: uint, f: |uint| -> T) { + self.reserve_additional(n); + for i in range(0u, n) { + self.push(f(i)); + } + } } impl Vec { @@ -1523,4 +1573,17 @@ mod tests { v.clone_from(&three); assert_eq!(v, three) } + + fn test_grow_fn() { + let mut v = Vec::from_slice([0u, 1]); + v.grow_fn(3, |i| i); + assert!(v == Vec::from_slice([0u, 1, 0, 1, 2])); + } + + #[test] + fn test_retain() { + let mut vec = Vec::from_slice([1u, 2, 3, 4]); + vec.retain(|x| x%2 == 0); + assert!(vec == Vec::from_slice([2u, 4])); + } } From 6d43138b75f009bfa6f0774953ef55fd91e9760a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Apr 2014 13:45:24 -0700 Subject: [PATCH 9/9] Test fixes from rollup --- src/libsyntax/print/pprust.rs | 8 ++++---- src/test/auxiliary/impl_privacy_xc_1.rs | 2 +- src/test/pretty/attr-fn-inner.rs | 2 +- src/test/pretty/doc-comments.rs | 2 +- src/test/run-pass/method-attributes.rs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7972852a3f4..fe969c6fd51 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -915,9 +915,6 @@ impl<'a> State<'a> { match attr.node.style { ast::AttrInner => { try!(self.print_attribute(attr)); - if !attr.node.is_sugared_doc { - try!(word(&mut self.s, ";")); - } count += 1; } _ => {/* fallthrough */ } @@ -935,7 +932,10 @@ impl<'a> State<'a> { if attr.node.is_sugared_doc { word(&mut self.s, attr.value_str().unwrap().get()) } else { - try!(word(&mut self.s, "#[")); + match attr.node.style { + ast::AttrInner => try!(word(&mut self.s, "#![")), + ast::AttrOuter => try!(word(&mut self.s, "#[")), + } try!(self.print_meta_item(attr.meta())); word(&mut self.s, "]") } diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs index de182c48c41..df4e0658cb8 100644 --- a/src/test/auxiliary/impl_privacy_xc_1.rs +++ b/src/test/auxiliary/impl_privacy_xc_1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_type = "lib"]; +#![crate_type = "lib"] pub struct Fish { pub x: int diff --git a/src/test/pretty/attr-fn-inner.rs b/src/test/pretty/attr-fn-inner.rs index 6745a271436..65dcf900567 100644 --- a/src/test/pretty/attr-fn-inner.rs +++ b/src/test/pretty/attr-fn-inner.rs @@ -14,7 +14,7 @@ // accidentally carried over to each inner function fn main() { - #[inner_attr]; + #![inner_attr] #[outer_attr] fn f() { } diff --git a/src/test/pretty/doc-comments.rs b/src/test/pretty/doc-comments.rs index 45e242c0ca0..02d141f5163 100644 --- a/src/test/pretty/doc-comments.rs +++ b/src/test/pretty/doc-comments.rs @@ -57,5 +57,5 @@ fn f() { } fn g() { } fn h() { - #[doc = "as do inner ones"]; + #![doc = "as do inner ones"] } diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index db7440738da..87c43da9ebc 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -22,12 +22,12 @@ trait frobable { impl frobable for int { #[frob_attr1] fn frob(&self) { - #[frob_attr2]; + #![frob_attr2] } #[defrob_attr1] fn defrob(&self) { - #[defrob_attr2]; + #![defrob_attr2] } }