diff --git a/README.md b/README.md index 2298aeb2fdd45..1acf5fd1f3df8 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 16c43b5e7a569..16141d936ebcc 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -164,13 +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 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] 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 [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 diff --git a/src/doc/nomicon/vec.md b/src/doc/nomicon/vec.md index 63f83788c4bac..691301946de4b 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. diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 4a9a148506343..b2cbc29b1c74c 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}; @@ -634,6 +634,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. @@ -766,6 +769,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/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 7ae129eaf4878..d2e98a795d935 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 diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index cafffb5266f91..c0b22274ee9d6 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); + } +} + + diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 117b1119c0a99..6f06efd0f9f26 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##" diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index cd8fb09406e47..86f8635f58d9a 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, diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index f1d67883117ec..4d806bda48426 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 diff --git a/src/libstd/sys/unix/ext/thread.rs b/src/libstd/sys/unix/ext/thread.rs index bb8200ff8597a..c98e42faba7c2 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; } diff --git a/src/snapshots.txt b/src/snapshots.txt index 200ea97880be6..d1a2ab464cba7 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