From d93fb02a5eb84874db012bb216982932029633f7 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 30 Mar 2016 16:59:38 -0700 Subject: [PATCH 01/12] Update Rust version in the Rustonomicon Vec chapter I verified that the final code compiles in Rust 1.9.0-nightly. --- src/doc/nomicon/vec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/nomicon/vec.md b/src/doc/nomicon/vec.md index 63f83788c4b..691301946de 100644 --- a/src/doc/nomicon/vec.md +++ b/src/doc/nomicon/vec.md @@ -2,7 +2,7 @@ To bring everything together, we're going to write `std::Vec` from scratch. Because all the best tools for writing unsafe code are unstable, this -project will only work on nightly (as of Rust 1.2.0). With the exception of the +project will only work on nightly (as of Rust 1.9.0). With the exception of the allocator API, much of the unstable code we'll use is expected to be stabilized in a similar form as it is today. From 0b0af5847fa467d37ca8629dfaa30478a26f2e1e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 30 Mar 2016 13:25:02 +0000 Subject: [PATCH 02/12] Register new FreeBSD snapshot Actual file is at https://people.freebsd.org/~asomers/rust/rust-stage0-2016-03-18-235d774-freebsd-x86_64-390b9a9f60f3d0d6a52c04d939a0355f572d03b3.tar.bz2 --- src/snapshots.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/snapshots.txt b/src/snapshots.txt index 200ea97880b..d1a2ab464cb 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -6,6 +6,7 @@ S 2016-03-18 235d774 winnt-i386 7703869608cc4192b8f1943e51b19ba1a03c0110 winnt-x86_64 8512b5ecc0c53a2cd3552e4f5688577de95cd978 openbsd-x86_64 c5b6feda38138a12cd5c05574b585dadebbb5e87 + freebsd-x86_64 390b9a9f60f3d0d6a52c04d939a0355f572d03b3 S 2016-02-17 4d3eebf linux-i386 5f194aa7628c0703f0fd48adc4ec7f3cc64b98c7 From 5428e6e27306519c9957c8f3c448c63b7fef3a06 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 31 Mar 2016 06:22:12 +0000 Subject: [PATCH 03/12] Remove accidental `println!` --- src/librustc_typeck/check/method/suggest.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index aae7912cace..45fe51239a8 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -41,7 +41,6 @@ use super::probe::Mode; fn is_fn_ty<'a, 'tcx>(ty: &Ty<'tcx>, fcx: &FnCtxt<'a, 'tcx>, span: Span) -> bool { let cx = fcx.tcx(); - println!("{:?}", ty); match ty.sty { // Not all of these (e.g. unsafe fns) implement FnOnce // so we look for these beforehand From 823f239ae581f66d73c8239566aa837b713ef210 Mon Sep 17 00:00:00 2001 From: David AO Lozano Date: Wed, 30 Mar 2016 13:45:06 -0600 Subject: [PATCH 04/12] =?UTF-8?q?Book:=20in=20beginner=20guide=20change=20?= =?UTF-8?q?irc=20channel=20#rust=20=E2=86=92=20#rust-beginners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/doc/book/getting-started.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index 16c43b5e7a5..397218d5946 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -164,13 +164,13 @@ installed. Doing so will depend on your specific system, consult its documentation for more details. If not, there are a number of places where we can get help. The easiest is -[the #rust IRC channel on irc.mozilla.org][irc], which we can access through +[the #rust-beginners IRC channel on irc.mozilla.org][irc], which we can access through [Mibbit][mibbit]. Click that link, and we'll be chatting with other Rustaceans (a silly nickname we call ourselves) who can help us out. Other great resources include [the user’s forum][users], and [Stack Overflow][stackoverflow]. -[irc]: irc://irc.mozilla.org/#rust -[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust +[irc]: irc://irc.mozilla.org/#rust-begginers +[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners [users]: https://users.rust-lang.org/ [stackoverflow]: http://stackoverflow.com/questions/tagged/rust From 90d7440f5402e54cd4453f9ba8cb83559508c25e Mon Sep 17 00:00:00 2001 From: David AO Lozano Date: Wed, 30 Mar 2016 13:55:25 -0600 Subject: [PATCH 05/12] Misspelled beginners in one place --- src/doc/book/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index 397218d5946..700323c4a98 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -169,7 +169,7 @@ If not, there are a number of places where we can get help. The easiest is (a silly nickname we call ourselves) who can help us out. Other great resources include [the user’s forum][users], and [Stack Overflow][stackoverflow]. -[irc]: irc://irc.mozilla.org/#rust-begginers +[irc]: irc://irc.mozilla.org/#rust-beginners [mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners [users]: https://users.rust-lang.org/ [stackoverflow]: http://stackoverflow.com/questions/tagged/rust From c233f2ee29e7be75411975473db232952f7489df Mon Sep 17 00:00:00 2001 From: David AO Lozano Date: Wed, 30 Mar 2016 20:07:53 -0600 Subject: [PATCH 06/12] Adding #rust-beginners to README and pointing the two channels on getting-started --- README.md | 3 ++- src/doc/book/getting-started.md | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2298aeb2fdd..1acf5fd1f3d 100644 --- a/README.md +++ b/README.md @@ -177,10 +177,11 @@ To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md). Rust has an [IRC] culture and most real-time collaboration happens in a variety of channels on Mozilla's IRC network, irc.mozilla.org. The most popular channel is [#rust], a venue for general discussion about -Rust, and a good place to ask for help. +Rust. And a good place to ask for help would be [#rust-beginners]. [IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat [#rust]: irc://irc.mozilla.org/rust +[#rust-beginners]: irc://irc.mozilla.org/rust-beginners ## License diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index 700323c4a98..bedc24443ac 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -164,13 +164,17 @@ installed. Doing so will depend on your specific system, consult its documentation for more details. If not, there are a number of places where we can get help. The easiest is -[the #rust-beginners IRC channel on irc.mozilla.org][irc], which we can access through -[Mibbit][mibbit]. Click that link, and we'll be chatting with other Rustaceans -(a silly nickname we call ourselves) who can help us out. Other great resources -include [the user’s forum][users], and [Stack Overflow][stackoverflow]. +[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners], which we +can access through [Mibbit][mibbit-beginners] and for general discussion +[the #rust IRC channel on irc.mozilla.org][irc], which we can access through +[Mibbit][mibbit]. Then we'll be chatting with other Rustaceans (a silly +nickname we call ourselves) who can help us out. Other great resources include +[the user’s forum][users], and [Stack Overflow][stackoverflow]. -[irc]: irc://irc.mozilla.org/#rust-beginners -[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners +[irc-beginners]: irc://irc.mozilla.org/#rust-beginners +[mibbit-beginners]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners +[irc]: irc://irc.mozilla.org/#rust +[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust [users]: https://users.rust-lang.org/ [stackoverflow]: http://stackoverflow.com/questions/tagged/rust From 9094935b460975b6fac272ebf5985dfd71b90104 Mon Sep 17 00:00:00 2001 From: David AO Lozano Date: Thu, 31 Mar 2016 00:37:37 -0600 Subject: [PATCH 07/12] Using only one Mibbit link for access the two channels --- src/doc/book/getting-started.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index bedc24443ac..16141d936eb 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -164,17 +164,15 @@ installed. Doing so will depend on your specific system, consult its documentation for more details. If not, there are a number of places where we can get help. The easiest is -[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners], which we -can access through [Mibbit][mibbit-beginners] and for general discussion -[the #rust IRC channel on irc.mozilla.org][irc], which we can access through -[Mibbit][mibbit]. Then we'll be chatting with other Rustaceans (a silly -nickname we call ourselves) who can help us out. Other great resources include -[the user’s forum][users], and [Stack Overflow][stackoverflow]. +[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners] and for +general discussion [the #rust IRC channel on irc.mozilla.org][irc], which we +can access through [Mibbit][mibbit]. Then we'll be chatting with other +Rustaceans (a silly nickname we call ourselves) who can help us out. Other great +resources include [the user’s forum][users] and [Stack Overflow][stackoverflow]. [irc-beginners]: irc://irc.mozilla.org/#rust-beginners -[mibbit-beginners]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners [irc]: irc://irc.mozilla.org/#rust -[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust +[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners,%23rust [users]: https://users.rust-lang.org/ [stackoverflow]: http://stackoverflow.com/questions/tagged/rust From 10caca24f0052a033cac648884d2393125bc24a3 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Thu, 31 Mar 2016 11:15:36 +0200 Subject: [PATCH 08/12] Improve E0277 error message in a generic context This now mentions that you can restrict type parameters to be able to call functions of traits. --- src/librustc/diagnostics.rs | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 117b1119c0a..6f06efd0f9f 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1033,6 +1033,47 @@ fn main() { some_func(5i32); // ok! } ``` + +Or in a generic context, an erroneous code example would look like: +```compile_fail +fn some_func(foo: T) { + println!("{:?}", foo); // error: the trait `core::fmt::Debug` is not + // implemented for the type `T` +} + +fn main() { + // We now call the method with the i32 type, + // which *does* implement the Debug trait. + some_func(5i32); +} +``` + +Note that the error here is in the definition of the generic function: Although +we only call it with a parameter that does implement `Debug`, the compiler +still rejects the function: It must work with all possible input types. In +order to make this example compile, we need to restrict the generic type we're +accepting: +``` +use std::fmt; + +// Restrict the input type to types that implement Debug. +fn some_func(foo: T) { + println!("{:?}", foo); +} + +fn main() { + // Calling the method is still fine, as i32 implements Debug. + some_func(5i32); + + // This would fail to compile now: + // struct WithoutDebug; + // some_func(WithoutDebug); +} + +Rust only looks at the signature of the called function, as such it must +already specify all requirements that will be used for every type parameter. +``` + "##, E0281: r##" From e72c8fb754658b5d0cfcefbd1443d9d0911f244e Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 31 Mar 2016 13:13:53 +0100 Subject: [PATCH 09/12] Fix formatting in the documentation for AtomicIsize::compare_exchange_weak --- src/libcore/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 7ae129eaf48..d2e98a795d9 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -695,7 +695,7 @@ impl AtomicIsize { unsafe { atomic_compare_exchange(self.v.get(), current, new, success, failure) } } - /// Stores a value into the `isize if the current value is the same as the `current` value. + /// Stores a value into the `isize` if the current value is the same as the `current` value. /// /// Unlike `compare_exchange`, this function is allowed to spuriously fail even when the /// comparison succeeds, which can result in more efficient code on some platforms. The From 33db2d65ffd5b988fdedc8ed91b395abaa57f777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D0=BB=D0=B5=D1=80=D0=B8=D0=B9=20=D0=9B=D0=B0?= =?UTF-8?q?=D1=88=D0=BC=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Thu, 31 Mar 2016 10:11:59 -0400 Subject: [PATCH 10/12] added missing refcell ref/refmut coercions to unsized --- src/libcore/cell.rs | 10 ++++++++-- src/libcoretest/cell.rs | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index fdd2e3a1784..aa02d982b52 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -147,8 +147,8 @@ use clone::Clone; use cmp::{PartialEq, Eq}; use default::Default; -use marker::{Copy, Send, Sync, Sized}; -use ops::{Deref, DerefMut, Drop, FnOnce}; +use marker::{Copy, Send, Sync, Sized, Unsize}; +use ops::{Deref, DerefMut, Drop, FnOnce, CoerceUnsized}; use option::Option; use option::Option::{None, Some}; @@ -638,6 +638,9 @@ impl<'b, T: ?Sized> Ref<'b, T> { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for Ref<'b, T> {} + impl<'b, T: ?Sized> RefMut<'b, T> { /// Make a new `RefMut` for a component of the borrowed data, e.g. an enum /// variant. @@ -770,6 +773,9 @@ impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { } } +#[unstable(feature = "coerce_unsized", issue = "27732")] +impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefMut<'b, T> {} + /// The core primitive for interior mutability in Rust. /// /// `UnsafeCell` is a type that wraps some `T` and indicates unsafe interior operations on the diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index cafffb5266f..c0b22274ee9 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -261,3 +261,23 @@ fn refcell_unsized() { let comp: &mut [i32] = &mut [4, 2, 5]; assert_eq!(&*cell.borrow(), comp); } + +#[test] +fn refcell_ref_coercion() { + let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]); + { + let mut cellref: RefMut<[i32; 3]> = cell.borrow_mut(); + cellref[0] = 4; + let mut coerced: RefMut<[i32]> = cellref; + coerced[2] = 5; + } + { + let comp: &mut [i32] = &mut [4, 2, 5]; + let cellref: Ref<[i32; 3]> = cell.borrow(); + assert_eq!(&*cellref, comp); + let coerced: Ref<[i32]> = cellref; + assert_eq!(&*coerced, comp); + } +} + + From 28e45bb96a2d6e956cc2e8cd1a8686a3de97eb25 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Thu, 31 Mar 2016 19:28:06 +0200 Subject: [PATCH 11/12] Fix a typo in the doc comment of `std::os::unix::thread::JoinHandleExt` --- src/libstd/sys/unix/ext/thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/ext/thread.rs b/src/libstd/sys/unix/ext/thread.rs index bb8200ff859..c98e42faba7 100644 --- a/src/libstd/sys/unix/ext/thread.rs +++ b/src/libstd/sys/unix/ext/thread.rs @@ -30,7 +30,7 @@ pub trait JoinHandleExt { /// /// This function **transfers ownership** of the underlying pthread_t to /// the caller. Callers are then the unique owners of the pthread_t and - /// must either detech or join the pthread_t once it's no longer needed. + /// must either detach or join the pthread_t once it's no longer needed. fn into_pthread_t(self) -> RawPthread; } From 0872cc37bccd3573f0e6118e7e792f943ce2a432 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Thu, 31 Mar 2016 21:19:17 +0200 Subject: [PATCH 12/12] Remove incorrect comment about `PartialEq` implementation --- src/librustc_front/hir.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index cd8fb09406e..86f8635f58d 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -931,7 +931,6 @@ pub struct TypeBinding { } -// NB PartialEq method appears below. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub struct Ty { pub id: NodeId,