Skip to content

Commit f283d3f

Browse files
committed
Auto merge of #77436 - JohnTitor:rollup-65dh7rp, r=JohnTitor
Rollup of 11 pull requests Successful merges: - #76851 (Fix 'FIXME' about using NonZeroU32 instead of u32.) - #76979 (Improve std::sys::windows::compat) - #77111 (Stabilize slice_ptr_range.) - #77147 (Split sys_common::Mutex in StaticMutex and MovableMutex.) - #77312 (Remove outdated line from `publish_toolstate` hook) - #77362 (Fix is_absolute on WASI) - #77375 (rustc_metadata: Do not forget to encode inherent impls for foreign types) - #77385 (Improve the example for ptr::copy) - #77389 (Fix some clippy lints) - #77399 (BTreeMap: use Unique::from to avoid a cast where type information exists) - #77429 (Link `new` method in `DefautHasher`s doc) Failed merges: r? `@ghost`
2 parents 66936de + 5a72180 commit f283d3f

File tree

36 files changed

+228
-227
lines changed

36 files changed

+228
-227
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! List of the accepted feature gates.
22
3-
use super::{Feature, State};
3+
use super::{to_nonzero, Feature, State};
44
use rustc_span::symbol::sym;
55

66
macro_rules! declare_features {
@@ -14,7 +14,7 @@ macro_rules! declare_features {
1414
state: State::Accepted,
1515
name: sym::$feature,
1616
since: $ver,
17-
issue: $issue,
17+
issue: to_nonzero($issue),
1818
edition: None,
1919
description: concat!($($doc,)*),
2020
}

compiler/rustc_feature/src/active.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! List of the active feature gates.
22
3-
use super::{Feature, State};
3+
use super::{to_nonzero, Feature, State};
44

55
use rustc_span::edition::Edition;
66
use rustc_span::symbol::{sym, Symbol};
@@ -29,7 +29,7 @@ macro_rules! declare_features {
2929
state: State::Active { set: set!($feature) },
3030
name: sym::$feature,
3131
since: $ver,
32-
issue: $issue,
32+
issue: to_nonzero($issue),
3333
edition: $edition,
3434
description: concat!($($doc,)*),
3535
}

compiler/rustc_feature/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,11 @@ pub struct Feature {
4646
pub state: State,
4747
pub name: Symbol,
4848
pub since: &'static str,
49-
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
49+
issue: Option<NonZeroU32>,
5050
pub edition: Option<Edition>,
5151
description: &'static str,
5252
}
5353

54-
impl Feature {
55-
fn issue(&self) -> Option<NonZeroU32> {
56-
self.issue.and_then(NonZeroU32::new)
57-
}
58-
}
59-
6054
#[derive(Copy, Clone, Debug)]
6155
pub enum Stability {
6256
Unstable,
@@ -102,8 +96,8 @@ impl UnstableFeatures {
10296
fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
10397
if let Some(info) = ACTIVE_FEATURES.iter().find(|t| t.name == feature) {
10498
// FIXME (#28244): enforce that active features have issue numbers
105-
// assert!(info.issue().is_some())
106-
info.issue()
99+
// assert!(info.issue.is_some())
100+
info.issue
107101
} else {
108102
// search in Accepted, Removed, or Stable Removed features
109103
let found = ACCEPTED_FEATURES
@@ -112,12 +106,21 @@ fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
112106
.chain(STABLE_REMOVED_FEATURES)
113107
.find(|t| t.name == feature);
114108
match found {
115-
Some(found) => found.issue(),
109+
Some(found) => found.issue,
116110
None => panic!("feature `{}` is not declared anywhere", feature),
117111
}
118112
}
119113
}
120114

115+
const fn to_nonzero(n: Option<u32>) -> Option<NonZeroU32> {
116+
// Can be replaced with `n.and_then(NonZeroU32::new)` if that is ever usable
117+
// in const context. Requires https://github.com/rust-lang/rfcs/pull/2632.
118+
match n {
119+
None => None,
120+
Some(n) => NonZeroU32::new(n),
121+
}
122+
}
123+
121124
pub enum GateIssue {
122125
Language,
123126
Library(Option<NonZeroU32>),

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! List of the removed feature gates.
22
3-
use super::{Feature, State};
3+
use super::{to_nonzero, Feature, State};
44
use rustc_span::symbol::sym;
55

66
macro_rules! declare_features {
@@ -14,7 +14,7 @@ macro_rules! declare_features {
1414
state: State::Removed { reason: $reason },
1515
name: sym::$feature,
1616
since: $ver,
17-
issue: $issue,
17+
issue: to_nonzero($issue),
1818
edition: None,
1919
description: concat!($($doc,)*),
2020
}
@@ -32,7 +32,7 @@ macro_rules! declare_features {
3232
state: State::Stabilized { reason: None },
3333
name: sym::$feature,
3434
since: $ver,
35-
issue: $issue,
35+
issue: to_nonzero($issue),
3636
edition: None,
3737
description: concat!($($doc,)*),
3838
}

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ impl EncodeContext<'a, 'tcx> {
17531753
self.encode_const_stability(def_id);
17541754
self.encode_deprecation(def_id);
17551755
self.encode_item_type(def_id);
1756+
self.encode_inherent_implementations(def_id);
17561757
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
17571758
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
17581759
self.encode_variances_of(def_id);

library/alloc/src/collections/btree/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<K, V> BoxedNode<K, V> {
128128
}
129129

130130
fn from_internal(node: Box<InternalNode<K, V>>) -> Self {
131-
BoxedNode { ptr: Box::into_unique(node).cast() }
131+
BoxedNode { ptr: Unique::from(&mut Box::leak(node).data) }
132132
}
133133

134134
unsafe fn from_ptr(ptr: NonNull<LeafNode<K, V>>) -> Self {

library/core/src/intrinsics.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,11 +1901,21 @@ pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
19011901
/// ```
19021902
/// use std::ptr;
19031903
///
1904+
/// /// # Safety:
1905+
/// /// * `ptr` must be correctly aligned for its type and non-zero.
1906+
/// /// * `ptr` must be valid for reads of `elts` contiguous objects of type `T`.
1907+
/// /// * Those elements must not be used after calling this function unless `T: Copy`.
19041908
/// # #[allow(dead_code)]
19051909
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
19061910
/// let mut dst = Vec::with_capacity(elts);
1907-
/// dst.set_len(elts);
1911+
///
1912+
/// // SAFETY: Our precondition ensures the source is aligned and valid,
1913+
/// // and `Vec::with_capacity` ensures that we have usable space to write them.
19081914
/// ptr::copy(ptr, dst.as_mut_ptr(), elts);
1915+
///
1916+
/// // SAFETY: We created it with this much capacity earlier,
1917+
/// // and the previous `copy` has initialized these elements.
1918+
/// dst.set_len(elts);
19091919
/// dst
19101920
/// }
19111921
/// ```

library/core/src/slice/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,6 @@ impl<T> [T] {
458458
/// element of this slice:
459459
///
460460
/// ```
461-
/// #![feature(slice_ptr_range)]
462-
///
463461
/// let a = [1, 2, 3];
464462
/// let x = &a[1] as *const _;
465463
/// let y = &5 as *const _;
@@ -469,7 +467,7 @@ impl<T> [T] {
469467
/// ```
470468
///
471469
/// [`as_ptr`]: #method.as_ptr
472-
#[unstable(feature = "slice_ptr_range", issue = "65807")]
470+
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
473471
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
474472
#[inline]
475473
pub const fn as_ptr_range(&self) -> Range<*const T> {
@@ -511,7 +509,7 @@ impl<T> [T] {
511509
/// common in C++.
512510
///
513511
/// [`as_mut_ptr`]: #method.as_mut_ptr
514-
#[unstable(feature = "slice_ptr_range", issue = "65807")]
512+
#[stable(feature = "slice_ptr_range", since = "1.48.0")]
515513
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
516514
#[inline]
517515
pub const fn as_mut_ptr_range(&mut self) -> Range<*mut T> {

library/std/src/collections/hash/map.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,11 +2836,10 @@ impl DefaultHasher {
28362836

28372837
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
28382838
impl Default for DefaultHasher {
2839-
// FIXME: here should link `new` to [DefaultHasher::new], but it occurs intra-doc link
2840-
// resolution failure when re-exporting libstd items. When #56922 fixed,
2841-
// link `new` to [DefaultHasher::new] again.
2842-
/// Creates a new `DefaultHasher` using `new`.
2839+
/// Creates a new `DefaultHasher` using [`new`].
28432840
/// See its documentation for more.
2841+
///
2842+
/// [`new`]: DefaultHasher::new
28442843
fn default() -> DefaultHasher {
28452844
DefaultHasher::new()
28462845
}

library/std/src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ impl Path {
18381838
// FIXME: Allow Redox prefixes
18391839
self.has_root() || has_redox_scheme(self.as_u8_slice())
18401840
} else {
1841-
self.has_root() && (cfg!(unix) || self.prefix().is_some())
1841+
self.has_root() && (cfg!(any(unix, target_os = "wasi")) || self.prefix().is_some())
18421842
}
18431843
}
18441844

0 commit comments

Comments
 (0)