From 8f38eae7ad732350cca979d077b8eecc632230e7 Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Sun, 25 Jan 2015 23:00:21 -0500 Subject: [PATCH 01/18] wrmdir -> RemoveDirectoryW Signed-off-by: Peter Atashian --- src/liblibc/lib.rs | 1 + src/libstd/sys/windows/fs.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index a07fd61cd8c34..2380bc7a75243 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -271,6 +271,7 @@ pub use funcs::bsd43::{shutdown}; #[cfg(windows)] pub use funcs::extra::kernel32::{GetOverlappedResult, ConnectNamedPipe}; #[cfg(windows)] pub use funcs::extra::kernel32::{DisconnectNamedPipe, OpenProcess}; #[cfg(windows)] pub use funcs::extra::kernel32::{MoveFileExW, VirtualProtect}; +#[cfg(windows)] pub use funcs::extra::kernel32::{RemoveDirectoryW}; #[cfg(windows)] pub use funcs::extra::msvcrt::{get_osfhandle, open_osfhandle}; #[cfg(windows)] pub use funcs::extra::winsock::{ioctlsocket}; diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index cb8ef7eb66bc4..bdcbcdfb8679c 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -342,7 +342,7 @@ pub fn chmod(p: &Path, mode: uint) -> IoResult<()> { pub fn rmdir(p: &Path) -> IoResult<()> { let p = try!(to_utf16(p)); - mkerr_libc(unsafe { libc::wrmdir(p.as_ptr()) }) + super::mkerr_winbool(unsafe { libc::RemoveDirectoryW(p.as_ptr()) }) } pub fn chown(_p: &Path, _uid: int, _gid: int) -> IoResult<()> { From d553ed66c75c1482fbbf6eeb60c929b3270079b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 26 Jan 2015 08:32:34 +0100 Subject: [PATCH 02/18] shell 'case' statement don't need 'break' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the syntax of 'case' is: `case word in [[(] pattern [| pattern] ...) list ;; ] ... esac` `list` don't have to issue `break`. `break` is normally used to exit a `for`, `until` or `while` loop. --- src/etc/local_stage0.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh index 56ebd4f140f52..41dea2eeff4a1 100755 --- a/src/etc/local_stage0.sh +++ b/src/etc/local_stage0.sh @@ -21,19 +21,16 @@ case $OS in ("Linux"|"FreeBSD"|"DragonFly") BIN_SUF= LIB_SUF=.so - break ;; ("Darwin") BIN_SUF= LIB_SUF=.dylib - break ;; (*) BIN_SUF=.exe LIB_SUF=.dll LIB_DIR=bin LIB_PREFIX= - break ;; esac From fff5600925cf3bbee2befd6957b727016765ebd0 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Sun, 25 Jan 2015 23:54:09 +0100 Subject: [PATCH 03/18] Make Unix and Windows impls consistent There are some explicit Send/Sync implementations for Window's types that don't exist in Unix. While the end result will be the same, I believe it's clearer if we keep the explicit implementations consistent by making the os-specific types Send/Sync where needed and possible. This commit addresses pipe src/libstd/sys/unix/pipe.rs unsafe impl Send for UnixListener {} unsafe impl Sync for UnixListener {} src/libstd/sys/windows/pipe.rs unsafe impl Send for UnixStream {} unsafe impl Sync for UnixStream {} unsafe impl Send for UnixListener {} unsafe impl Sync for UnixListener {} unsafe impl Send for UnixAcceptor {} unsafe impl Sync for UnixAcceptor {} unsafe impl Send for AcceptorState {} unsafe impl Sync for AcceptorState {} --- src/libstd/sys/windows/pipe.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 9996909f2f5bb..ef511d1319923 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -129,6 +129,9 @@ impl Drop for Event { } } +unsafe impl Send for Event {} +unsafe impl Sync for Event {} + struct Inner { handle: libc::HANDLE, lock: Mutex<()>, @@ -156,6 +159,9 @@ impl Drop for Inner { } } +unsafe impl Send for Inner {} +unsafe impl Sync for Inner {} + unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE { libc::CreateNamedPipeW( name, @@ -220,9 +226,6 @@ pub struct UnixStream { write_deadline: u64, } -unsafe impl Send for UnixStream {} -unsafe impl Sync for UnixStream {} - impl UnixStream { fn try_connect(p: *const u16) -> Option { // Note that most of this is lifted from the libuv implementation. @@ -615,17 +618,11 @@ pub struct UnixAcceptor { deadline: u64, } -unsafe impl Send for UnixAcceptor {} -unsafe impl Sync for UnixAcceptor {} - struct AcceptorState { abort: Event, closed: AtomicBool, } -unsafe impl Send for AcceptorState {} -unsafe impl Sync for AcceptorState {} - impl UnixAcceptor { pub fn accept(&mut self) -> IoResult { // This function has some funky implementation details when working with From fde4472848b662a4d1236388c4cf15e2450237e6 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Mon, 26 Jan 2015 00:06:12 +0100 Subject: [PATCH 04/18] Make Unix and Windows impls consistent There are some explicit Send/Sync implementations for Window's types that don't exist in Unix. While the end result will be the same, I believe it's clearer if we keep the explicit implementations consistent by making the os-specific types Send/Sync where needed and possible. This commit addresses tcp. Existing differences below: src/libstd/sys/unix/tcp.rs unsafe impl Sync for TcpListener {} unsafe impl Sync for AcceptorInner {} src/libstd/sys/windows/tcp.rs unsafe impl Send for Event {} unsafe impl Sync for Event {} unsafe impl Send for TcpListener {} unsafe impl Sync for TcpListener {} unsafe impl Send for TcpAcceptor {} unsafe impl Sync for TcpAcceptor {} unsafe impl Send for AcceptorInner {} unsafe impl Sync for AcceptorInner {} --- src/libstd/sys/windows/tcp.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 77139b52efa14..ebebeb1a8a577 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -116,9 +116,6 @@ pub struct TcpAcceptor { deadline: u64, } -unsafe impl Send for TcpAcceptor {} -unsafe impl Sync for TcpAcceptor {} - struct AcceptorInner { listener: TcpListener, abort: Event, @@ -126,7 +123,6 @@ struct AcceptorInner { closed: AtomicBool, } -unsafe impl Send for AcceptorInner {} unsafe impl Sync for AcceptorInner {} impl TcpAcceptor { From f7f80ce61a4e3e684714614a57320cc8fd0932ef Mon Sep 17 00:00:00 2001 From: Nelson Chen Date: Sun, 25 Jan 2015 23:54:19 -0800 Subject: [PATCH 05/18] Add "-webkit-overflow-scrolling: touch" to book CSS for the page wrapper. This change permits native momentum scrolling in Safari on iOS in the book. --- src/rustbook/css.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rustbook/css.rs b/src/rustbook/css.rs index 65ba031a2d634..44c603e01edc2 100644 --- a/src/rustbook/css.rs +++ b/src/rustbook/css.rs @@ -40,6 +40,7 @@ body { bottom: 0px; box-sizing: border-box; background: none repeat scroll 0% 0% #FFF; + -webkit-overflow-scrolling: touch; } #page { From e0dc9bd275a61e6eb6fde0356d54cc4072ae7a71 Mon Sep 17 00:00:00 2001 From: Nelson Chen Date: Mon, 26 Jan 2015 02:28:51 -0800 Subject: [PATCH 06/18] Add same "-webkit-overflow-scrolling: touch" to the table of contents in the book. --- src/rustbook/css.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rustbook/css.rs b/src/rustbook/css.rs index 44c603e01edc2..7af95350c95e4 100644 --- a/src/rustbook/css.rs +++ b/src/rustbook/css.rs @@ -29,6 +29,7 @@ body { font-size: 16px; background: none repeat scroll 0% 0% #FFF; box-sizing: border-box; + -webkit-overflow-scrolling: touch; } #page-wrapper { From 85b80aa1e1c69f0ee22c93e7126f96ab7182377a Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 23 Jan 2015 10:52:58 +0100 Subject: [PATCH 07/18] don't ignore errors in encode and allow hashmaps with enum keys closes #21470 on main rust repository was fixed on rust-lang/rustc-serialize (see https://github.com/rust-lang/rustc-serialize/pull/32) --- src/libserialize/json.rs | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 5f4ba8ef9fcc7..d86bf8e48716f 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -97,7 +97,7 @@ //! }; //! //! // Serialize using `json::encode` -//! let encoded = json::encode(&object); +//! let encoded = json::encode(&object).unwrap(); //! //! // Deserialize using `json::decode` //! let decoded: TestStruct = json::decode(encoded.as_slice()).unwrap(); @@ -143,7 +143,7 @@ //! uid: 1, //! dsc: "test".to_string(), //! val: num.to_json(), -//! }); +//! }).unwrap(); //! println!("data: {}", data); //! // data: {"uid":1,"dsc":"test","val":"0.0001+12.539j"}; //! } @@ -316,13 +316,13 @@ pub fn decode(s: &str) -> DecodeResult { } /// Shortcut function to encode a `T` into a JSON `String` -pub fn encode(object: &T) -> string::String { +pub fn encode(object: &T) -> Result { let mut s = String::new(); { let mut encoder = Encoder::new(&mut s); - let _ = object.encode(&mut encoder); + try!(object.encode(&mut encoder)); } - s + Ok(s) } impl fmt::Display for ErrorCode { @@ -536,7 +536,6 @@ impl<'a> ::Encoder for Encoder<'a> { fn emit_enum(&mut self, _name: &str, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } f(self) } @@ -550,10 +549,10 @@ impl<'a> ::Encoder for Encoder<'a> { // enums are encoded as strings or objects // Bunny => "Bunny" // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]} - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } if cnt == 0 { escape_str(self.writer, name) } else { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } try!(write!(self.writer, "{{\"variant\":")); try!(escape_str(self.writer, name)); try!(write!(self.writer, ",\"fields\":[")); @@ -785,7 +784,6 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_enum(&mut self, _name: &str, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } f(self) } @@ -797,10 +795,10 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { - if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } if cnt == 0 { escape_str(self.writer, name) } else { + if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } try!(write!(self.writer, "{{\n")); self.curr_indent += self.indent; try!(spaces(self.writer, self.curr_indent)); @@ -3537,6 +3535,24 @@ mod tests { } } + #[test] + fn test_hashmap_with_enum_key() { + use std::collections::HashMap; + use json; + #[derive(RustcEncodable, Eq, Hash, PartialEq, RustcDecodable, Show)] + enum Enum { + Foo, + #[allow(dead_code)] + Bar, + } + let mut map = HashMap::new(); + map.insert(Enum::Foo, 0); + let result = json::encode(&map).unwrap(); + assert_eq!(&result[], r#"{"Foo":0}"#); + let decoded: HashMap = json::decode(result.as_slice()).unwrap(); + assert_eq!(map, decoded); + } + #[test] fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() { use std::collections::HashMap; From 82b0b0fcc70593ff13176795f1bc82c86c7c618f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 26 Jan 2015 16:10:22 +0100 Subject: [PATCH 08/18] fallout --- src/libsyntax/parse/mod.rs | 2 +- src/test/run-pass/deriving-encodable-decodable-box.rs | 2 +- src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs | 2 +- src/test/run-pass/issue-14021.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 8cb7ee5b33746..6dfd1fddcf7dd 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -854,7 +854,7 @@ mod test { #[test] fn string_to_tts_1 () { let tts = string_to_tts("fn a (b : i32) { b; }".to_string()); - assert_eq!(json::encode(&tts), + assert_eq!(json::encode(&tts).unwrap(), "[\ {\ \"variant\":\"TtToken\",\ diff --git a/src/test/run-pass/deriving-encodable-decodable-box.rs b/src/test/run-pass/deriving-encodable-decodable-box.rs index 1a204fa3e206e..a0888850aaf14 100644 --- a/src/test/run-pass/deriving-encodable-decodable-box.rs +++ b/src/test/run-pass/deriving-encodable-decodable-box.rs @@ -24,7 +24,7 @@ struct A { fn main() { let obj = A { foo: box [true, false] }; - let s = json::encode(&obj); + let s = json::encode(&obj).unwrap(); let obj2: A = json::decode(s.as_slice()).unwrap(); assert!(obj.foo == obj2.foo); } diff --git a/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs b/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs index 3b2c1d9f27c72..a5453d26170ad 100644 --- a/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs +++ b/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs @@ -35,7 +35,7 @@ fn main() { foo: Cell::new(true), bar: RefCell::new( A { baz: 2 } ) }; - let s = json::encode(&obj); + let s = json::encode(&obj).unwrap(); let obj2: B = json::decode(s.as_slice()).unwrap(); assert!(obj.foo.get() == obj2.foo.get()); assert!(obj.bar.borrow().baz == obj2.bar.borrow().baz); diff --git a/src/test/run-pass/issue-14021.rs b/src/test/run-pass/issue-14021.rs index 509459a2ab338..8c4dd7ddc9a31 100644 --- a/src/test/run-pass/issue-14021.rs +++ b/src/test/run-pass/issue-14021.rs @@ -20,7 +20,7 @@ struct UnitLikeStruct; pub fn main() { let obj = UnitLikeStruct; - let json_str: String = json::encode(&obj); + let json_str: String = json::encode(&obj).unwrap(); let json_object = json::from_str(json_str.as_slice()); let mut decoder = json::Decoder::new(json_object.unwrap()); From cbcb191b970360e3b32a8be7d86d5c6ec2b8e7c9 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Mon, 26 Jan 2015 17:45:21 +0100 Subject: [PATCH 09/18] Remove comment about `UnsafeCell`s and `static` It has actually been safe to put an `UnsafeCell` into a non-mutable `static` since the `const` change. --- src/libcore/cell.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 202d860021ee4..62029a4ea010d 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -592,12 +592,6 @@ impl<'b, T> DerefMut for RefMut<'b, T> { /// The `UnsafeCell` type is the only legal way to obtain aliasable data that is considered /// mutable. In general, transmuting an `&T` type into an `&mut T` is considered undefined behavior. /// -/// Although it is possible to put an `UnsafeCell` into static item, it is not permitted to take -/// the address of the static item if the item is not declared as mutable. This rule exists because -/// immutable static items are stored in read-only memory, and thus any attempt to mutate their -/// interior can cause segfaults. Immutable static items containing `UnsafeCell` instances are -/// still useful as read-only initializers, however, so we do not forbid them altogether. -/// /// Types like `Cell` and `RefCell` use this type to wrap their internal data. /// /// `UnsafeCell` doesn't opt-out from any marker traits, instead, types with an `UnsafeCell` From ea50bf8850304e8afefa9089792fc077fb54aef4 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Mon, 26 Jan 2015 22:39:51 +0100 Subject: [PATCH 10/18] Unconditionally disable LLVM's FastISel on AArch64 Before ca07e256f62f772d14c42f41af46f2aeacc54983, LLVM's AArch64FastISel had a sign (and zero?) extension bug. Until rustc gets its LLVM past that commit, the way of workaround is to pass an option to LLVM that forces the disabling of FastISel (which would normally kick in for -O0). Fixes #21627 --- src/librustc_trans/back/write.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 5e48ce384be51..68e1be65ee8b2 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -1012,6 +1012,9 @@ unsafe fn configure_llvm(sess: &Session) { if sess.time_llvm_passes() { add("-time-passes"); } if sess.print_llvm_passes() { add("-debug-pass=Structure"); } + // FIXME #21627 disable faulty FastISel on AArch64 (even for -O0) + if sess.target.target.arch.as_slice() == "aarch64" { add("-fast-isel=0"); } + for arg in sess.opts.cg.llvm_args.iter() { add(&(*arg)[]); } From 94404070d66ab2ca49cb649291738fcb567ea4d8 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 27 Jan 2015 15:44:05 -0800 Subject: [PATCH 11/18] discuss.rust-lang.org -> internals.rust-lang.org --- CONTRIBUTING.md | 4 ++-- README.md | 4 ++-- src/doc/index.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f2bd6dc30c5d..2724e47938439 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,11 +50,11 @@ example, if it's 2014, and you change a Rust file that was created in # Coordination and communication Get feedback from other developers on -[discuss.rust-lang.org][discuss], and +[internals.rust-lang.org][internals], and [#rust-internals][pound-rust-internals]. [pound-rust-internals]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals -[discuss]: http://discuss.rust-lang.org +[internals]: http://internals.rust-lang.org For more details, please refer to [Note-development-policy](https://github.com/rust-lang/rust/wiki/Note-development-policy). diff --git a/README.md b/README.md index eef27236b1aa3..6d54c2c6ee4ca 100644 --- a/README.md +++ b/README.md @@ -112,11 +112,11 @@ The Rust community congregates in a few places: * [StackOverflow] - Get help here. * [/r/rust] - General discussion. -* [discuss.rust-lang.org] - For development of the Rust language itself. +* [internals.rust-lang.org] - For development of the Rust language itself. [StackOverflow]: http://stackoverflow.com/questions/tagged/rust [/r/rust]: http://reddit.com/r/rust -[discuss.rust-lang.org]: http://discuss.rust-lang.org/ +[internals.rust-lang.org]: http://internals.rust-lang.org/ ## License diff --git a/src/doc/index.md b/src/doc/index.md index 25dcc10d89363..f385a9798ea3c 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -41,7 +41,7 @@ problem might reveal someone who has asked it before! There is an active [subreddit](http://reddit.com/r/rust) with lots of discussion about Rust. -There is also a [developer forum](http://discuss.rust-lang.org/), where the +There is also a [developer forum](http://internals.rust-lang.org/), where the development of Rust itself is discussed. # Specification From 1c502f1d435734990dc6eee34d80caf737db2076 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 28 Jan 2015 10:12:54 +0800 Subject: [PATCH 12/18] README.md - Fix source tarball link --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eef27236b1aa3..be424a8b7a5b5 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ documentation. To build from the [tarball] do: - $ curl -O https://static.rust-lang.org/dist/rust-nightly.tar.gz - $ tar -xzf rust-nightly.tar.gz - $ cd rust-nightly + $ curl -O https://static.rust-lang.org/dist/rustc-nightly-src.tar.gz + $ tar -xzf rustc-nightly-src.tar.gz + $ cd rustc-nightly Or to build from the [repo] do: @@ -80,7 +80,7 @@ $ pacman -S base-devel $ make && make install [repo]: https://github.com/rust-lang/rust -[tarball]: https://static.rust-lang.org/dist/rust-nightly.tar.gz +[tarball]: https://static.rust-lang.org/dist/rustc-nightly-src.tar.gz [trpl]: http://doc.rust-lang.org/book/index.html ## Notes From 57dd4ea78d527f1c81f6009d0132bf210dd8fdfd Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 26 Jan 2015 22:56:50 -0500 Subject: [PATCH 13/18] fix #[cfg(test)] warnings --- src/liballoc/heap.rs | 1 + src/libfmt_macros/lib.rs | 2 +- src/librustc_back/rpath.rs | 1 - src/libserialize/json.rs | 3 +-- src/libsyntax/ext/expand.rs | 5 +---- src/libsyntax/print/pprust.rs | 1 - src/libtest/lib.rs | 3 +-- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index a2643f4d0f79b..c87d789901b1b 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[cfg(not(test))] use core::ptr::PtrExt; // FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias` diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 0ff153274410a..57b4a67de367d 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -444,7 +444,7 @@ mod tests { use super::*; fn same(fmt: &'static str, p: &[Piece<'static>]) { - let mut parser = Parser::new(fmt); + let parser = Parser::new(fmt); assert!(p == parser.collect::>>()); } diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index bafd5fbe94487..47b909df5e8da 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -151,7 +151,6 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec { mod test { use super::{RPathConfig}; use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; - use syntax::abi; #[test] fn test_rpaths_to_flags() { diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index dad72fbd0e30b..f6c76f2c7b86b 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2618,7 +2618,7 @@ mod tests { use super::JsonEvent::*; use super::{Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser, StackElement, Stack, Decoder, Encoder, EncoderError}; - use std::{i64, u64, f32, f64, old_io}; + use std::{i64, u64, f32, f64}; use std::collections::BTreeMap; use std::num::Float; use std::string; @@ -3928,7 +3928,6 @@ mod tests { #[test] fn test_encode_hashmap_with_arbitrary_key() { - use std::str::from_utf8; use std::old_io::Writer; use std::collections::HashMap; use std::fmt; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 629991799e73d..acf0fe7f6cde3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1433,15 +1433,12 @@ mod test { use super::{pattern_bindings, expand_crate}; use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig}; use ast; - use ast::{Attribute_, AttrOuter, MetaWord, Name}; - use attr; + use ast::Name; use codemap; - use codemap::Spanned; use ext::mtwt; use fold::Folder; use parse; use parse::token; - use ptr::P; use util::parser_testing::{string_to_parser}; use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents}; use visit; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ae3c4addf3883..f9a202523b562 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2975,7 +2975,6 @@ mod test { use ast_util; use codemap; use parse::token; - use ptr::P; #[test] fn test_fun_to_string() { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 2e59b15b6d918..0f3d84ae6ea71 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1118,9 +1118,8 @@ pub mod bench { mod tests { use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc, TestDescAndFn, TestOpts, run_test, - Metric, MetricMap, + MetricMap, StaticTestName, DynTestName, DynTestFn, ShouldFail}; - use std::old_io::TempDir; use std::thunk::Thunk; use std::sync::mpsc::channel; From d0a9a39b1eb6a5fd152332392b7c4b1cd08a92c6 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 18:58:07 +0100 Subject: [PATCH 14/18] Rename found_ast to FoundAst and qualify uses. This matches contemporary Rust style. --- src/librustc/metadata/csearch.rs | 14 +++++--------- src/librustc/metadata/decoder.rs | 10 +++++----- src/librustc/middle/const_eval.rs | 4 ++-- src/librustc_trans/trans/inline.rs | 16 ++++++++-------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index e34fb37e1c555..1295970d667b0 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -10,10 +10,6 @@ // Searching for information from the cstore -#![allow(non_camel_case_types)] - -pub use self::found_ast::*; - use metadata::common::*; use metadata::cstore; use metadata::decoder; @@ -101,10 +97,10 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec r } -pub enum found_ast<'ast> { - found(&'ast ast::InlinedItem), - found_parent(ast::DefId, &'ast ast::InlinedItem), - not_found, +pub enum FoundAst<'ast> { + Found(&'ast ast::InlinedItem), + FoundParent(ast::DefId, &'ast ast::InlinedItem), + NotFound, } // Finds the AST for this item in the crate metadata, if any. If the item was @@ -112,7 +108,7 @@ pub enum found_ast<'ast> { // will be returned. pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId, decode_inlined_item: decoder::DecodeInlinedItem) - -> found_ast<'tcx> { + -> FoundAst<'tcx> { let cstore = &tcx.sess.cstore; let cdata = cstore.get_crate_data(def.krate); decoder::maybe_get_item_ast(&*cdata, tcx, def.node, decode_inlined_item) diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index e6f76dedca95f..b573c54ef855b 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -693,23 +693,23 @@ pub type DecodeInlinedItem<'a> = pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeId, mut decode_inlined_item: DecodeInlinedItem) - -> csearch::found_ast<'tcx> { + -> csearch::FoundAst<'tcx> { debug!("Looking up item: {}", id); let item_doc = lookup_item(id, cdata.data()); let path = item_path(item_doc).init().to_vec(); match decode_inlined_item(cdata, tcx, path, item_doc) { - Ok(ii) => csearch::found(ii), + Ok(ii) => csearch::FoundAst::Found(ii), Err(path) => { match item_parent_item(item_doc) { Some(did) => { let did = translate_def_id(cdata, did); let parent_item = lookup_item(did.node, cdata.data()); match decode_inlined_item(cdata, tcx, path, parent_item) { - Ok(ii) => csearch::found_parent(did, ii), - Err(_) => csearch::not_found + Ok(ii) => csearch::FoundAst::FoundParent(did, ii), + Err(_) => csearch::FoundAst::NotFound } } - None => csearch::not_found + None => csearch::FoundAst::NotFound } } } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index c2533c1a9c688..00141903c7c3b 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -133,7 +133,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, } let expr_id = match csearch::maybe_get_item_ast(tcx, enum_def, box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { - csearch::found(&ast::IIItem(ref item)) => match item.node { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemEnum(ast::EnumDef { ref variants }, _) => { // NOTE this doesn't do the right thing, it compares inlined // NodeId's to the original variant_def's NodeId, but they @@ -173,7 +173,7 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId) } let expr_id = match csearch::maybe_get_item_ast(tcx, def_id, box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { - csearch::found(&ast::IIItem(ref item)) => match item.node { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemConst(_, ref const_expr) => Some(const_expr.id), _ => None }, diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index dd1cfc5ad6d82..ea6d9b88e117e 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -43,11 +43,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) box |a,b,c,d| astencode::decode_inlined_item(a, b, c, d)); let inline_def = match csearch_result { - csearch::not_found => { + csearch::FoundAst::NotFound => { ccx.external().borrow_mut().insert(fn_id, None); return None; } - csearch::found(&ast::IIItem(ref item)) => { + csearch::FoundAst::Found(&ast::IIItem(ref item)) => { ccx.external().borrow_mut().insert(fn_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, fn_id); @@ -90,12 +90,12 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) local_def(item.id) } - csearch::found(&ast::IIForeign(ref item)) => { + csearch::FoundAst::Found(&ast::IIForeign(ref item)) => { ccx.external().borrow_mut().insert(fn_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, fn_id); local_def(item.id) } - csearch::found_parent(parent_id, &ast::IIItem(ref item)) => { + csearch::FoundAst::FoundParent(parent_id, &ast::IIItem(ref item)) => { ccx.external().borrow_mut().insert(parent_id, Some(item.id)); ccx.external_srcs().borrow_mut().insert(item.id, parent_id); @@ -124,11 +124,11 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) trans_item(ccx, &**item); local_def(my_id) } - csearch::found_parent(_, _) => { - ccx.sess().bug("maybe_get_item_ast returned a found_parent \ + csearch::FoundAst::FoundParent(_, _) => { + ccx.sess().bug("maybe_get_item_ast returned a FoundParent \ with a non-item parent"); } - csearch::found(&ast::IITraitItem(_, ref trait_item)) => { + csearch::FoundAst::Found(&ast::IITraitItem(_, ref trait_item)) => { match *trait_item { ast::RequiredMethod(_) => ccx.sess().bug("found RequiredMethod IITraitItem"), ast::ProvidedMethod(ref mth) => { @@ -147,7 +147,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) } } } - csearch::found(&ast::IIImplItem(impl_did, ref impl_item)) => { + csearch::FoundAst::Found(&ast::IIImplItem(impl_did, ref impl_item)) => { match *impl_item { ast::MethodImplItem(ref mth) => { ccx.external().borrow_mut().insert(fn_id, Some(mth.id)); From f88c94d8d2c74402d6f72607a47c4850dcdf3b4d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:13:36 +0100 Subject: [PATCH 15/18] Simplify the implementation of segments_name_eq. --- src/libsyntax/ast_util.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 5aeea47ac60dc..07d3290d410f7 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -670,20 +670,13 @@ pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool { // are two arrays of segments equal when compared unhygienically? pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool { - if a.len() != b.len() { - false - } else { - for (idx,seg) in a.iter().enumerate() { - if seg.identifier.name != b[idx].identifier.name - // FIXME #7743: ident -> name problems in lifetime comparison? - // can types contain idents? - || seg.parameters != b[idx].parameters - { - return false; - } - } - true - } + a.len() == b.len() && + a.iter().zip(b.iter()).all(|(s, t)| { + s.identifier.name == t.identifier.name && + // FIXME #7743: ident -> name problems in lifetime comparison? + // can types contain idents? + s.parameters == t.parameters + }) } /// Returns true if this literal is a string and false otherwise. From 4ad677e5b65b803e15e91e40097e2d77f0209ca7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:22:09 +0100 Subject: [PATCH 16/18] Remove a custom variant of iter::Cloned. --- src/librustc/metadata/encoder.rs | 4 ++-- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/ty.rs | 2 +- src/librustc_trans/back/link.rs | 3 +-- src/libsyntax/ast_map/mod.rs | 19 +++---------------- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index f6c5ba4b52bc8..783bc8810572f 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1577,7 +1577,7 @@ fn encode_info_for_items(ecx: &EncodeContext, &krate.module, &[], ast::CRATE_NODE_ID, - ast_map::Values([].iter()).chain(None), + [].iter().cloned().chain(None), syntax::parse::token::special_idents::invalid, ast::Public); @@ -1949,7 +1949,7 @@ fn encode_misc_info(ecx: &EncodeContext, } // Encode reexports for the root module. - encode_reexports(ecx, rbml_w, 0, ast_map::Values([].iter()).chain(None)); + encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None)); rbml_w.end_tag(); rbml_w.end_tag(); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 091ef9d52eb40..6d296d70ffa4a 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -130,7 +130,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, debug!("> Decoding inlined fn: {:?}::?", { // Do an Option dance to use the path after it is moved below. - let s = ast_map::path_to_string(ast_map::Values(path.iter())); + let s = ast_map::path_to_string(path.iter().cloned()); path_as_str = Some(s); path_as_str.as_ref().map(|x| &x[]) }); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 86cf030c8288a..bf9c850302bfa 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -5249,7 +5249,7 @@ pub fn with_path(cx: &ctxt, id: ast::DefId, f: F) -> T where if id.krate == ast::LOCAL_CRATE { cx.map.with_path(id.node, f) } else { - f(ast_map::Values(csearch::get_item_path(cx, id).iter()).chain(None)) + f(csearch::get_item_path(cx, id).iter().cloned().chain(None)) } } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index f5a6f3d95a2c4..f6d061ea722ad 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -37,7 +37,6 @@ use flate; use serialize::hex::ToHex; use syntax::ast; use syntax::ast_map::{PathElem, PathElems, PathName}; -use syntax::ast_map; use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; use syntax::parse::token; @@ -339,7 +338,7 @@ pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tc let path = [PathName(token::intern(&s[])), gensym_name(name)]; let hash = get_symbol_hash(ccx, t); - mangle(ast_map::Values(path.iter()), Some(&hash[])) + mangle(path.iter().cloned(), Some(&hash[])) } pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String { diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 96476cabac5f8..f2be6b2258282 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -75,21 +75,8 @@ impl<'a> Iterator for LinkedPath<'a> { } } -// HACK(eddyb) move this into libstd (value wrapper for slice::Iter). -#[derive(Clone)] -pub struct Values<'a, T:'a>(pub slice::Iter<'a, T>); - -impl<'a, T: Copy> Iterator for Values<'a, T> { - type Item = T; - - fn next(&mut self) -> Option { - let &mut Values(ref mut items) = self; - items.next().map(|&x| x) - } -} - /// The type of the iterator used by with_path. -pub type PathElems<'a, 'b> = iter::Chain, LinkedPath<'b>>; +pub type PathElems<'a, 'b> = iter::Chain>, LinkedPath<'b>>; pub fn path_to_string>(path: PI) -> String { let itr = token::get_ident_interner(); @@ -458,9 +445,9 @@ impl<'ast> Map<'ast> { if parent == id { match self.find_entry(id) { Some(RootInlinedParent(data)) => { - f(Values(data.path.iter()).chain(next)) + f(data.path.iter().cloned().chain(next)) } - _ => f(Values([].iter()).chain(next)) + _ => f([].iter().cloned().chain(next)) } } else { self.with_path_next(parent, Some(&LinkedPathNode { From 7aa27353931c3cad8d43ee7ba82f622a68faac18 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:25:25 +0100 Subject: [PATCH 17/18] Remove unnecessary to_string() call. --- src/libsyntax/ast_map/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index f2be6b2258282..002e003afcb88 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -88,7 +88,7 @@ pub fn path_to_string>(path: PI) -> String { } s.push_str(&e[]); s - }).to_string() + }) } #[derive(Copy, Show)] From 9a379d425783a6852e807ebee19ecfe2e6de9b23 Mon Sep 17 00:00:00 2001 From: Orpheus Lummis Date: Wed, 28 Jan 2015 10:04:56 -0500 Subject: [PATCH 18/18] Correct Orpheus Lummis's email and name New email address, stylization of name. --- AUTHORS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 896731f02515b..0eafe9eac3237 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -516,7 +516,7 @@ Olivier Saut Olle Jonsson Or Brostovski Oren Hazi -Orphée Lafond-Lummis +Orpheus Lummis P1start Pablo Brasero Palmer Cox