Auto merge of #29883 - Manishearth:rollup, r=Manishearth
- Successful merges: #29868, #29873, #29874, #29875, #29876, #29880, #29881 - Failed merges:
This commit is contained in:
commit
c61e8fd61a
11 changed files with 49 additions and 25 deletions
|
@ -14,7 +14,7 @@
|
||||||
# would create a variable HOST_i686-darwin-macos with the value
|
# would create a variable HOST_i686-darwin-macos with the value
|
||||||
# i386.
|
# i386.
|
||||||
define DEF_HOST_VAR
|
define DEF_HOST_VAR
|
||||||
HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1))))
|
HOST_$(1) = $(patsubst i%86,i386,$(word 1,$(subst -, ,$(1))))
|
||||||
endef
|
endef
|
||||||
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t))))
|
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t))))
|
||||||
$(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t))))
|
$(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t))))
|
||||||
|
|
|
@ -32,6 +32,5 @@ Within a function, bounding lifetimes is more error-prone. The safest and easies
|
||||||
way to bound a lifetime is to return it from a function with a bound lifetime.
|
way to bound a lifetime is to return it from a function with a bound lifetime.
|
||||||
However if this is unacceptable, the reference can be placed in a location with
|
However if this is unacceptable, the reference can be placed in a location with
|
||||||
a specific lifetime. Unfortunately it's impossible to name all lifetimes involved
|
a specific lifetime. Unfortunately it's impossible to name all lifetimes involved
|
||||||
in a function. To get around this, you can in principle use `copy_lifetime`, though
|
in a function.
|
||||||
these are unstable due to their awkward nature and questionable utility.
|
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ fn change_truth(x: bool) -> bool {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If we would have used types that do not implement the `Copy` trait,
|
If we had used types that do not implement the `Copy` trait,
|
||||||
we would have gotten a compile error because we tried to use a moved value.
|
we would have gotten a compile error because we tried to use a moved value.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|
|
@ -109,19 +109,28 @@ Here’s an example of using the longer form.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fn clone(&self);
|
fn foo() -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct Bar;
|
struct Bar;
|
||||||
|
|
||||||
impl Foo for Bar {
|
impl Bar {
|
||||||
fn clone(&self) {
|
fn foo() -> i32 {
|
||||||
println!("Making a clone of Bar");
|
20
|
||||||
|
|
||||||
<Bar as Clone>::clone(self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Foo for Bar {
|
||||||
|
fn foo() -> i32 {
|
||||||
|
10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
assert_eq!(10, <Bar as Foo>::foo());
|
||||||
|
assert_eq!(20, Bar::foo());
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s.
|
Using the angle bracket syntax lets you call the trait method instead of the
|
||||||
|
inherent one.
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
use marker::Sized;
|
use marker::Sized;
|
||||||
|
|
||||||
/// A common trait for cloning an object.
|
/// A common trait for cloning an object.
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait Clone : Sized {
|
pub trait Clone : Sized {
|
||||||
/// Returns a copy of the value.
|
/// Returns a copy of the value.
|
||||||
|
|
|
@ -43,6 +43,8 @@ use option::Option::{self, Some};
|
||||||
/// in terms of it by default. Any manual implementation of `ne` *must* respect
|
/// in terms of it by default. Any manual implementation of `ne` *must* respect
|
||||||
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
|
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
|
||||||
/// only if `a != b`.
|
/// only if `a != b`.
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[lang = "eq"]
|
#[lang = "eq"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait PartialEq<Rhs: ?Sized = Self> {
|
pub trait PartialEq<Rhs: ?Sized = Self> {
|
||||||
|
@ -69,6 +71,8 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
|
||||||
///
|
///
|
||||||
/// This property cannot be checked by the compiler, and therefore `Eq` implies
|
/// This property cannot be checked by the compiler, and therefore `Eq` implies
|
||||||
/// `PartialEq`, and has no extra methods.
|
/// `PartialEq`, and has no extra methods.
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait Eq: PartialEq<Self> {
|
pub trait Eq: PartialEq<Self> {
|
||||||
// FIXME #13101: this method is used solely by #[deriving] to
|
// FIXME #13101: this method is used solely by #[deriving] to
|
||||||
|
@ -171,6 +175,8 @@ impl Ordering {
|
||||||
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
|
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
|
||||||
///
|
///
|
||||||
/// When this trait is `derive`d, it produces a lexicographic ordering.
|
/// When this trait is `derive`d, it produces a lexicographic ordering.
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait Ord: Eq + PartialOrd<Self> {
|
pub trait Ord: Eq + PartialOrd<Self> {
|
||||||
/// This method returns an `Ordering` between `self` and `other`.
|
/// This method returns an `Ordering` between `self` and `other`.
|
||||||
|
@ -227,6 +233,8 @@ impl PartialOrd for Ordering {
|
||||||
/// However it remains possible to implement the others separately for types which do not have a
|
/// However it remains possible to implement the others separately for types which do not have a
|
||||||
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
|
/// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 ==
|
||||||
/// false` (cf. IEEE 754-2008 section 5.11).
|
/// false` (cf. IEEE 754-2008 section 5.11).
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[lang = "ord"]
|
#[lang = "ord"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
|
||||||
|
|
|
@ -300,6 +300,8 @@ impl<'a> Display for Arguments<'a> {
|
||||||
///
|
///
|
||||||
/// [module]: ../../std/fmt/index.html
|
/// [module]: ../../std/fmt/index.html
|
||||||
///
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// Deriving an implementation:
|
/// Deriving an implementation:
|
||||||
|
|
|
@ -93,6 +93,8 @@ mod sip;
|
||||||
///
|
///
|
||||||
/// In other words, if two keys are equal, their hashes should also be equal.
|
/// In other words, if two keys are equal, their hashes should also be equal.
|
||||||
/// `HashMap` and `HashSet` both rely on this behavior.
|
/// `HashMap` and `HashSet` both rely on this behavior.
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub trait Hash {
|
pub trait Hash {
|
||||||
/// Feeds this value into the state given, updating the hasher as necessary.
|
/// Feeds this value into the state given, updating the hasher as necessary.
|
||||||
|
|
|
@ -165,6 +165,10 @@ pub trait Unsize<T: ?Sized> {
|
||||||
/// to consider though: if you think your type may _not_ be able to implement `Copy` in the future,
|
/// to consider though: if you think your type may _not_ be able to implement `Copy` in the future,
|
||||||
/// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking
|
/// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking
|
||||||
/// change: that second example would fail to compile if we made `Foo` non-`Copy`.
|
/// change: that second example would fail to compile if we made `Foo` non-`Copy`.
|
||||||
|
///
|
||||||
|
/// # Derivable
|
||||||
|
///
|
||||||
|
/// This trait can be used with `#[derive]`.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[lang = "copy"]
|
#[lang = "copy"]
|
||||||
pub trait Copy : Clone {
|
pub trait Copy : Clone {
|
||||||
|
|
|
@ -167,22 +167,20 @@ impl StdError for JoinPathsError {
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
pub fn current_exe() -> io::Result<PathBuf> {
|
pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
unsafe {
|
unsafe {
|
||||||
use libc::funcs::bsd44::*;
|
let mut mib = [libc::CTL_KERN as c_int,
|
||||||
use libc::consts::os::extra::*;
|
libc::KERN_PROC as c_int,
|
||||||
let mut mib = [CTL_KERN as c_int,
|
libc::KERN_PROC_PATHNAME as c_int,
|
||||||
KERN_PROC as c_int,
|
|
||||||
KERN_PROC_PATHNAME as c_int,
|
|
||||||
-1 as c_int];
|
-1 as c_int];
|
||||||
let mut sz: libc::size_t = 0;
|
let mut sz: libc::size_t = 0;
|
||||||
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
|
let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
|
||||||
ptr::null_mut(), &mut sz, ptr::null_mut(),
|
ptr::null_mut(), &mut sz, ptr::null_mut(),
|
||||||
0 as libc::size_t);
|
0 as libc::size_t);
|
||||||
if err != 0 { return Err(io::Error::last_os_error()); }
|
if err != 0 { return Err(io::Error::last_os_error()); }
|
||||||
if sz == 0 { return Err(io::Error::last_os_error()); }
|
if sz == 0 { return Err(io::Error::last_os_error()); }
|
||||||
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
|
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
|
||||||
let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
|
let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
|
||||||
v.as_mut_ptr() as *mut libc::c_void, &mut sz,
|
v.as_mut_ptr() as *mut libc::c_void, &mut sz,
|
||||||
ptr::null_mut(), 0 as libc::size_t);
|
ptr::null_mut(), 0 as libc::size_t);
|
||||||
if err != 0 { return Err(io::Error::last_os_error()); }
|
if err != 0 { return Err(io::Error::last_os_error()); }
|
||||||
if sz == 0 { return Err(io::Error::last_os_error()); }
|
if sz == 0 { return Err(io::Error::last_os_error()); }
|
||||||
v.set_len(sz as usize - 1); // chop off trailing NUL
|
v.set_len(sz as usize - 1); // chop off trailing NUL
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_mir(graphviz="comparefoo.gv")]
|
#[rustc_mir]
|
||||||
fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults {
|
fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults {
|
||||||
ComparisonResults {
|
ComparisonResults {
|
||||||
lt: a < b,
|
lt: a < b,
|
||||||
|
@ -88,7 +88,7 @@ fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_mir(graphviz="simpleeq.gv")]
|
#[rustc_mir]
|
||||||
fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool {
|
fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool {
|
||||||
let result = a == b;
|
let result = a == b;
|
||||||
result
|
result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue