Skip to content

Commit b559710

Browse files
committed
Auto merge of #50807 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests Successful merges: - #50170 (Implement From for more types on Cow) - #50638 (Don't unconditionally set CLOEXEC twice on every fd we open on Linux) - #50656 (Fix `fn main() -> impl Trait` for non-`Termination` trait) - #50669 (rustdoc: deprecate `#![doc(passes, plugins, no_default_passes)]`) - #50726 (read2: Use inner function instead of closure) - #50728 (Fix rustdoc panic with `impl Trait` in type parameters) - #50736 (env: remove unwrap in examples in favor of try op) - #50740 (Remove LazyBTreeMap.) - #50752 (Add missing error codes in libsyntax-ext asm) - #50779 (Make mutable_noalias and arg_align_attributes be tracked) - #50787 (Fix run-make wasm tests) - #50788 (Fix an ICE when casting a nonexistent const) - #50789 (Ensure libraries built in stage0 have unique metadata) - #50793 (tidy: Add a check for empty UI test files) - #50797 (fix a typo in signed-integer::from_str_radix()) - #50808 (Stabilize num::NonZeroU*) - #50809 (GitHub: Stop treating Cargo.lock as a generated file.) Failed merges:
2 parents 4208bd5 + 3c261a4 commit b559710

File tree

78 files changed

+589
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+589
-361
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
src/etc/installer/gfx/* binary
88
*.woff binary
99
src/vendor/** -text
10-
Cargo.lock -merge
10+
Cargo.lock -merge linguist-generated=false

src/bootstrap/builder.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,15 @@ impl<'a> Builder<'a> {
592592

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

597605
let stage;
598606
if compiler.stage == 0 && self.local_rebuild {

src/bootstrap/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ test!(RunFailFullDepsPretty {
838838
host: true
839839
});
840840

841-
host_test!(RunMake {
841+
default_test!(RunMake {
842842
path: "src/test/run-make",
843843
mode: "run-make",
844844
suite: "run-make"
@@ -1041,7 +1041,7 @@ impl Step for Compiletest {
10411041

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

1063-
if mode != "run-make" {
1063+
if suite != "run-make-fulldeps" {
10641064
cmd.arg("--cc").arg("")
10651065
.arg("--cxx").arg("")
10661066
.arg("--cflags").arg("")

src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
#![feature(lang_items)]
103103
#![feature(libc)]
104104
#![feature(needs_allocator)]
105-
#![feature(nonzero)]
106105
#![feature(optin_builtin_traits)]
107106
#![feature(pattern)]
108107
#![feature(pin)]

src/liballoc/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,14 @@ impl<'a> From<String> for Cow<'a, str> {
22402240
}
22412241
}
22422242

2243+
#[stable(feature = "cow_from_string_ref", since = "1.28.0")]
2244+
impl<'a> From<&'a String> for Cow<'a, str> {
2245+
#[inline]
2246+
fn from(s: &'a String) -> Cow<'a, str> {
2247+
Cow::Borrowed(s.as_str())
2248+
}
2249+
}
2250+
22432251
#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
22442252
impl<'a> FromIterator<char> for Cow<'a, str> {
22452253
fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> {

src/liballoc/vec.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,13 @@ impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
22862286
}
22872287
}
22882288

2289+
#[stable(feature = "cow_from_vec_ref", since = "1.28.0")]
2290+
impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
2291+
fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
2292+
Cow::Borrowed(v.as_slice())
2293+
}
2294+
}
2295+
22892296
#[stable(feature = "rust1", since = "1.0.0")]
22902297
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
22912298
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ pub mod prelude;
171171

172172
pub mod intrinsics;
173173
pub mod mem;
174-
pub mod nonzero;
175174
pub mod ptr;
176175
pub mod hint;
177176

@@ -221,6 +220,7 @@ pub mod heap {
221220

222221
// note: does not need to be public
223222
mod iter_private;
223+
mod nonzero;
224224
mod tuple;
225225
mod unit;
226226

src/libcore/nonzero.rs

+3-93
Original file line numberDiff line numberDiff line change
@@ -9,103 +9,13 @@
99
// except according to those terms.
1010

1111
//! Exposes the NonZero lang item which provides optimization hints.
12-
#![unstable(feature = "nonzero", reason = "deprecated", issue = "49137")]
13-
#![rustc_deprecated(reason = "use `std::ptr::NonNull` or `std::num::NonZero*` instead",
14-
since = "1.26.0")]
15-
#![allow(deprecated)]
1612
1713
use ops::CoerceUnsized;
1814

19-
/// Unsafe trait to indicate what types are usable with the NonZero struct
20-
pub unsafe trait Zeroable {
21-
/// Whether this value is zero
22-
fn is_zero(&self) -> bool;
23-
}
24-
25-
macro_rules! impl_zeroable_for_pointer_types {
26-
( $( $Ptr: ty )+ ) => {
27-
$(
28-
/// For fat pointers to be considered "zero", only the "data" part needs to be null.
29-
unsafe impl<T: ?Sized> Zeroable for $Ptr {
30-
#[inline]
31-
fn is_zero(&self) -> bool {
32-
(*self).is_null()
33-
}
34-
}
35-
)+
36-
}
37-
}
38-
39-
macro_rules! impl_zeroable_for_integer_types {
40-
( $( $Int: ty )+ ) => {
41-
$(
42-
unsafe impl Zeroable for $Int {
43-
#[inline]
44-
fn is_zero(&self) -> bool {
45-
*self == 0
46-
}
47-
}
48-
)+
49-
}
50-
}
51-
52-
impl_zeroable_for_pointer_types! {
53-
*const T
54-
*mut T
55-
}
56-
57-
impl_zeroable_for_integer_types! {
58-
usize u8 u16 u32 u64 u128
59-
isize i8 i16 i32 i64 i128
60-
}
61-
6215
/// A wrapper type for raw pointers and integers that will never be
6316
/// NULL or 0 that might allow certain optimizations.
6417
#[lang = "non_zero"]
65-
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
66-
pub struct NonZero<T: Zeroable>(pub(crate) T);
67-
68-
impl<T: Zeroable> NonZero<T> {
69-
/// Creates an instance of NonZero with the provided value.
70-
/// You must indeed ensure that the value is actually "non-zero".
71-
#[inline]
72-
pub const unsafe fn new_unchecked(inner: T) -> Self {
73-
NonZero(inner)
74-
}
75-
76-
/// Creates an instance of NonZero with the provided value.
77-
#[inline]
78-
pub fn new(inner: T) -> Option<Self> {
79-
if inner.is_zero() {
80-
None
81-
} else {
82-
Some(NonZero(inner))
83-
}
84-
}
85-
86-
/// Gets the inner value.
87-
pub fn get(self) -> T {
88-
self.0
89-
}
90-
}
91-
92-
impl<T: Zeroable+CoerceUnsized<U>, U: Zeroable> CoerceUnsized<NonZero<U>> for NonZero<T> {}
93-
94-
impl<'a, T: ?Sized> From<&'a mut T> for NonZero<*mut T> {
95-
fn from(reference: &'a mut T) -> Self {
96-
NonZero(reference)
97-
}
98-
}
99-
100-
impl<'a, T: ?Sized> From<&'a mut T> for NonZero<*const T> {
101-
fn from(reference: &'a mut T) -> Self {
102-
let ptr: *mut T = reference;
103-
NonZero(ptr)
104-
}
105-
}
18+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19+
pub(crate) struct NonZero<T>(pub(crate) T);
10620

107-
impl<'a, T: ?Sized> From<&'a T> for NonZero<*const T> {
108-
fn from(reference: &'a T) -> Self {
109-
NonZero(reference)
110-
}
111-
}
21+
impl<T: CoerceUnsized<U>, U> CoerceUnsized<NonZero<U>> for NonZero<T> {}

src/libcore/num/mod.rs

+9-29
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ use convert::TryFrom;
1616
use fmt;
1717
use intrinsics;
1818
use mem;
19-
#[allow(deprecated)] use nonzero::NonZero;
19+
use nonzero::NonZero;
2020
use ops;
2121
use str::FromStr;
2222

2323
macro_rules! impl_nonzero_fmt {
24-
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
24+
( ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
2525
$(
26-
#[$stability]
27-
#[allow(deprecated)]
26+
#[stable(feature = "nonzero", since = "1.28.0")]
2827
impl fmt::$Trait for $Ty {
2928
#[inline]
3029
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -36,7 +35,7 @@ macro_rules! impl_nonzero_fmt {
3635
}
3736

3837
macro_rules! nonzero_integers {
39-
( #[$stability: meta] #[$deprecation: meta] $( $Ty: ident($Int: ty); )+ ) => {
38+
( $( $Ty: ident($Int: ty); )+ ) => {
4039
$(
4140
/// An integer that is known not to equal zero.
4241
///
@@ -47,27 +46,24 @@ macro_rules! nonzero_integers {
4746
/// use std::mem::size_of;
4847
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
4948
/// ```
50-
#[$stability]
51-
#[$deprecation]
52-
#[allow(deprecated)]
49+
#[stable(feature = "nonzero", since = "1.28.0")]
5350
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5451
pub struct $Ty(NonZero<$Int>);
5552

56-
#[allow(deprecated)]
5753
impl $Ty {
5854
/// Create a non-zero without checking the value.
5955
///
6056
/// # Safety
6157
///
6258
/// The value must not be zero.
63-
#[$stability]
59+
#[stable(feature = "nonzero", since = "1.28.0")]
6460
#[inline]
6561
pub const unsafe fn new_unchecked(n: $Int) -> Self {
6662
$Ty(NonZero(n))
6763
}
6864

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

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

8985
impl_nonzero_fmt! {
90-
#[$stability]
9186
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
9287
}
9388
)+
9489
}
9590
}
9691

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

108-
nonzero_integers! {
109-
#[unstable(feature = "nonzero", issue = "49137")]
110-
#[rustc_deprecated(since = "1.26.0", reason = "\
111-
signed non-zero integers are considered for removal due to lack of known use cases. \
112-
If you’re using them, please comment on https://github.com/rust-lang/rust/issues/49137")]
113-
NonZeroI8(i8);
114-
NonZeroI16(i16);
115-
NonZeroI32(i32);
116-
NonZeroI64(i64);
117-
NonZeroI128(i128);
118-
NonZeroIsize(isize);
119-
}
120-
121101
/// Provides intentionally-wrapped arithmetic on `T`.
122102
///
123103
/// Operations like `+` on `u32` values is intended to never overflow,
@@ -252,7 +232,7 @@ depending on `radix`:
252232
253233
* `0-9`
254234
* `a-z`
255-
* `a-z`
235+
* `A-Z`
256236
257237
# Panics
258238

0 commit comments

Comments
 (0)