Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 17 pull requests #50807

Merged
merged 46 commits into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1133a14
Implement From for more types on Cow
burtonageo Apr 22, 2018
ea8131d
Add cstring_from_cow_cstr and osstring_from_cow_osstr
burtonageo Apr 27, 2018
d87b039
Add pathbuf_from_cow_path
burtonageo Apr 27, 2018
f3e858a
Update the stable attributes to use the current nightly version number
burtonageo Apr 27, 2018
17e2628
Update features to 1.28.0
burtonageo May 9, 2018
7c0f664
Fix typo
burtonageo May 9, 2018
587566e
Fix `fn main() -> impl Trait` for non-`Termination` trait
leoyvens May 11, 2018
56f505e
read2: Use inner function instead of closure
udoprog May 14, 2018
f73c4a4
env: remove unwrap in examples in favor of try op
udoprog May 14, 2018
6d1da82
Don't unconditionally set CLOEXEC twice on every fd we open on Linux
tbu- May 14, 2018
f46b888
Remove LazyBTreeMap.
nnethercote May 14, 2018
9415adc
deprecate #![doc(no_default_passes, passes, plugins)]
QuietMisdreavus Apr 20, 2018
bb6224b
add ui test for rustdoc's deprecated attributes
QuietMisdreavus Apr 23, 2018
10ac995
drop unnecessary "warning" from warning text
QuietMisdreavus May 14, 2018
30d9502
Add missing error codes in libsyntax-ext asm
GuillaumeGomez May 14, 2018
ba2b4b1
Make mutable_noalias and arg_align_attributes be tracked
nox May 15, 2018
0582d02
Rename ret_ty to declared_ret_ty
leoyvens May 15, 2018
a90a963
Fix run-make wasm tests
ehuss May 15, 2018
a4224eb
Fix an ICE when casting a nonexistent const
varkor May 15, 2018
e8e5eb5
Ensure libraries built in stage0 have unique metadata
cuviper May 16, 2018
7eefe2b
Fix rustdoc panic with `impl Trait` in type parameters
sinkuu May 14, 2018
a2896bf
fix a typo in signed-integer::from_str_radix()
shamiao May 16, 2018
d623f45
Rollup merge of #50638 - tbu-:pr_open_cloexec_once, r=nagisa
kennytm May 16, 2018
5cc6fd3
Rollup merge of #50656 - leodasvacas:fix-impl-trait-in-main-ret, r=ni…
kennytm May 16, 2018
5074a7e
Rollup merge of #50669 - QuietMisdreavus:deprecated-attrs, r=Guillaum…
kennytm May 16, 2018
2d46b90
GitHub: Stop treating Cargo.lock as a generated file.
kennytm May 16, 2018
ee85bfd
Make core::nonzero private
SimonSapin Feb 16, 2018
c536639
Remove unstable deprecated num::NonZeroI* types
SimonSapin Mar 24, 2018
89d9ca9
Stabilize num::NonZeroU*
SimonSapin May 16, 2018
5c10185
tidy: Add a check for empty UI test files
yaahc May 16, 2018
16adb0c
Remove empty files
yaahc May 16, 2018
6ed200a
Remove empty file introduced by rebase
yaahc May 16, 2018
fc6c08e
Rollup merge of #50726 - udoprog:read2-inner-fn, r=alexcrichton
kennytm May 16, 2018
539a376
Rollup merge of #50728 - sinkuu:fix_50702, r=GuillaumeGomez
kennytm May 16, 2018
06e6173
Rollup merge of #50736 - udoprog:env-try-op, r=shepmaster
kennytm May 16, 2018
bb20dc1
Rollup merge of #50740 - nnethercote:rm-LazyBTreeMap, r=cramertj
kennytm May 16, 2018
39129a5
Rollup merge of #50752 - GuillaumeGomez:more-error-code-in-libsyntax-…
kennytm May 16, 2018
380066b
Rollup merge of #50779 - nox:untracked-options, r=rkruppe
kennytm May 16, 2018
9ced69d
Rollup merge of #50787 - ehuss:fix-run-make-wasm, r=alexcrichton
kennytm May 16, 2018
d3bf721
Rollup merge of #50788 - varkor:missing-const-cast, r=cramertj
kennytm May 16, 2018
e4f8132
Rollup merge of #50789 - cuviper:bootstrap-metadata, r=alexcrichton
kennytm May 16, 2018
0306630
Rollup merge of #50797 - shamiao:patch-1, r=kennytm
kennytm May 16, 2018
63ea42f
Rollup merge of #50793 - jrlusby:master, r=petrochenkov
kennytm May 16, 2018
02aedec
Rollup merge of #50808 - SimonSapin:nonzero, r=alexcrichton
kennytm May 16, 2018
8366780
Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichton
kennytm May 16, 2018
3c261a4
Rollup merge of #50809 - kennytm:show-cargo-lock-diff, r=alexcrichton
kennytm May 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
src/etc/installer/gfx/* binary
*.woff binary
src/vendor/** -text
Cargo.lock -merge
Cargo.lock -merge linguist-generated=false
10 changes: 9 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,15 @@ impl<'a> Builder<'a> {

// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005
// Force cargo to output binaries with disambiguating hashes in the name
cargo.env("__CARGO_DEFAULT_LIB_METADATA", &self.config.channel);
let metadata = if compiler.stage == 0 {
// Treat stage0 like special channel, whether it's a normal prior-
// release rustc or a local rebuild with the same version, so we
// never mix these libraries by accident.
"bootstrap"
} else {
&self.config.channel
};
cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata);

let stage;
if compiler.stage == 0 && self.local_rebuild {
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ test!(RunFailFullDepsPretty {
host: true
});

host_test!(RunMake {
default_test!(RunMake {
path: "src/test/run-make",
mode: "run-make",
suite: "run-make"
Expand Down Expand Up @@ -1041,7 +1041,7 @@ impl Step for Compiletest {

// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if !builder.config.dry_run && mode == "run-make" {
if !builder.config.dry_run && suite == "run-make-fulldeps" {
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
cmd.arg("--cc").arg(builder.cc(target))
Expand All @@ -1054,13 +1054,13 @@ impl Step for Compiletest {
}
}
}
if mode == "run-make" && !builder.config.llvm_enabled {
if suite == "run-make-fulldeps" && !builder.config.llvm_enabled {
builder.info(
&format!("Ignoring run-make test suite as they generally don't work without LLVM"));
return;
}

if mode != "run-make" {
if suite != "run-make-fulldeps" {
cmd.arg("--cc").arg("")
.arg("--cxx").arg("")
.arg("--cflags").arg("")
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
#![feature(lang_items)]
#![feature(libc)]
#![feature(needs_allocator)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
#![feature(pin)]
Expand Down
8 changes: 8 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,14 @@ impl<'a> From<String> for Cow<'a, str> {
}
}

#[stable(feature = "cow_from_string_ref", since = "1.28.0")]
impl<'a> From<&'a String> for Cow<'a, str> {
#[inline]
fn from(s: &'a String) -> Cow<'a, str> {
Cow::Borrowed(s.as_str())
}
}

#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
impl<'a> FromIterator<char> for Cow<'a, str> {
fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> {
Expand Down
7 changes: 7 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,13 @@ impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
}
}

#[stable(feature = "cow_from_vec_ref", since = "1.28.0")]
impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
Cow::Borrowed(v.as_slice())
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ pub mod prelude;

pub mod intrinsics;
pub mod mem;
pub mod nonzero;
pub mod ptr;
pub mod hint;

Expand Down Expand Up @@ -221,6 +220,7 @@ pub mod heap {

// note: does not need to be public
mod iter_private;
mod nonzero;
mod tuple;
mod unit;

Expand Down
96 changes: 3 additions & 93 deletions src/libcore/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,103 +9,13 @@
// except according to those terms.

//! Exposes the NonZero lang item which provides optimization hints.
#![unstable(feature = "nonzero", reason = "deprecated", issue = "49137")]
#![rustc_deprecated(reason = "use `std::ptr::NonNull` or `std::num::NonZero*` instead",
since = "1.26.0")]
#![allow(deprecated)]

use ops::CoerceUnsized;

/// Unsafe trait to indicate what types are usable with the NonZero struct
pub unsafe trait Zeroable {
/// Whether this value is zero
fn is_zero(&self) -> bool;
}

macro_rules! impl_zeroable_for_pointer_types {
( $( $Ptr: ty )+ ) => {
$(
/// For fat pointers to be considered "zero", only the "data" part needs to be null.
unsafe impl<T: ?Sized> Zeroable for $Ptr {
#[inline]
fn is_zero(&self) -> bool {
(*self).is_null()
}
}
)+
}
}

macro_rules! impl_zeroable_for_integer_types {
( $( $Int: ty )+ ) => {
$(
unsafe impl Zeroable for $Int {
#[inline]
fn is_zero(&self) -> bool {
*self == 0
}
}
)+
}
}

impl_zeroable_for_pointer_types! {
*const T
*mut T
}

impl_zeroable_for_integer_types! {
usize u8 u16 u32 u64 u128
isize i8 i16 i32 i64 i128
}

/// A wrapper type for raw pointers and integers that will never be
/// NULL or 0 that might allow certain optimizations.
#[lang = "non_zero"]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
pub struct NonZero<T: Zeroable>(pub(crate) T);

impl<T: Zeroable> NonZero<T> {
/// Creates an instance of NonZero with the provided value.
/// You must indeed ensure that the value is actually "non-zero".
#[inline]
pub const unsafe fn new_unchecked(inner: T) -> Self {
NonZero(inner)
}

/// Creates an instance of NonZero with the provided value.
#[inline]
pub fn new(inner: T) -> Option<Self> {
if inner.is_zero() {
None
} else {
Some(NonZero(inner))
}
}

/// Gets the inner value.
pub fn get(self) -> T {
self.0
}
}

impl<T: Zeroable+CoerceUnsized<U>, U: Zeroable> CoerceUnsized<NonZero<U>> for NonZero<T> {}

impl<'a, T: ?Sized> From<&'a mut T> for NonZero<*mut T> {
fn from(reference: &'a mut T) -> Self {
NonZero(reference)
}
}

impl<'a, T: ?Sized> From<&'a mut T> for NonZero<*const T> {
fn from(reference: &'a mut T) -> Self {
let ptr: *mut T = reference;
NonZero(ptr)
}
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub(crate) struct NonZero<T>(pub(crate) T);

impl<'a, T: ?Sized> From<&'a T> for NonZero<*const T> {
fn from(reference: &'a T) -> Self {
NonZero(reference)
}
}
impl<T: CoerceUnsized<U>, U> CoerceUnsized<NonZero<U>> for NonZero<T> {}
38 changes: 9 additions & 29 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ use convert::TryFrom;
use fmt;
use intrinsics;
use mem;
#[allow(deprecated)] use nonzero::NonZero;
use nonzero::NonZero;
use ops;
use str::FromStr;

macro_rules! impl_nonzero_fmt {
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
( ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
$(
#[$stability]
#[allow(deprecated)]
#[stable(feature = "nonzero", since = "1.28.0")]
impl fmt::$Trait for $Ty {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand All @@ -36,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
}

macro_rules! nonzero_integers {
( #[$stability: meta] #[$deprecation: meta] $( $Ty: ident($Int: ty); )+ ) => {
( $( $Ty: ident($Int: ty); )+ ) => {
$(
/// An integer that is known not to equal zero.
///
Expand All @@ -47,27 +46,24 @@ macro_rules! nonzero_integers {
/// use std::mem::size_of;
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
/// ```
#[$stability]
#[$deprecation]
#[allow(deprecated)]
#[stable(feature = "nonzero", since = "1.28.0")]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct $Ty(NonZero<$Int>);

#[allow(deprecated)]
impl $Ty {
/// Create a non-zero without checking the value.
///
/// # Safety
///
/// The value must not be zero.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub const unsafe fn new_unchecked(n: $Int) -> Self {
$Ty(NonZero(n))
}

/// Create a non-zero if the given value is not zero.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn new(n: $Int) -> Option<Self> {
if n != 0 {
Expand All @@ -78,7 +74,7 @@ macro_rules! nonzero_integers {
}

/// Returns the value as a primitive type.
#[$stability]
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn get(self) -> $Int {
self.0 .0
Expand All @@ -87,16 +83,13 @@ macro_rules! nonzero_integers {
}

impl_nonzero_fmt! {
#[$stability]
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
}
)+
}
}

nonzero_integers! {
#[unstable(feature = "nonzero", issue = "49137")]
#[allow(deprecated)] // Redundant, works around "error: inconsistent lockstep iteration"
NonZeroU8(u8);
NonZeroU16(u16);
NonZeroU32(u32);
Expand All @@ -105,19 +98,6 @@ nonzero_integers! {
NonZeroUsize(usize);
}

nonzero_integers! {
#[unstable(feature = "nonzero", issue = "49137")]
#[rustc_deprecated(since = "1.26.0", reason = "\
signed non-zero integers are considered for removal due to lack of known use cases. \
If you’re using them, please comment on https://github.com/rust-lang/rust/issues/49137")]
NonZeroI8(i8);
NonZeroI16(i16);
NonZeroI32(i32);
NonZeroI64(i64);
NonZeroI128(i128);
NonZeroIsize(isize);
}

/// Provides intentionally-wrapped arithmetic on `T`.
///
/// Operations like `+` on `u32` values is intended to never overflow,
Expand Down Expand Up @@ -252,7 +232,7 @@ depending on `radix`:

* `0-9`
* `a-z`
* `a-z`
* `A-Z`

# Panics

Expand Down
Loading