diff --git a/RELEASES.md b/RELEASES.md index 9b61ce0e05414..54fe87dc65816 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,182 @@ +Version 1.4.0 (2015-10-29) +============================ + +* ~1200 changes, numerous bugfixes + +Highlights +---------- + +* Windows builds targeting the 64-bit MSVC ABI and linker (instead of + GNU) are now supported and recommended for use. + +Breaking Changes +---------------- + +* [Several changes have been made to fix type soundness and improve + the behavior of associated types][sound]. See [RFC 1214]. Although + we have mostly introduced these changes as warnings this release, to + become errors next release, there are still some scenarios that will + see immediate breakage. +* [The `str::lines` and `BufRead::lines` iterators treat `\r\n` as + line breaks in addition to `\n`][crlf]. +* [Loans of `'static` lifetime extend to the end of a function][stat]. +* [`str::parse` no longer introduces avoidable rounding error when + parsing floating point numbers. Together with earlier changes to + float formatting/output, "round trips" like f.to_string().parse() + now preserve the value of f exactly. Additionally, leading plus + signs are now accepted][fp3]. + + +Language +-------- + +* `use` statements that import multiple items [can now rename + them][i], as in `use foo::{bar as kitten, baz as puppy}`. +* [Binops work correctly on fat pointers][binfat]. +* `pub extern crate`, which does not behave as expected, [issues a + warning][pec] until a better solution is found. + +Libraries +--------- + +* [Many APIs were stabilized][stab]: `>::into_string`, + [`Arc::downgrade`], [`Arc::get_mut`], [`Arc::make_mut`], + [`Arc::try_unwrap`], [`Box::from_raw`], [`Box::into_raw`], [`CStr::to_str`], + [`CStr::to_string_lossy`], [`CString::from_raw`], [`CString::into_raw`], + [`IntoRawFd::into_raw_fd`], [`IntoRawFd`], + `IntoRawHandle::into_raw_handle`, `IntoRawHandle`, + `IntoRawSocket::into_raw_socket`, `IntoRawSocket`, [`Rc::downgrade`], + [`Rc::get_mut`], [`Rc::make_mut`], [`Rc::try_unwrap`], [`Result::expect`], + [`String::into_boxed_str`], [`TcpStream::read_timeout`], + [`TcpStream::set_read_timeout`], [`TcpStream::set_write_timeout`], + [`TcpStream::write_timeout`], [`UdpSocket::read_timeout`], + [`UdpSocket::set_read_timeout`], [`UdpSocket::set_write_timeout`], + [`UdpSocket::write_timeout`], `Vec::append`, `Vec::split_off`, + [`VecDeque::append`], [`VecDeque::retain`], [`VecDeque::split_off`], + [`rc::Weak::upgrade`], [`rc::Weak`], [`slice::Iter::as_slice`], + [`slice::IterMut::into_slice`], [`str::CharIndices::as_str`], + [`str::Chars::as_str`], [`str::split_at_mut`], [`str::split_at`], + [`sync::Weak::upgrade`], [`sync::Weak`], [`thread::park_timeout`], + [`thread::sleep`]. +* [Some APIs were deprecated][dep]: `BTreeMap::with_b`, + `BTreeSet::with_b`, `Option::as_mut_slice`, `Option::as_slice`, + `Result::as_mut_slice`, `Result::as_slice`, `f32::from_str_radix`, + `f64::from_str_radix`. +* [Reverse-searching strings is faster with the 'two-way' + algorithm][s]. +* [`std::io::copy` allows `?Sized` arguments][cc]. +* The `Windows`, `Chunks`, and `ChunksMut` iterators over slices all + [override `count`, `nth` and `last` with an O(1) + implementation][it]. +* [`Default` is implemented for arrays up to `[T; 32]`][d]. +* [`IntoRawFd` has been added to the Unix-specific prelude, + `IntoRawSocket` and `IntoRawHandle` to the Windows-specific + prelude][pr]. +* [`Extend` and `FromIterator` where `T: + Copy`][ext] as part of [RFC 839]. This will cause type inferance + breakage in rare situations. +* [`BinaryHeap` implements `Debug`][bh2]. +* [`Borrow` and `BorrowMut` are implemented for fixed-size + arrays][bm]. +* [`extern fn`s with the "Rust" and "C" ABIs implement common + traits including `Eq`, `Ord`, `Debug`, `Hash`][fp]. +* [String comparison is faster][faststr]. +* `&mut T` where `T: std::fmt::Write` [also implements + `std::fmt::Write`][mutw]. +* [A stable regression in `VecDeque::push_back` and other + capicity-altering methods that caused panics for zero-sized types + was fixed][vd]. +* [Function pointers implement traits for up to 12 parameters][fp2]. + +Miscellaneous +------------- + +* The compiler [no longer uses the 'morestack' feature to prevent + stack overflow][mm]. Instead it uses guard pages and stack + probes (though stack probes are not yet implemented on any platform + but Windows). +* [The compiler matches traits faster when projections are involved][p]. +* The 'improper_ctypes' lint [no longer warns about use of `isize` and + `usize`][ffi]. +* [Cargo now displays useful information about what its doing during + `cargo update`][cu]. + +[`Arc::downgrade`]: http://doc.rust-lang.org/nightly/alloc/arc/struct.Arc.html#method.downgrade +[`Arc::make_mut`]: http://doc.rust-lang.org/nightly/alloc/arc/struct.Arc.html#method.make_mut +[`Arc::get_mut`]: http://doc.rust-lang.org/nightly/alloc/arc/struct.Arc.html#method.get_mut +[`Arc::try_unwrap`]: http://doc.rust-lang.org/nightly/alloc/arc/struct.Arc.html#method.try_unwrap +[`Box::from_raw`]: http://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html#method.from_raw +[`Box::into_raw`]: http://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html#method.into_raw +[`CStr::to_str`]: http://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.to_str +[`CStr::to_string_lossy`]: http://doc.rust-lang.org/nightly/std/ffi/struct.CStr.html#method.to_string_lossy +[`CString::from_raw`]: http://doc.rust-lang.org/nightly/std/ffi/struct.CString.html#method.from_raw +[`CString::into_raw`]: http://doc.rust-lang.org/nightly/std/ffi/struct.CString.html#method.into_raw +[`IntoRawFd::into_raw_fd`]: http://doc.rust-lang.org/nightly/std/os/unix/io/trait.IntoRawFd.html#tymethod.into_raw_fd +[`IntoRawFd`]: http://doc.rust-lang.org/nightly/std/os/unix/io/trait.IntoRawFd.html +[`Rc::downgrade`]: http://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.downgrade +[`Rc::get_mut`]: http://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.get_mut +[`Rc::make_mut`]: http://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.make_mut +[`Rc::try_unwrap`]: http://doc.rust-lang.org/nightly/alloc/rc/struct.Rc.html#method.try_unwrap +[`Result::expect`]: http://doc.rust-lang.org/nightly/core/result/enum.Result.html#method.expect +[`String::into_boxed_str`]: http://doc.rust-lang.org/nightly/collections/string/struct.String.html#method.into_boxed_str +[`TcpStream::read_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.read_timeout +[`TcpStream::set_read_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.set_read_timeout +[`TcpStream::write_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.write_timeout +[`TcpStream::set_write_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.set_write_timeout +[`UdpSocket::read_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.read_timeout +[`UdpSocket::set_read_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.set_read_timeout +[`UdpSocket::write_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.write_timeout +[`UdpSocket::set_write_timeout`]: http://doc.rust-lang.org/nightly/std/net/struct.TcpStream.html#method.set_write_timeout +[`VecDeque::append`]: http://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.append +[`VecDeque::retain`]: http://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.retain +[`VecDeque::split_off`]: http://doc.rust-lang.org/nightly/std/collections/struct.VecDeque.html#method.split_off +[`rc::Weak::upgrade`]: http://doc.rust-lang.org/nightly/std/rc/struct.Weak.html#method.upgrade +[`rc::Weak`]: http://doc.rust-lang.org/nightly/std/rc/struct.Weak.html +[`slice::Iter::as_slice`]: http://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#method.as_slice +[`slice::IterMut::into_slice`]: http://doc.rust-lang.org/nightly/std/slice/struct.IterMut.html#method.into_slice +[`str::CharIndices::as_str`]: http://doc.rust-lang.org/nightly/std/str/struct.CharIndices.html#method.as_str +[`str::Chars::as_str`]: http://doc.rust-lang.org/nightly/std/str/struct.Chars.html#method.as_str +[`str::split_at_mut`]: http://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_at_mut +[`str::split_at`]: http://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_at +[`sync::Weak::upgrade`]: http://doc.rust-lang.org/nightly/std/sync/struct.Weak.html#method.upgrade +[`sync::Weak`]: http://doc.rust-lang.org/nightly/std/sync/struct.Weak.html +[`thread::park_timeout`]: http://doc.rust-lang.org/nightly/std/thread/fn.park_timeout.html +[`thread::sleep`]: http://doc.rust-lang.org/nightly/std/thread/fn.sleep.html +[bh2]: https://github.com/rust-lang/rust/pull/28156 +[binfat]: https://github.com/rust-lang/rust/pull/28270 +[bm]: https://github.com/rust-lang/rust/pull/28197 +[cc]: https://github.com/rust-lang/rust/pull/27531 +[crlf]: https://github.com/rust-lang/rust/pull/28034 +[cu]: https://github.com/rust-lang/cargo/pull/1931 +[d]: https://github.com/rust-lang/rust/pull/27825 +[dep]: https://github.com/rust-lang/rust/pull/28339 +[es]: https://github.com/rust-lang/rust/pull/27956 +[ext]: https://github.com/rust-lang/rust/pull/28094 +[faststr]: https://github.com/rust-lang/rust/pull/28338 +[ffi]: https://github.com/rust-lang/rust/pull/28779 +[fp]: https://github.com/rust-lang/rust/pull/28268 +[fp2]: https://github.com/rust-lang/rust/pull/28560 +[fp3]: https://github.com/rust-lang/rust/pull/27307 +[i]: https://github.com/rust-lang/rust/pull/27451 +[into2]: https://github.com/rust-lang/rust/pull/28039 +[it]: https://github.com/rust-lang/rust/pull/27652 +[mm]: https://github.com/rust-lang/rust/pull/27338 +[mutw]: https://github.com/rust-lang/rust/pull/28368 +[sound]: https://github.com/rust-lang/rust/pull/27641 +[p]: https://github.com/rust-lang/rust/pull/27866 +[pec]: https://github.com/rust-lang/rust/pull/28486 +[pr]: https://github.com/rust-lang/rust/pull/27896 +[RFC 839]: https://github.com/rust-lang/rfcs/blob/master/text/0839-embrace-extend-extinguish.md +[RFC 1214]: https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md +[s]: https://github.com/rust-lang/rust/pull/27474 +[stab]: https://github.com/rust-lang/rust/pull/28339 +[stat]: https://github.com/rust-lang/rust/pull/28321 +[vd]: https://github.com/rust-lang/rust/pull/28494 + Version 1.3.0 (2015-09-17) ============================== diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index b74aaef927d88..c693cceeac482 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -1605,14 +1605,11 @@ arguments. ## Writing the logic -We're all different in how we write code, but error handling is -usually the last thing we want to think about. This isn't very good -practice for good design, but it can be useful for rapidly -prototyping. In our case, because Rust forces us to be explicit about -error handling, it will also make it obvious what parts of our program -can cause errors. Why? Because Rust will make us call `unwrap`! This -can give us a nice bird's eye view of how we need to approach error -handling. +We all write code differently, but error handling is usually the last thing we +want to think about. This isn't great for the overall design of a program, but +it can be useful for rapid prototyping. Because Rust forces us to be explicit +about error handling (by making us call `unwrap`), it is easy to see which +parts of our program can cause errors. In this case study, the logic is really simple. All we need to do is parse the CSV data given to us and print out a field in matching rows. Let's do it. (Make diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md index d31d823247082..41c134b29f3d1 100644 --- a/src/doc/trpl/method-syntax.md +++ b/src/doc/trpl/method-syntax.md @@ -43,8 +43,6 @@ fn main() { This will print `12.566371`. - - We’ve made a `struct` that represents a circle. We then write an `impl` block, and inside it, define a method, `area`. @@ -83,6 +81,35 @@ impl Circle { } ``` +You can use as many `impl` blocks as you’d like. The previous example could +have also been written like this: + +```rust +struct Circle { + x: f64, + y: f64, + radius: f64, +} + +impl Circle { + fn reference(&self) { + println!("taking self by reference!"); + } +} + +impl Circle { + fn mutable_reference(&mut self) { + println!("taking self by mutable reference!"); + } +} + +impl Circle { + fn takes_ownership(self) { + println!("taking ownership of self!"); + } +} +``` + # Chaining method calls So, now we know how to call a method, such as `foo.bar()`. But what about our diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index ea4830fc3e6ce..869e7a0b38393 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -732,6 +732,8 @@ impl [T] { /// /// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`. /// + /// This is a stable sort. + /// /// # Examples /// /// ```rust diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f1199919fcb0e..9b260b57099bb 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1565,6 +1565,8 @@ pub trait Iterator { /// as soon as it finds a `false`, given that no matter what else happens, /// the result will also be `false`. /// + /// An empty iterator returns `true`. + /// /// # Examples /// /// Basic usage: @@ -1613,6 +1615,8 @@ pub trait Iterator { /// as soon as it finds a `true`, given that no matter what else happens, /// the result will also be `true`. /// + /// An empty iterator returns `false`. + /// /// # Examples /// /// Basic usage: @@ -2071,6 +2075,8 @@ pub trait Iterator { /// /// Takes each element, adds them together, and returns the result. /// + /// An empty iterator returns the zero value of the type. + /// /// # Examples /// /// Basic usage: @@ -2094,6 +2100,8 @@ pub trait Iterator { /// Iterates over the entire iterator, multiplying all the elements /// + /// An empty iterator returns the one value of the type. + /// /// # Examples /// /// ``` diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index f6baf23b564b0..bdff4f6d3732d 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -382,11 +382,12 @@ mod impls { unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} } -/// A marker trait indicates a type that can be reflected over. This -/// trait is implemented for all types. Its purpose is to ensure that -/// when you write a generic function that will employ reflection, -/// that must be reflected (no pun intended) in the generic bounds of -/// that function. Here is an example: +/// A marker trait indicates a type that can be reflected over. +/// +/// This trait is implemented for all types. Its purpose is to ensure +/// that when you write a generic function that will employ +/// reflection, that must be reflected (no pun intended) in the +/// generic bounds of that function. Here is an example: /// /// ``` /// #![feature(reflect_marker)] diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 7c6add80337c0..965226f6355c2 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -601,6 +601,9 @@ impl HashMap /// Returns the number of elements the map can hold without reallocating. /// + /// This number is a lower bound; the `HashMap` might be able to hold + /// more, but is guaranteed to be able to hold at least this many. + /// /// # Examples /// /// ``` diff --git a/src/test/run-pass/issue-24954.rs b/src/test/run-pass/issue-24954.rs new file mode 100644 index 0000000000000..f525274a1dfca --- /dev/null +++ b/src/test/run-pass/issue-24954.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($y:expr) => ({ + $y = 2; + }) +} + +#[allow(unused_variables)] +#[allow(unused_assignments)] +fn main() { + let mut x = 1; + foo!(x); +}