Skip to content

Commit 72b2bd5

Browse files
committed
Auto merge of #68067 - JohnTitor:rollup-vsj5won, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #66254 (Make Layout::new const) - #67122 (Do not deduplicate diagnostics in UI tests) - #67358 (Add HashSet::get_or_insert_owned) - #67725 (Simplify into_key_slice_mut) - #67935 (Relax the Sized bounds on Pin::map_unchecked(_mut)) - #67967 (Delay bug to prevent ICE in MIR borrowck) - #67975 (Export public scalar statics in wasm) - #68006 (Recognise riscv64 in compiletest) - #68040 (Cleanup) - #68054 (doc: add Null-unchecked version section to mut pointer as_mut method) Failed merges: - #67258 (Introduce `X..`, `..X`, and `..=X` range patterns) r? @ghost
2 parents 59eb49d + 9e83df0 commit 72b2bd5

File tree

235 files changed

+3078
-418
lines changed

Some content is hidden

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

235 files changed

+3078
-418
lines changed

Cargo.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,8 +3079,6 @@ dependencies = [
30793079
"graphviz",
30803080
"jobserver",
30813081
"log",
3082-
"measureme",
3083-
"num_cpus",
30843082
"parking_lot",
30853083
"polonius-engine",
30863084
"rustc-rayon",
@@ -3090,7 +3088,6 @@ dependencies = [
30903088
"rustc_error_codes",
30913089
"rustc_errors",
30923090
"rustc_feature",
3093-
"rustc_fs_util",
30943091
"rustc_hir",
30953092
"rustc_index",
30963093
"rustc_macros",
@@ -3278,7 +3275,6 @@ dependencies = [
32783275
"jemalloc-sys",
32793276
"rustc_codegen_ssa",
32803277
"rustc_driver",
3281-
"rustc_target",
32823278
]
32833279

32843280
[[package]]
@@ -3409,7 +3405,6 @@ dependencies = [
34093405
"rustc_codegen_utils",
34103406
"rustc_data_structures",
34113407
"rustc_errors",
3412-
"rustc_expand",
34133408
"rustc_feature",
34143409
"rustc_fs_util",
34153410
"rustc_hir",
@@ -3497,7 +3492,6 @@ name = "rustc_driver"
34973492
version = "0.0.0"
34983493
dependencies = [
34993494
"env_logger 0.7.1",
3500-
"graphviz",
35013495
"lazy_static 1.3.0",
35023496
"log",
35033497
"rustc",
@@ -3513,7 +3507,6 @@ dependencies = [
35133507
"rustc_mir",
35143508
"rustc_parse",
35153509
"rustc_plugin_impl",
3516-
"rustc_resolve",
35173510
"rustc_save_analysis",
35183511
"rustc_span",
35193512
"rustc_target",
@@ -3660,7 +3653,6 @@ dependencies = [
36603653
"log",
36613654
"rustc",
36623655
"rustc_data_structures",
3663-
"rustc_error_codes",
36643656
"rustc_feature",
36653657
"rustc_hir",
36663658
"rustc_index",
@@ -4464,8 +4456,6 @@ dependencies = [
44644456
name = "syntax"
44654457
version = "0.0.0"
44664458
dependencies = [
4467-
"bitflags",
4468-
"lazy_static 1.3.0",
44694459
"log",
44704460
"rustc_data_structures",
44714461
"rustc_error_codes",

src/liballoc/collections/btree/node.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
397397

398398
/// Borrows a view into the values stored in the node.
399399
/// The caller must ensure that the node is not the shared root.
400+
/// This function is not public, so doesn't have to support shared roots like `keys` does.
400401
fn vals(&self) -> &[V] {
401402
self.reborrow().into_val_slice()
402403
}
@@ -514,6 +515,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
514515
}
515516

516517
/// The caller must ensure that the node is not the shared root.
518+
/// This function is not public, so doesn't have to support shared roots like `keys` does.
517519
fn keys_mut(&mut self) -> &mut [K] {
518520
unsafe { self.reborrow_mut().into_key_slice_mut() }
519521
}
@@ -589,20 +591,15 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
589591
unsafe { &mut *(self.root as *mut Root<K, V>) }
590592
}
591593

594+
/// The caller must ensure that the node is not the shared root.
592595
fn into_key_slice_mut(mut self) -> &'a mut [K] {
593-
// Same as for `into_key_slice` above, we try to avoid a run-time check.
594-
if (mem::align_of::<NodeHeader<K, V, K>>() > mem::align_of::<NodeHeader<K, V>>()
595-
|| mem::size_of::<NodeHeader<K, V, K>>() != mem::size_of::<NodeHeader<K, V>>())
596-
&& self.is_shared_root()
597-
{
598-
&mut []
599-
} else {
600-
unsafe {
601-
slice::from_raw_parts_mut(
602-
MaybeUninit::first_ptr_mut(&mut (*self.as_leaf_mut()).keys),
603-
self.len(),
604-
)
605-
}
596+
debug_assert!(!self.is_shared_root());
597+
// We cannot be the shared root, so `as_leaf_mut` is okay.
598+
unsafe {
599+
slice::from_raw_parts_mut(
600+
MaybeUninit::first_ptr_mut(&mut (*self.as_leaf_mut()).keys),
601+
self.len(),
602+
)
606603
}
607604
}
608605

src/liballoc/collections/btree/search.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ where
4646
}
4747
}
4848

49+
/// Returns the index in the node at which the key (or an equivalent) exists
50+
/// or could exist, and whether it exists in the node itself. If it doesn't
51+
/// exist in the node itself, it may exist in the subtree with that index
52+
/// (if the node has subtrees). If the key doesn't exist in node or subtree,
53+
/// the returned index is the position or subtree to insert at.
4954
pub fn search_linear<BorrowType, K, V, Type, Q: ?Sized>(
5055
node: &NodeRef<BorrowType, K, V, Type>,
5156
key: &Q,
@@ -54,6 +59,12 @@ where
5459
Q: Ord,
5560
K: Borrow<Q>,
5661
{
62+
// This function is defined over all borrow types (immutable, mutable, owned),
63+
// and may be called on the shared root in each case.
64+
// Crucially, we use `keys()` here, i.e., we work with immutable data.
65+
// `keys_mut()` does not support the shared root, so we cannot use it.
66+
// Using `keys()` is fine here even if BorrowType is mutable, as all we return
67+
// is an index -- not a reference.
5768
for (i, k) in node.keys().iter().enumerate() {
5869
match key.cmp(k.borrow()) {
5970
Ordering::Greater => {}

src/libcore/alloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::usize;
1717
#[derive(Debug)]
1818
pub struct Excess(pub NonNull<u8>, pub usize);
1919

20-
fn size_align<T>() -> (usize, usize) {
20+
const fn size_align<T>() -> (usize, usize) {
2121
(mem::size_of::<T>(), mem::align_of::<T>())
2222
}
2323

@@ -120,14 +120,14 @@ impl Layout {
120120

121121
/// Constructs a `Layout` suitable for holding a value of type `T`.
122122
#[stable(feature = "alloc_layout", since = "1.28.0")]
123+
#[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
123124
#[inline]
124-
pub fn new<T>() -> Self {
125+
pub const fn new<T>() -> Self {
125126
let (size, align) = size_align::<T>();
126127
// Note that the align is guaranteed by rustc to be a power of two and
127128
// the size+align combo is guaranteed to fit in our address space. As a
128129
// result use the unchecked constructor here to avoid inserting code
129130
// that panics if it isn't optimized well enough.
130-
debug_assert!(Layout::from_size_align(size, align).is_ok());
131131
unsafe { Layout::from_size_align_unchecked(size, align) }
132132
}
133133

src/libcore/pin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ impl<'a, T: ?Sized> Pin<&'a T> {
672672
#[stable(feature = "pin", since = "1.33.0")]
673673
pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U>
674674
where
675+
U: ?Sized,
675676
F: FnOnce(&T) -> &U,
676677
{
677678
let pointer = &*self.pointer;
@@ -763,6 +764,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
763764
#[stable(feature = "pin", since = "1.33.0")]
764765
pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U>
765766
where
767+
U: ?Sized,
766768
F: FnOnce(&mut T) -> &mut U,
767769
{
768770
let pointer = Pin::get_unchecked_mut(self);

src/libcore/ptr/mut_ptr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ impl<T: ?Sized> *mut T {
250250
/// *first_value = 4;
251251
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
252252
/// ```
253+
///
254+
/// # Null-unchecked version
255+
///
256+
/// If you are sure the pointer can never be null and are looking for some kind of
257+
/// `as_mut_unchecked` that returns the `&mut T` instead of `Option<&mut T>`, know that
258+
/// you can dereference the pointer directly.
259+
///
260+
/// ```
261+
/// let mut s = [1, 2, 3];
262+
/// let ptr: *mut u32 = s.as_mut_ptr();
263+
/// let first_value = unsafe { &mut *ptr };
264+
/// *first_value = 4;
265+
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
266+
/// ```
253267
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
254268
#[inline]
255269
pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> {

src/librustc/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ bitflags = "1.2.1"
1515
fmt_macros = { path = "../libfmt_macros" }
1616
graphviz = { path = "../libgraphviz" }
1717
jobserver = "0.1"
18-
num_cpus = "1.0"
1918
scoped-tls = "1.0"
2019
log = { version = "0.4", features = ["release_max_level_info", "std"] }
2120
rustc-rayon = "0.3.0"
@@ -36,8 +35,6 @@ backtrace = "0.3.40"
3635
parking_lot = "0.9"
3736
byteorder = { version = "1.3" }
3837
chalk-engine = { version = "0.9.0", default-features=false }
39-
rustc_fs_util = { path = "../librustc_fs_util" }
4038
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
41-
measureme = "0.5"
4239
rustc_error_codes = { path = "../librustc_error_codes" }
4340
rustc_session = { path = "../librustc_session" }

src/librustc/ty/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,6 @@ pub struct UpvarBorrow<'tcx> {
808808
pub type UpvarListMap = FxHashMap<DefId, FxIndexMap<hir::HirId, UpvarId>>;
809809
pub type UpvarCaptureMap<'tcx> = FxHashMap<UpvarId, UpvarCapture<'tcx>>;
810810

811-
#[derive(Copy, Clone, TypeFoldable)]
812-
pub struct ClosureUpvar<'tcx> {
813-
pub res: Res,
814-
pub span: Span,
815-
pub ty: Ty<'tcx>,
816-
}
817-
818811
#[derive(Clone, Copy, PartialEq, Eq)]
819812
pub enum IntVarValue {
820813
IntType(ast::IntTy),

src/librustc/ty/structural_impls.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ impl fmt::Debug for ty::AdtDef {
4545
}
4646
}
4747

48-
impl fmt::Debug for ty::ClosureUpvar<'tcx> {
49-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50-
write!(f, "ClosureUpvar({:?},{:?})", self.res, self.ty)
51-
}
52-
}
53-
5448
impl fmt::Debug for ty::UpvarId {
5549
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5650
let name = ty::tls::with(|tcx| tcx.hir().name(self.var_path.hir_id));

src/librustc_codegen_llvm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ rustc_session = { path = "../librustc_session" }
3131
rustc_target = { path = "../librustc_target" }
3232
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3333
syntax = { path = "../libsyntax" }
34-
rustc_expand = { path = "../librustc_expand" }
3534
rustc_span = { path = "../librustc_span" }

0 commit comments

Comments
 (0)