Skip to content

Commit

Permalink
Auto merge of rust-lang#82718 - JohnTitor:rollup-vpfx3j2, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - rust-lang#81223 ([rustdoc] Generate redirect map file)
 - rust-lang#82439 (BTree: fix untrue safety)
 - rust-lang#82469 (Use a crate to produce rustdoc tree comparisons instead of the `diff` command)
 - rust-lang#82589 (unix: Non-mutable bufs in send_vectored_with_ancillary_to)
 - rust-lang#82689 (meta: Notify Zulip for rustdoc nominated issues)
 - rust-lang#82695 (Revert non-power-of-two vector restriction)
 - rust-lang#82706 (use outer_expn_data() instead of outer_expn().expn_data())
 - rust-lang#82710 (FloatToInit: Replacing round_unchecked_to --> to_int_unchecked)
 - rust-lang#82712 (Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`)
 - rust-lang#82713 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 3, 2021
2 parents cbca568 + 374c90b commit 770ed1c
Show file tree
Hide file tree
Showing 32 changed files with 313 additions and 146 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ dependencies = [
name = "compiletest"
version = "0.0.0"
dependencies = [
"colored",
"diff",
"getopts",
"glob",
Expand All @@ -688,6 +689,7 @@ dependencies = [
"serde_json",
"tracing",
"tracing-subscriber",
"unified-diff",
"walkdir",
"winapi 0.3.9",
]
Expand Down Expand Up @@ -5526,6 +5528,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"

[[package]]
name = "unified-diff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "496a3d395ed0c30f411ceace4a91f7d93b148fb5a9b383d5d4cff7850f048d5f"
dependencies = [
"diff",
]

[[package]]
name = "unstable-book-gen"
version = "0.1.0"
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Can't be caught in typeck if the array length is generic.
if e_len == 0 {
tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty));
} else if !e_len.is_power_of_two() {
tcx.sess.fatal(&format!(
"monomorphising SIMD type `{}` of non-power-of-two length",
ty
));
} else if e_len > MAX_SIMD_LANES {
tcx.sess.fatal(&format!(
"monomorphising SIMD type `{}` of length greater than {}",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ impl<'a> Resolver<'a> {

fn macro_def(&self, mut ctxt: SyntaxContext) -> DefId {
loop {
match ctxt.outer_expn().expn_data().macro_def_id {
match ctxt.outer_expn_data().macro_def_id {
Some(def_id) => return def_id,
None => ctxt.remove_mark(),
};
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,15 +1161,6 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
if len == 0 {
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
return;
} else if !len.is_power_of_two() {
struct_span_err!(
tcx.sess,
sp,
E0075,
"SIMD vector length must be a power of two"
)
.emit();
return;
} else if len > MAX_SIMD_LANES {
struct_span_err!(
tcx.sess,
Expand Down
31 changes: 15 additions & 16 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ impl<K, V> LeafNode<K, V> {
}
}

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

impl<K, V> NodeRef<marker::Owned, K, V, marker::Leaf> {
fn new_leaf() -> Self {
Self::from_new_leaf(unsafe { LeafNode::new() })
Self::from_new_leaf(LeafNode::new())
}

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

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

let kv = self.split_leaf_data(&mut new_node);
let kv = self.split_leaf_data(&mut new_node);

let right = NodeRef::from_new_leaf(new_node);
SplitResult { left: self.node, kv, right }
}
let right = NodeRef::from_new_leaf(new_node);
SplitResult { left: self.node, kv, right }
}

/// Removes the key-value pair pointed to by this handle and returns it, along with the edge
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod private {
pub trait Sealed {}
}

/// Supporting trait for inherent methods of `f32` and `f64` such as `round_unchecked_to`.
/// Supporting trait for inherent methods of `f32` and `f64` such as `to_int_unchecked`.
/// Typically doesn’t need to be used directly.
#[unstable(feature = "convert_float_to_int", issue = "67057")]
pub trait FloatToInt<Int>: private::Sealed + Sized {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use crate::sys::wasi_ext as wasi;
// If we're not documenting libstd then we just expose the main modules as we otherwise would.

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

Expand Down
10 changes: 5 additions & 5 deletions library/std/src/sys/unix/ext/net/ancillary.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{sockaddr_un, SocketAddr};
use crate::convert::TryFrom;
use crate::io::{self, IoSliceMut};
use crate::io::{self, IoSlice, IoSliceMut};
use crate::marker::PhantomData;
use crate::mem::{size_of, zeroed};
use crate::os::unix::io::RawFd;
Expand Down Expand Up @@ -68,7 +68,7 @@ pub(super) fn recv_vectored_with_ancillary_from(
pub(super) fn send_vectored_with_ancillary_to(
socket: &Socket,
path: Option<&Path>,
bufs: &mut [IoSliceMut<'_>],
bufs: &[IoSlice<'_>],
ancillary: &mut SocketAncillary<'_>,
) -> io::Result<usize> {
unsafe {
Expand All @@ -78,7 +78,7 @@ pub(super) fn send_vectored_with_ancillary_to(
let mut msg: libc::msghdr = zeroed();
msg.msg_name = &mut msg_name as *mut _ as *mut _;
msg.msg_namelen = msg_namelen;
msg.msg_iov = bufs.as_mut_ptr().cast();
msg.msg_iov = bufs.as_ptr() as *mut _;
msg.msg_control = ancillary.buffer.as_mut_ptr().cast();
cfg_if::cfg_if! {
if #[cfg(any(target_os = "android", all(target_os = "linux", target_env = "gnu")))] {
Expand Down Expand Up @@ -567,7 +567,7 @@ impl<'a> SocketAncillary<'a> {
/// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixStream, SocketAncillary};
/// use std::os::unix::io::AsRawFd;
/// use std::io::IoSliceMut;
/// use std::io::IoSlice;
///
/// fn main() -> std::io::Result<()> {
/// let sock = UnixStream::connect("/tmp/sock")?;
Expand All @@ -577,7 +577,7 @@ impl<'a> SocketAncillary<'a> {
/// ancillary.add_fds(&[sock.as_raw_fd()][..]);
///
/// let mut buf = [1; 8];
/// let mut bufs = &mut [IoSliceMut::new(&mut buf[..])][..];
/// let mut bufs = &mut [IoSlice::new(&mut buf[..])][..];
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary)?;
/// Ok(())
/// }
Expand Down
44 changes: 23 additions & 21 deletions library/std/src/sys/unix/ext/net/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::{sockaddr_un, SocketAddr};
target_os = "netbsd",
target_os = "openbsd",
))]
use crate::io::IoSliceMut;
use crate::io::{IoSlice, IoSliceMut};
use crate::net::Shutdown;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::path::Path;
Expand Down Expand Up @@ -506,23 +506,24 @@ impl UnixDatagram {
/// ```no_run
/// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
/// use std::io::IoSliceMut;
/// use std::io::IoSlice;
///
/// fn main() -> std::io::Result<()> {
/// let sock = UnixDatagram::unbound()?;
/// let mut buf1 = [1; 8];
/// let mut buf2 = [2; 16];
/// let mut buf3 = [3; 8];
/// let mut bufs = &mut [
/// IoSliceMut::new(&mut buf1),
/// IoSliceMut::new(&mut buf2),
/// IoSliceMut::new(&mut buf3),
/// let buf1 = [1; 8];
/// let buf2 = [2; 16];
/// let buf3 = [3; 8];
/// let bufs = &[
/// IoSlice::new(&buf1),
/// IoSlice::new(&buf2),
/// IoSlice::new(&buf3),
/// ][..];
/// let fds = [0, 1, 2];
/// let mut ancillary_buffer = [0; 128];
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
/// ancillary.add_fds(&fds[..]);
/// sock.send_vectored_with_ancillary_to(bufs, &mut ancillary, "/some/sock").expect("send_vectored_with_ancillary_to function failed");
/// sock.send_vectored_with_ancillary_to(bufs, &mut ancillary, "/some/sock")
/// .expect("send_vectored_with_ancillary_to function failed");
/// Ok(())
/// }
/// ```
Expand All @@ -538,7 +539,7 @@ impl UnixDatagram {
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary_to<P: AsRef<Path>>(
&self,
bufs: &mut [IoSliceMut<'_>],
bufs: &[IoSlice<'_>],
ancillary: &mut SocketAncillary<'_>,
path: P,
) -> io::Result<usize> {
Expand All @@ -554,23 +555,24 @@ impl UnixDatagram {
/// ```no_run
/// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixDatagram, SocketAncillary};
/// use std::io::IoSliceMut;
/// use std::io::IoSlice;
///
/// fn main() -> std::io::Result<()> {
/// let sock = UnixDatagram::unbound()?;
/// let mut buf1 = [1; 8];
/// let mut buf2 = [2; 16];
/// let mut buf3 = [3; 8];
/// let mut bufs = &mut [
/// IoSliceMut::new(&mut buf1),
/// IoSliceMut::new(&mut buf2),
/// IoSliceMut::new(&mut buf3),
/// let buf1 = [1; 8];
/// let buf2 = [2; 16];
/// let buf3 = [3; 8];
/// let bufs = &[
/// IoSlice::new(&buf1),
/// IoSlice::new(&buf2),
/// IoSlice::new(&buf3),
/// ][..];
/// let fds = [0, 1, 2];
/// let mut ancillary_buffer = [0; 128];
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
/// ancillary.add_fds(&fds[..]);
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary).expect("send_vectored_with_ancillary function failed");
/// sock.send_vectored_with_ancillary(bufs, &mut ancillary)
/// .expect("send_vectored_with_ancillary function failed");
/// Ok(())
/// }
/// ```
Expand All @@ -586,7 +588,7 @@ impl UnixDatagram {
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary(
&self,
bufs: &mut [IoSliceMut<'_>],
bufs: &[IoSlice<'_>],
ancillary: &mut SocketAncillary<'_>,
) -> io::Result<usize> {
send_vectored_with_ancillary_to(&self.0, None, bufs, ancillary)
Expand Down
21 changes: 11 additions & 10 deletions library/std/src/sys/unix/ext/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,24 @@ impl UnixStream {
/// ```no_run
/// #![feature(unix_socket_ancillary_data)]
/// use std::os::unix::net::{UnixStream, SocketAncillary};
/// use std::io::IoSliceMut;
/// use std::io::IoSlice;
///
/// fn main() -> std::io::Result<()> {
/// let socket = UnixStream::connect("/tmp/sock")?;
/// let mut buf1 = [1; 8];
/// let mut buf2 = [2; 16];
/// let mut buf3 = [3; 8];
/// let mut bufs = &mut [
/// IoSliceMut::new(&mut buf1),
/// IoSliceMut::new(&mut buf2),
/// IoSliceMut::new(&mut buf3),
/// let buf1 = [1; 8];
/// let buf2 = [2; 16];
/// let buf3 = [3; 8];
/// let bufs = &[
/// IoSlice::new(&buf1),
/// IoSlice::new(&buf2),
/// IoSlice::new(&buf3),
/// ][..];
/// let fds = [0, 1, 2];
/// let mut ancillary_buffer = [0; 128];
/// let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]);
/// ancillary.add_fds(&fds[..]);
/// socket.send_vectored_with_ancillary(bufs, &mut ancillary).expect("send_vectored_with_ancillary function failed");
/// socket.send_vectored_with_ancillary(bufs, &mut ancillary)
/// .expect("send_vectored_with_ancillary function failed");
/// Ok(())
/// }
/// ```
Expand All @@ -562,7 +563,7 @@ impl UnixStream {
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub fn send_vectored_with_ancillary(
&self,
bufs: &mut [IoSliceMut<'_>],
bufs: &[IoSlice<'_>],
ancillary: &mut SocketAncillary<'_>,
) -> io::Result<usize> {
send_vectored_with_ancillary_to(&self.0, None, bufs, ancillary)
Expand Down
18 changes: 9 additions & 9 deletions library/std/src/sys/unix/ext/net/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,14 @@ fn test_unix_datagram_peek_from() {
fn test_send_vectored_fds_unix_stream() {
let (s1, s2) = or_panic!(UnixStream::pair());

let mut buf1 = [1; 8];
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
let buf1 = [1; 8];
let bufs_send = &[IoSlice::new(&buf1[..])][..];

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

let usize = or_panic!(s1.send_vectored_with_ancillary(&mut bufs_send, &mut ancillary1));
let usize = or_panic!(s1.send_vectored_with_ancillary(&bufs_send, &mut ancillary1));
assert_eq!(usize, 8);

let mut buf2 = [0; 8];
Expand Down Expand Up @@ -542,8 +542,8 @@ fn test_send_vectored_with_ancillary_to_unix_datagram() {

or_panic!(bsock2.set_passcred(true));

let mut buf1 = [1; 8];
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
let buf1 = [1; 8];
let bufs_send = &[IoSlice::new(&buf1[..])][..];

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

let usize =
or_panic!(bsock1.send_vectored_with_ancillary_to(&mut bufs_send, &mut ancillary1, &path2));
or_panic!(bsock1.send_vectored_with_ancillary_to(&bufs_send, &mut ancillary1, &path2));
assert_eq!(usize, 8);

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

let mut buf1 = [1; 8];
let mut bufs_send = &mut [IoSliceMut::new(&mut buf1[..])][..];
let buf1 = [1; 8];
let bufs_send = &[IoSlice::new(&buf1[..])][..];

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

or_panic!(bsock1.connect(&path2));
let usize = or_panic!(bsock1.send_vectored_with_ancillary(&mut bufs_send, &mut ancillary1));
let usize = or_panic!(bsock1.send_vectored_with_ancillary(&bufs_send, &mut ancillary1));
assert_eq!(usize, 8);

let mut buf2 = [0; 8];
Expand Down
Loading

0 comments on commit 770ed1c

Please sign in to comment.