Auto merge of #32666 - Manishearth:rollup, r=Manishearth

Rollup of 11 pull requests

- Successful merges: #32622, #32629, #32640, #32641, #32642, #32645, #32647, #32649, #32652, #32654, #32656
- Failed merges:
This commit is contained in:
bors 2016-04-01 17:06:04 -07:00
commit 18172d1375
11 changed files with 82 additions and 13 deletions

View File

@ -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

View File

@ -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 users 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 users 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

View File

@ -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.

View File

@ -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>, U: ?Sized> CoerceUnsized<Ref<'b, U>> 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>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {}
/// The core primitive for interior mutability in Rust.
///
/// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the

View File

@ -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

View File

@ -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);
}
}

View File

@ -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<T>(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<T: fmt::Debug>(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##"

View File

@ -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,

View File

@ -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

View File

@ -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;
}

View File

@ -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