Skip to content

Commit 770ed1c

Browse files
committed
Auto merge of #82718 - JohnTitor:rollup-vpfx3j2, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #81223 ([rustdoc] Generate redirect map file) - #82439 (BTree: fix untrue safety) - #82469 (Use a crate to produce rustdoc tree comparisons instead of the `diff` command) - #82589 (unix: Non-mutable bufs in send_vectored_with_ancillary_to) - #82689 (meta: Notify Zulip for rustdoc nominated issues) - #82695 (Revert non-power-of-two vector restriction) - #82706 (use outer_expn_data() instead of outer_expn().expn_data()) - #82710 (FloatToInit: Replacing round_unchecked_to --> to_int_unchecked) - #82712 (Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`) - #82713 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents cbca568 + 374c90b commit 770ed1c

File tree

32 files changed

+313
-146
lines changed

32 files changed

+313
-146
lines changed

Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ dependencies = [
676676
name = "compiletest"
677677
version = "0.0.0"
678678
dependencies = [
679+
"colored",
679680
"diff",
680681
"getopts",
681682
"glob",
@@ -688,6 +689,7 @@ dependencies = [
688689
"serde_json",
689690
"tracing",
690691
"tracing-subscriber",
692+
"unified-diff",
691693
"walkdir",
692694
"winapi 0.3.9",
693695
]
@@ -5526,6 +5528,15 @@ version = "0.1.1"
55265528
source = "registry+https://github.com/rust-lang/crates.io-index"
55275529
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
55285530

5531+
[[package]]
5532+
name = "unified-diff"
5533+
version = "0.2.1"
5534+
source = "registry+https://github.com/rust-lang/crates.io-index"
5535+
checksum = "496a3d395ed0c30f411ceace4a91f7d93b148fb5a9b383d5d4cff7850f048d5f"
5536+
dependencies = [
5537+
"diff",
5538+
]
5539+
55295540
[[package]]
55305541
name = "unstable-book-gen"
55315542
version = "0.1.0"

compiler/rustc_middle/src/ty/layout.rs

-5
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
732732
// Can't be caught in typeck if the array length is generic.
733733
if e_len == 0 {
734734
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty));
735-
} else if !e_len.is_power_of_two() {
736-
tcx.sess.fatal(&format!(
737-
"monomorphising SIMD type `{}` of non-power-of-two length",
738-
ty
739-
));
740735
} else if e_len > MAX_SIMD_LANES {
741736
tcx.sess.fatal(&format!(
742737
"monomorphising SIMD type `{}` of length greater than {}",

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ impl<'a> Resolver<'a> {
14221422

14231423
fn macro_def(&self, mut ctxt: SyntaxContext) -> DefId {
14241424
loop {
1425-
match ctxt.outer_expn().expn_data().macro_def_id {
1425+
match ctxt.outer_expn_data().macro_def_id {
14261426
Some(def_id) => return def_id,
14271427
None => ctxt.remove_mark(),
14281428
};

compiler/rustc_typeck/src/check/check.rs

-9
Original file line numberDiff line numberDiff line change
@@ -1161,15 +1161,6 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
11611161
if len == 0 {
11621162
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
11631163
return;
1164-
} else if !len.is_power_of_two() {
1165-
struct_span_err!(
1166-
tcx.sess,
1167-
sp,
1168-
E0075,
1169-
"SIMD vector length must be a power of two"
1170-
)
1171-
.emit();
1172-
return;
11731164
} else if len > MAX_SIMD_LANES {
11741165
struct_span_err!(
11751166
tcx.sess,

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

+15-16
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ impl<K, V> LeafNode<K, V> {
7777
}
7878
}
7979

80-
/// Creates a new boxed `LeafNode`. Unsafe because all nodes should really be hidden behind
81-
/// `BoxedNode`, preventing accidental dropping of uninitialized keys and values.
82-
unsafe fn new() -> Box<Self> {
80+
/// Creates a new boxed `LeafNode`.
81+
fn new() -> Box<Self> {
8382
unsafe {
8483
let mut leaf = Box::new_uninit();
8584
LeafNode::init(leaf.as_mut_ptr());
@@ -107,10 +106,9 @@ struct InternalNode<K, V> {
107106
impl<K, V> InternalNode<K, V> {
108107
/// Creates a new boxed `InternalNode`.
109108
///
110-
/// This is unsafe for two reasons. First, it returns an owned `InternalNode` in a box, risking
111-
/// dropping of uninitialized fields. Second, an invariant of internal nodes is that `len + 1`
112-
/// edges are initialized and valid, meaning that even when the node is empty (having a
113-
/// `len` of 0), there must be one initialized and valid edge. This function does not set up
109+
/// # Safety
110+
/// An invariant of internal nodes is that they have at least one
111+
/// initialized and valid edge. This function does not set up
114112
/// such an edge.
115113
unsafe fn new() -> Box<Self> {
116114
unsafe {
@@ -144,7 +142,7 @@ impl<K, V> Root<K, V> {
144142

145143
impl<K, V> NodeRef<marker::Owned, K, V, marker::Leaf> {
146144
fn new_leaf() -> Self {
147-
Self::from_new_leaf(unsafe { LeafNode::new() })
145+
Self::from_new_leaf(LeafNode::new())
148146
}
149147

150148
fn from_new_leaf(leaf: Box<LeafNode<K, V>>) -> Self {
@@ -156,10 +154,13 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::Internal> {
156154
fn new_internal(child: Root<K, V>) -> Self {
157155
let mut new_node = unsafe { InternalNode::new() };
158156
new_node.edges[0].write(child.node);
159-
NodeRef::from_new_internal(new_node, child.height + 1)
157+
unsafe { NodeRef::from_new_internal(new_node, child.height + 1) }
160158
}
161159

162-
fn from_new_internal(internal: Box<InternalNode<K, V>>, height: usize) -> Self {
160+
/// # Safety
161+
/// `height` must not be zero.
162+
unsafe fn from_new_internal(internal: Box<InternalNode<K, V>>, height: usize) -> Self {
163+
debug_assert!(height > 0);
163164
let node = NonNull::from(Box::leak(internal)).cast();
164165
let mut this = NodeRef { height, node, _marker: PhantomData };
165166
this.borrow_mut().correct_all_childrens_parent_links();
@@ -1080,14 +1081,12 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, mark
10801081
/// - All the key-value pairs to the right of this handle are put into a newly
10811082
/// allocated node.
10821083
pub fn split(mut self) -> SplitResult<'a, K, V, marker::Leaf> {
1083-
unsafe {
1084-
let mut new_node = LeafNode::new();
1084+
let mut new_node = LeafNode::new();
10851085

1086-
let kv = self.split_leaf_data(&mut new_node);
1086+
let kv = self.split_leaf_data(&mut new_node);
10871087

1088-
let right = NodeRef::from_new_leaf(new_node);
1089-
SplitResult { left: self.node, kv, right }
1090-
}
1088+
let right = NodeRef::from_new_leaf(new_node);
1089+
SplitResult { left: self.node, kv, right }
10911090
}
10921091

10931092
/// Removes the key-value pair pointed to by this handle and returns it, along with the edge

library/core/src/convert/num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod private {
99
pub trait Sealed {}
1010
}
1111

12-
/// Supporting trait for inherent methods of `f32` and `f64` such as `round_unchecked_to`.
12+
/// Supporting trait for inherent methods of `f32` and `f64` such as `to_int_unchecked`.
1313
/// Typically doesn’t need to be used directly.
1414
#[unstable(feature = "convert_float_to_int", issue = "67057")]
1515
pub trait FloatToInt<Int>: private::Sealed + Sized {

library/std/src/os/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub use crate::sys::wasi_ext as wasi;
2929
// If we're not documenting libstd then we just expose the main modules as we otherwise would.
3030

3131
#[cfg(not(doc))]
32-
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
32+
#[cfg(any(unix, target_os = "hermit"))]
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
pub use crate::sys::ext as unix;
3535

library/std/src/sys/unix/ext/net/ancillary.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{sockaddr_un, SocketAddr};
22
use crate::convert::TryFrom;
3-
use crate::io::{self, IoSliceMut};
3+
use crate::io::{self, IoSlice, IoSliceMut};
44
use crate::marker::PhantomData;
55
use crate::mem::{size_of, zeroed};
66
use crate::os::unix::io::RawFd;
@@ -68,7 +68,7 @@ pub(super) fn recv_vectored_with_ancillary_from(
6868
pub(super) fn send_vectored_with_ancillary_to(
6969
socket: &Socket,
7070
path: Option<&Path>,
71-
bufs: &mut [IoSliceMut<'_>],
71+
bufs: &[IoSlice<'_>],
7272
ancillary: &mut SocketAncillary<'_>,
7373
) -> io::Result<usize> {
7474
unsafe {
@@ -78,7 +78,7 @@ pub(super) fn send_vectored_with_ancillary_to(
7878
let mut msg: libc::msghdr = zeroed();
7979
msg.msg_name = &mut msg_name as *mut _ as *mut _;
8080
msg.msg_namelen = msg_namelen;
81-
msg.msg_iov = bufs.as_mut_ptr().cast();
81+
msg.msg_iov = bufs.as_ptr() as *mut _;
8282
msg.msg_control = ancillary.buffer.as_mut_ptr().cast();
8383
cfg_if::cfg_if! {
8484
if #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] {
@@ -567,7 +567,7 @@ impl<'a> SocketAncillary<'a> {
567567
/// #![feature(unix_socket_ancillary_data)]
568568
/// use std::os::unix::net::{UnixStream, SocketAncillary};
569569
/// use std::os::unix::io::AsRawFd;
570-
/// use std::io::IoSliceMut;
570+
/// use std::io::IoSlice;
571571
///
572572
/// fn main() -> std::io::Result<()> {
573573
/// let sock = UnixStream::connect("/tmp/sock")?;
@@ -577,7 +577,7 @@ impl<'a> SocketAncillary<'a> {
577577
/// ancillary.add_fds(&[sock.as_raw_fd()][..]);
578578
///
579579
/// let mut buf = [1; 8];
580-
/// let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..];
580+
/// let mut bufs = &mut [IoSlice::new(&mut buf[..])][..];
581581
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary)?;
582582
/// Ok(())
583583
/// }

library/std/src/sys/unix/ext/net/datagram.rs

+23-21
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::{sockaddr_un, SocketAddr};
1919
target_os = "netbsd",
2020
target_os = "openbsd",
2121
))]
22-
use crate::io::IoSliceMut;
22+
use crate::io::{IoSlice, IoSliceMut};
2323
use crate::net::Shutdown;
2424
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
2525
use crate::path::Path;
@@ -506,23 +506,24 @@ impl UnixDatagram {
506506
/// ```no_run
507507
/// #![feature(unix_socket_ancillary_data)]
508508
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
509-
/// use std::io::IoSliceMut;
509+
/// use std::io::IoSlice;
510510
///
511511
/// fn main() -> std::io::Result<()> {
512512
/// let sock = UnixDatagram::unbound()?;
513-
/// let mut buf1 = [1; 8];
514-
/// let mut buf2 = [2; 16];
515-
/// let mut buf3 = [3; 8];
516-
/// let mut bufs = &mut [
517-
/// IoSliceMut::new(&mut buf1),
518-
/// IoSliceMut::new(&mut buf2),
519-
/// IoSliceMut::new(&mut buf3),
513+
/// let buf1 = [1; 8];
514+
/// let buf2 = [2; 16];
515+
/// let buf3 = [3; 8];
516+
/// let bufs = &[
517+
/// IoSlice::new(&buf1),
518+
/// IoSlice::new(&buf2),
519+
/// IoSlice::new(&buf3),
520520
/// ][..];
521521
/// let fds = [0, 1, 2];
522522
/// let mut ancillary_buffer = [0; 128];
523523
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
524524
/// ancillary.add_fds(&fds[..]);
525-
/// sock.send_vectored_with_ancillary_to(bufs, &mut ancillary, "/some/sock").expect("send_vectored_with_ancillary_to function failed");
525+
/// sock.send_vectored_with_ancillary_to(bufs, &mut ancillary, "/some/sock")
526+
/// .expect("send_vectored_with_ancillary_to function failed");
526527
/// Ok(())
527528
/// }
528529
/// ```
@@ -538,7 +539,7 @@ impl UnixDatagram {
538539
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
539540
pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>(
540541
&self,
541-
bufs: &mut [IoSliceMut<'_>],
542+
bufs: &[IoSlice<'_>],
542543
ancillary: &mut SocketAncillary<'_>,
543544
path: P,
544545
) -> io::Result<usize> {
@@ -554,23 +555,24 @@ impl UnixDatagram {
554555
/// ```no_run
555556
/// #![feature(unix_socket_ancillary_data)]
556557
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
557-
/// use std::io::IoSliceMut;
558+
/// use std::io::IoSlice;
558559
///
559560
/// fn main() -> std::io::Result<()> {
560561
/// let sock = UnixDatagram::unbound()?;
561-
/// let mut buf1 = [1; 8];
562-
/// let mut buf2 = [2; 16];
563-
/// let mut buf3 = [3; 8];
564-
/// let mut bufs = &mut [
565-
/// IoSliceMut::new(&mut buf1),
566-
/// IoSliceMut::new(&mut buf2),
567-
/// IoSliceMut::new(&mut buf3),
562+
/// let buf1 = [1; 8];
563+
/// let buf2 = [2; 16];
564+
/// let buf3 = [3; 8];
565+
/// let bufs = &[
566+
/// IoSlice::new(&buf1),
567+
/// IoSlice::new(&buf2),
568+
/// IoSlice::new(&buf3),
568569
/// ][..];
569570
/// let fds = [0, 1, 2];
570571
/// let mut ancillary_buffer = [0; 128];
571572
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
572573
/// ancillary.add_fds(&fds[..]);
573-
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary).expect("send_vectored_with_ancillary function failed");
574+
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary)
575+
/// .expect("send_vectored_with_ancillary function failed");
574576
/// Ok(())
575577
/// }
576578
/// ```
@@ -586,7 +588,7 @@ impl UnixDatagram {
586588
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
587589
pub fn send_vectored_with_ancillary(
588590
&self,
589-
bufs: &mut [IoSliceMut<'_>],
591+
bufs: &[IoSlice<'_>],
590592
ancillary: &mut SocketAncillary<'_>,
591593
) -> io::Result<usize> {
592594
send_vectored_with_ancillary_to(&self.0, None, bufs, ancillary)

library/std/src/sys/unix/ext/net/stream.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -530,23 +530,24 @@ impl UnixStream {
530530
/// ```no_run
531531
/// #![feature(unix_socket_ancillary_data)]
532532
/// use std::os::unix::net::{UnixStream, SocketAncillary};
533-
/// use std::io::IoSliceMut;
533+
/// use std::io::IoSlice;
534534
///
535535
/// fn main() -> std::io::Result<()> {
536536
/// let socket = UnixStream::connect("/tmp/sock")?;
537-
/// let mut buf1 = [1; 8];
538-
/// let mut buf2 = [2; 16];
539-
/// let mut buf3 = [3; 8];
540-
/// let mut bufs = &mut [
541-
/// IoSliceMut::new(&mut buf1),
542-
/// IoSliceMut::new(&mut buf2),
543-
/// IoSliceMut::new(&mut buf3),
537+
/// let buf1 = [1; 8];
538+
/// let buf2 = [2; 16];
539+
/// let buf3 = [3; 8];
540+
/// let bufs = &[
541+
/// IoSlice::new(&buf1),
542+
/// IoSlice::new(&buf2),
543+
/// IoSlice::new(&buf3),
544544
/// ][..];
545545
/// let fds = [0, 1, 2];
546546
/// let mut ancillary_buffer = [0; 128];
547547
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
548548
/// ancillary.add_fds(&fds[..]);
549-
/// socket.send_vectored_with_ancillary(bufs, &mut ancillary).expect("send_vectored_with_ancillary function failed");
549+
/// socket.send_vectored_with_ancillary(bufs, &mut ancillary)
550+
/// .expect("send_vectored_with_ancillary function failed");
550551
/// Ok(())
551552
/// }
552553
/// ```
@@ -562,7 +563,7 @@ impl UnixStream {
562563
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
563564
pub fn send_vectored_with_ancillary(
564565
&self,
565-
bufs: &mut [IoSliceMut<'_>],
566+
bufs: &[IoSlice<'_>],
566567
ancillary: &mut SocketAncillary<'_>,
567568
) -> io::Result<usize> {
568569
send_vectored_with_ancillary_to(&self.0, None, bufs, ancillary)

library/std/src/sys/unix/ext/net/tests.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,14 @@ fn test_unix_datagram_peek_from() {
485485
fn test_send_vectored_fds_unix_stream() {
486486
let (s1, s2) = or_panic!(UnixStream::pair());
487487

488-
let mut buf1 = [1; 8];
489-
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
488+
let buf1 = [1; 8];
489+
let bufs_send = &[IoSlice::new(&buf1[..])][..];
490490

491491
let mut ancillary1_buffer = [0; 128];
492492
let mut ancillary1 = SocketAncillary::new(&mut ancillary1_buffer[..]);
493493
assert!(ancillary1.add_fds(&[s1.as_raw_fd()][..]));
494494

495-
let usize = or_panic!(s1.send_vectored_with_ancillary(&mut bufs_send, &mut ancillary1));
495+
let usize = or_panic!(s1.send_vectored_with_ancillary(&bufs_send, &mut ancillary1));
496496
assert_eq!(usize, 8);
497497

498498
let mut buf2 = [0; 8];
@@ -542,8 +542,8 @@ fn test_send_vectored_with_ancillary_to_unix_datagram() {
542542

543543
or_panic!(bsock2.set_passcred(true));
544544

545-
let mut buf1 = [1; 8];
546-
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
545+
let buf1 = [1; 8];
546+
let bufs_send = &[IoSlice::new(&buf1[..])][..];
547547

548548
let mut ancillary1_buffer = [0; 128];
549549
let mut ancillary1 = SocketAncillary::new(&mut ancillary1_buffer[..]);
@@ -554,7 +554,7 @@ fn test_send_vectored_with_ancillary_to_unix_datagram() {
554554
assert!(ancillary1.add_creds(&[cred1.clone()][..]));
555555

556556
let usize =
557-
or_panic!(bsock1.send_vectored_with_ancillary_to(&mut bufs_send, &mut ancillary1, &path2));
557+
or_panic!(bsock1.send_vectored_with_ancillary_to(&bufs_send, &mut ancillary1, &path2));
558558
assert_eq!(usize, 8);
559559

560560
let mut buf2 = [0; 8];
@@ -603,15 +603,15 @@ fn test_send_vectored_with_ancillary_unix_datagram() {
603603
let bsock1 = or_panic!(UnixDatagram::bind(&path1));
604604
let bsock2 = or_panic!(UnixDatagram::bind(&path2));
605605

606-
let mut buf1 = [1; 8];
607-
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
606+
let buf1 = [1; 8];
607+
let bufs_send = &[IoSlice::new(&buf1[..])][..];
608608

609609
let mut ancillary1_buffer = [0; 128];
610610
let mut ancillary1 = SocketAncillary::new(&mut ancillary1_buffer[..]);
611611
assert!(ancillary1.add_fds(&[bsock1.as_raw_fd()][..]));
612612

613613
or_panic!(bsock1.connect(&path2));
614-
let usize = or_panic!(bsock1.send_vectored_with_ancillary(&mut bufs_send, &mut ancillary1));
614+
let usize = or_panic!(bsock1.send_vectored_with_ancillary(&bufs_send, &mut ancillary1));
615615
assert_eq!(usize, 8);
616616

617617
let mut buf2 = [0; 8];

0 commit comments

Comments
 (0)