diff options
| author | bors <bors@rust-lang.org> | 2023-05-01 20:35:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-01 20:35:53 +0000 |
| commit | d6ddee637b62c6c4cdee90d98c3a21a1325a8e81 (patch) | |
| tree | 4be608ba309b622a1f66a912b261179c1595a291 | |
| parent | dbba594575ce75b1b57ccb1e4223b9909a28b1b8 (diff) | |
| parent | 15eebac9d962fa7510f4729f85e57c46a39c3ea1 (diff) | |
| download | rust-d6ddee637b62c6c4cdee90d98c3a21a1325a8e81.tar.gz rust-d6ddee637b62c6c4cdee90d98c3a21a1325a8e81.zip | |
Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #109540 (std docs: edit `PathBuf::set_file_name` example) - #110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`) - #110987 (update wasi_clock_time_api ref.) - #111038 (Leave promoteds untainted by errors when borrowck fails) - #111042 (Add `#[no_coverage]` to the test harness's `fn main`) - #111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined) - #111065 (Explicitly document how Send and Sync relate to references) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
37 files changed, 180 insertions, 16 deletions
diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index be4ba66c082..9bc1e27b4ec 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -232,7 +232,7 @@ fn generate_test_harness( let expn_id = ext_cx.resolver.expansion_for_ast_pass( DUMMY_SP, AstPass::TestHarness, - &[sym::test, sym::rustc_attrs], + &[sym::test, sym::rustc_attrs, sym::no_coverage], None, ); let def_site = DUMMY_SP.with_def_site_ctxt(expn_id.to_expn_id()); @@ -313,6 +313,8 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> { // #[rustc_main] let main_attr = ecx.attr_word(sym::rustc_main, sp); + // #[no_coverage] + let no_coverage_attr = ecx.attr_word(sym::no_coverage, sp); // pub fn main() { ... } let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(ThinVec::new())); @@ -342,7 +344,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> { let main = P(ast::Item { ident: main_id, - attrs: thin_vec![main_attr], + attrs: thin_vec![main_attr, no_coverage_attr], id: ast::DUMMY_NODE_ID, kind: main, vis: ast::Visibility { span: sp, kind: ast::VisibilityKind::Public, tokens: None }, diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 25d7db0ee60..8d9a22ea30d 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -616,13 +616,10 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_ return tcx.arena.alloc(IndexVec::new()); } - let tainted_by_errors = tcx.mir_borrowck(def).tainted_by_errors; + tcx.ensure_with_value().mir_borrowck(def); let mut promoted = tcx.mir_promoted(def).1.steal(); for body in &mut promoted { - if let Some(error_reported) = tainted_by_errors { - body.tainted_by_errors = Some(error_reported); - } run_analysis_to_runtime_passes(tcx, body); } diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 40789cb3049..82e4c648974 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -24,7 +24,7 @@ use crate::hash::Hasher; /// operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring /// some overhead) and thus is `Send`. /// -/// See [the Nomicon](../../nomicon/send-and-sync.html) for more details. +/// See [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`] trait for more details. /// /// [`Rc`]: ../../std/rc/struct.Rc.html /// [arc]: ../../std/sync/struct.Arc.html @@ -426,6 +426,11 @@ pub macro Copy($item:item) { /// becomes read-only, as if it were a `& &T`. Hence there is no risk /// of a data race. /// +/// A shorter overview of how [`Sync`] and [`Send`] relate to referencing: +/// * `&T` is [`Send`] if and only if `T` is [`Sync`] +/// * `&mut T` is [`Send`] if and only if `T` is [`Send`] +/// * `&T` and `&mut T` are [`Sync`] if and only if `T` is [`Sync`] +/// /// Types that are not `Sync` are those that have "interior /// mutability" in a non-thread-safe form, such as [`Cell`][cell] /// and [`RefCell`][refcell]. These types allow for mutation of diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 30e553f285b..6640c7fb162 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -709,6 +709,7 @@ impl File { // `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows. impl AsInner<fs_imp::File> for File { + #[inline] fn as_inner(&self) -> &fs_imp::File { &self.inner } @@ -1087,12 +1088,14 @@ impl OpenOptions { } impl AsInner<fs_imp::OpenOptions> for OpenOptions { + #[inline] fn as_inner(&self) -> &fs_imp::OpenOptions { &self.0 } } impl AsInnerMut<fs_imp::OpenOptions> for OpenOptions { + #[inline] fn as_inner_mut(&mut self) -> &mut fs_imp::OpenOptions { &mut self.0 } @@ -1352,6 +1355,7 @@ impl fmt::Debug for Metadata { } impl AsInner<fs_imp::FileAttr> for Metadata { + #[inline] fn as_inner(&self) -> &fs_imp::FileAttr { &self.0 } @@ -1604,6 +1608,7 @@ impl FileType { } impl AsInner<fs_imp::FileType> for FileType { + #[inline] fn as_inner(&self) -> &fs_imp::FileType { &self.0 } @@ -1616,6 +1621,7 @@ impl FromInner<fs_imp::FilePermissions> for Permissions { } impl AsInner<fs_imp::FilePermissions> for Permissions { + #[inline] fn as_inner(&self) -> &fs_imp::FilePermissions { &self.0 } @@ -1770,6 +1776,7 @@ impl fmt::Debug for DirEntry { } impl AsInner<fs_imp::DirEntry> for DirEntry { + #[inline] fn as_inner(&self) -> &fs_imp::DirEntry { &self.0 } @@ -2510,6 +2517,7 @@ impl DirBuilder { } impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder { + #[inline] fn as_inner_mut(&mut self) -> &mut fs_imp::DirBuilder { &mut self.inner } diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 4b42ad65ee6..541e95d229b 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -691,6 +691,7 @@ impl Write for &TcpStream { } impl AsInner<net_imp::TcpStream> for TcpStream { + #[inline] fn as_inner(&self) -> &net_imp::TcpStream { &self.0 } @@ -1033,6 +1034,7 @@ impl Iterator for IntoIncoming { impl FusedIterator for IntoIncoming {} impl AsInner<net_imp::TcpListener> for TcpListener { + #[inline] fn as_inner(&self) -> &net_imp::TcpListener { &self.0 } diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 864e1b0f345..9628bcc5108 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -788,6 +788,7 @@ impl UdpSocket { // `AsRawSocket`/`IntoRawSocket`/`FromRawSocket` on Windows. impl AsInner<net_imp::UdpSocket> for UdpSocket { + #[inline] fn as_inner(&self) -> &net_imp::UdpSocket { &self.0 } diff --git a/library/std/src/os/linux/process.rs b/library/std/src/os/linux/process.rs index 540363c0349..2b3ff76d7a4 100644 --- a/library/std/src/os/linux/process.rs +++ b/library/std/src/os/linux/process.rs @@ -52,6 +52,7 @@ pub struct PidFd { } impl AsInner<FileDesc> for PidFd { + #[inline] fn as_inner(&self) -> &FileDesc { &self.inner } @@ -70,6 +71,7 @@ impl IntoInner<FileDesc> for PidFd { } impl AsRawFd for PidFd { + #[inline] fn as_raw_fd(&self) -> RawFd { self.as_inner().as_raw_fd() } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 5b22333cc35..198996c5f70 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1395,11 +1395,16 @@ impl PathBuf { /// /// let mut buf = PathBuf::from("/"); /// assert!(buf.file_name() == None); - /// buf.set_file_name("bar"); - /// assert!(buf == PathBuf::from("/bar")); + /// + /// buf.set_file_name("foo.txt"); + /// assert!(buf == PathBuf::from("/foo.txt")); /// assert!(buf.file_name().is_some()); - /// buf.set_file_name("baz.txt"); - /// assert!(buf == PathBuf::from("/baz.txt")); + /// + /// buf.set_file_name("bar.txt"); + /// assert!(buf == PathBuf::from("/bar.txt")); + /// + /// buf.set_file_name("baz"); + /// assert!(buf == PathBuf::from("/baz")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S) { @@ -2562,7 +2567,8 @@ impl Path { /// ``` /// use std::path::{Path, PathBuf}; /// - /// let path = Path::new("/tmp/foo.txt"); + /// let path = Path::new("/tmp/foo.png"); + /// assert_eq!(path.with_file_name("bar"), PathBuf::from("/tmp/bar")); /// assert_eq!(path.with_file_name("bar.txt"), PathBuf::from("/tmp/bar.txt")); /// /// let path = Path::new("/tmp"); diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 0ab72f7ea7a..bf22c2d46c9 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -211,6 +211,7 @@ pub struct Child { impl crate::sealed::Sealed for Child {} impl AsInner<imp::Process> for Child { + #[inline] fn as_inner(&self) -> &imp::Process { &self.handle } @@ -304,6 +305,7 @@ impl Write for &ChildStdin { } impl AsInner<AnonPipe> for ChildStdin { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -373,6 +375,7 @@ impl Read for ChildStdout { } impl AsInner<AnonPipe> for ChildStdout { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -438,6 +441,7 @@ impl Read for ChildStderr { } impl AsInner<AnonPipe> for ChildStderr { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -1107,12 +1111,14 @@ impl fmt::Debug for Command { } impl AsInner<imp::Command> for Command { + #[inline] fn as_inner(&self) -> &imp::Command { &self.inner } } impl AsInnerMut<imp::Command> for Command { + #[inline] fn as_inner_mut(&mut self) -> &mut imp::Command { &mut self.inner } @@ -1605,6 +1611,7 @@ impl ExitStatus { } impl AsInner<imp::ExitStatus> for ExitStatus { + #[inline] fn as_inner(&self) -> &imp::ExitStatus { &self.0 } @@ -1884,6 +1891,7 @@ impl From<u8> for ExitCode { } impl AsInner<imp::ExitCode> for ExitCode { + #[inline] fn as_inner(&self) -> &imp::ExitCode { &self.0 } diff --git a/library/std/src/sys/hermit/fd.rs b/library/std/src/sys/hermit/fd.rs index 3a2cdd301ea..ccde05aa1d7 100644 --- a/library/std/src/sys/hermit/fd.rs +++ b/library/std/src/sys/hermit/fd.rs @@ -75,6 +75,7 @@ impl FromRawFd for FileDesc { } impl AsInner<OwnedFd> for FileDesc { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.fd } diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index cf0b271761f..4bb735668d2 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -367,12 +367,14 @@ impl DirBuilder { } impl AsInner<FileDesc> for File { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } } impl AsInnerMut<FileDesc> for File { + #[inline] fn as_inner_mut(&mut self) -> &mut FileDesc { &mut self.0 } @@ -397,6 +399,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index d6f64a29719..8c2d489d6a3 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -340,6 +340,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -364,6 +365,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/sgx/fd.rs b/library/std/src/sys/sgx/fd.rs index 0c02a107691..b3686d0e283 100644 --- a/library/std/src/sys/sgx/fd.rs +++ b/library/std/src/sys/sgx/fd.rs @@ -62,6 +62,7 @@ impl FileDesc { } impl AsInner<Fd> for FileDesc { + #[inline] fn as_inner(&self) -> &Fd { &self.fd } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index 923be5eb944..03620a08f2c 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -24,6 +24,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.inner } @@ -220,6 +221,7 @@ impl TcpStream { } impl AsInner<Socket> for TcpStream { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -304,6 +306,7 @@ impl TcpListener { } impl AsInner<Socket> for TcpListener { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index 7d7bfae1432..0bd2bc3b961 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -112,6 +112,7 @@ impl FileDesc { } impl AsInner<c_int> for FileDesc { + #[inline] fn as_inner(&self) -> &c_int { &self.fd } @@ -462,6 +463,7 @@ impl Socket { } impl AsInner<c_int> for Socket { + #[inline] fn as_inner(&self) -> &c_int { self.0.as_inner() } diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs index ce5c048f252..45f96478fc3 100644 --- a/library/std/src/sys/unix/fd.rs +++ b/library/std/src/sys/unix/fd.rs @@ -481,6 +481,7 @@ impl<'a> Read for &'a FileDesc { } impl AsInner<OwnedFd> for FileDesc { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.0 } @@ -505,6 +506,7 @@ impl AsFd for FileDesc { } impl AsRawFd for FileDesc { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index abef170dd5a..b398fd5eb24 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -547,6 +547,7 @@ impl FileAttr { } impl AsInner<stat64> for FileAttr { + #[inline] fn as_inner(&self) -> &stat64 { &self.stat } @@ -1193,8 +1194,6 @@ impl File { None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), } }; - #[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))] - let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; cfg_if::cfg_if! { if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] { // Redox doesn't appear to support `UTIME_OMIT`. @@ -1206,6 +1205,7 @@ impl File { "setting file times not supported", )) } else if #[cfg(any(target_os = "android", target_os = "macos"))] { + let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; // futimens requires macOS 10.13, and Android API level 19 cvt(unsafe { weak!(fn futimens(c_int, *const libc::timespec) -> c_int); @@ -1232,6 +1232,22 @@ impl File { })?; Ok(()) } else { + #[cfg(all(target_os = "linux", target_env = "gnu", target_pointer_width = "32", not(target_arch = "riscv32")))] + { + use crate::sys::{time::__timespec64, weak::weak}; + + // Added in glibc 2.34 + weak!(fn __futimens64(libc::c_int, *const __timespec64) -> libc::c_int); + + if let Some(futimens64) = __futimens64.get() { + let to_timespec = |time: Option<SystemTime>| time.map(|time| time.t.to_timespec64()) + .unwrap_or(__timespec64::new(0, libc::UTIME_OMIT as _)); + let times = [to_timespec(times.accessed), to_timespec(times.modified)]; + cvt(unsafe { futimens64(self.as_raw_fd(), times.as_ptr()) })?; + return Ok(()); + } + } + let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; cvt(unsafe { libc::futimens(self.as_raw_fd(), times.as_ptr()) })?; Ok(()) } @@ -1254,12 +1270,14 @@ impl DirBuilder { } impl AsInner<FileDesc> for File { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } } impl AsInnerMut<FileDesc> for File { + #[inline] fn as_inner_mut(&mut self) -> &mut FileDesc { &mut self.0 } @@ -1284,6 +1302,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index 9967588939a..ee016887e70 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -129,6 +129,7 @@ pub mod net { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -153,6 +154,7 @@ pub mod net { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } @@ -183,6 +185,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -305,6 +308,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -371,6 +375,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 573bfa6587e..39edb136c24 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -490,6 +490,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -514,6 +515,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/os_str.rs b/library/std/src/sys/unix/os_str.rs index 017e2af29d4..488217f3941 100644 --- a/library/std/src/sys/unix/os_str.rs +++ b/library/std/src/sys/unix/os_str.rs @@ -89,6 +89,7 @@ impl IntoInner<Vec<u8>> for Buf { } impl AsInner<[u8]> for Buf { + #[inline] fn as_inner(&self) -> &[u8] { &self.inner } diff --git a/library/std/src/sys/unix/pipe.rs b/library/std/src/sys/unix/pipe.rs index dc17c9fac46..938a46bfdd8 100644 --- a/library/std/src/sys/unix/pipe.rs +++ b/library/std/src/sys/unix/pipe.rs @@ -135,6 +135,7 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) -> } impl AsRawFd for AnonPipe { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index 6f53583409d..a61d926ca8b 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -166,6 +166,16 @@ impl Timespec { } self.to_timespec() } + + #[cfg(all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") + ))] + pub fn to_timespec64(&self) -> __timespec64 { + __timespec64::new(self.tv_sec, self.tv_nsec.0 as _) + } } impl From<libc::timespec> for Timespec { @@ -196,6 +206,18 @@ pub(in crate::sys::unix) struct __timespec64 { target_pointer_width = "32", not(target_arch = "riscv32") ))] +impl __timespec64 { + pub(in crate::sys::unix) fn new(tv_sec: i64, tv_nsec: i32) -> Self { + Self { tv_sec, tv_nsec, _padding: 0 } + } +} + +#[cfg(all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") +))] impl From<__timespec64> for Timespec { fn from(t: __timespec64) -> Timespec { Timespec::new(t.tv_sec, t.tv_nsec.into()) diff --git a/library/std/src/sys/wasi/fd.rs b/library/std/src/sys/wasi/fd.rs index 191db4b60f7..9a8b2a0be5b 100644 --- a/library/std/src/sys/wasi/fd.rs +++ b/library/std/src/sys/wasi/fd.rs @@ -275,12 +275,14 @@ impl WasiFd { } impl AsInner<OwnedFd> for WasiFd { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.fd } } impl AsInnerMut<OwnedFd> for WasiFd { + #[inline] fn as_inner_mut(&mut self) -> &mut OwnedFd { &mut self.fd } @@ -305,6 +307,7 @@ impl AsFd for WasiFd { } impl AsRawFd for WasiFd { + #[inline] fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() } diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index 3a205267e34..8d1dbf59155 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -498,6 +498,7 @@ impl File { } impl AsInner<WasiFd> for File { + #[inline] fn as_inner(&self) -> &WasiFd { &self.fd } @@ -522,6 +523,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() } diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index 59d94a3686d..2239880ffbe 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -17,6 +17,7 @@ pub struct TcpStream { } impl AsInner<WasiFd> for Socket { + #[inline] fn as_inner(&self) -> &WasiFd { &self.0 } @@ -41,6 +42,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } @@ -184,6 +186,7 @@ impl TcpStream { } } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -274,6 +277,7 @@ impl TcpListener { } } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -284,6 +288,7 @@ impl TcpListener { } impl AsInner<Socket> for TcpListener { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -436,6 +441,7 @@ impl UdpSocket { unsupported() } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -446,6 +452,7 @@ impl UdpSocket { } impl AsInner<Socket> for UdpSocket { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 8ed62cdddcd..f99cdfbecfb 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -832,6 +832,7 @@ fn open_link_no_reparse(parent: &File, name: &[u16], access: u32) -> io::Result< } impl AsInner<Handle> for File { + #[inline] fn as_inner(&self) -> &Handle { &self.handle } diff --git a/library/std/src/sys/windows/handle.rs b/library/std/src/sys/windows/handle.rs index b290f4070e8..c7677d1c13a 100644 --- a/library/std/src/sys/windows/handle.rs +++ b/library/std/src/sys/windows/handle.rs @@ -34,6 +34,7 @@ impl Handle { } impl AsInner<OwnedHandle> for Handle { + #[inline] fn as_inner(&self) -> &OwnedHandle { &self.0 } diff --git a/library/std/src/sys/windows/net.rs b/library/std/src/sys/windows/net.rs index ee1f5482b47..8158713fa84 100644 --- a/library/std/src/sys/windows/net.rs +++ b/library/std/src/sys/windows/net.rs @@ -446,6 +446,7 @@ impl<'a> Read for &'a Socket { } impl AsInner<OwnedSocket> for Socket { + #[inline] fn as_inner(&self) -> &OwnedSocket { &self.0 } diff --git a/library/std/src/sys/windows/os_str.rs b/library/std/src/sys/windows/os_str.rs index 4bdd8c505ff..2f2b0e56e08 100644 --- a/library/std/src/sys/windows/os_str.rs +++ b/library/std/src/sys/windows/os_str.rs @@ -27,6 +27,7 @@ impl FromInner<Wtf8Buf> for Buf { } impl AsInner<Wtf8> for Buf { + #[inline] fn as_inner(&self) -> &Wtf8 { &self.inner } diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index cb24caa1e8a..652c695fc57 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -239,6 +239,7 @@ impl TcpStream { Ok(TcpStream { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -352,6 +353,7 @@ impl TcpStream { } impl AsInner<Socket> for TcpStream { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -427,6 +429,7 @@ impl TcpListener { Ok(TcpListener { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -517,6 +520,7 @@ impl UdpSocket { Ok(UdpSocket { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs index bc588bdbb3c..ff96c35fb0b 100644 --- a/library/std/src/sys_common/wtf8.rs +++ b/library/std/src/sys_common/wtf8.rs @@ -501,6 +501,7 @@ pub struct Wtf8 { } impl AsInner<[u8]> for Wtf8 { + #[inline] fn as_inner(&self) -> &[u8] { &self.bytes } diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 5c2e9da70fb..00e2857a137 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -119,7 +119,7 @@ pub use core::time::TryFromFloatSecsError; /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode -/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get +/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html /// @@ -224,7 +224,7 @@ pub struct Instant(time::Instant); /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [gettimeofday]: https://man7.org/linux/man-pages/man2/gettimeofday.2.html /// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime -/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get +/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get /// [GetSystemTimePreciseAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index 58f746f2e0e..7d7f682130d 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -79,6 +79,7 @@ pub const a_test: test::TestDescAndFn = }; fn a_test() {} #[rustc_main] +#[no_coverage] pub fn main() -> () { extern crate test; test::test_main_static(&[&a_test, &m_test, &z_test]) diff --git a/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt new file mode 100644 index 00000000000..93bd1cfcb48 --- /dev/null +++ b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt @@ -0,0 +1,11 @@ + 1| |// Verify that the entry point injected by the test harness doesn't cause + 2| |// weird artifacts in the coverage report (e.g. issue #10749). + 3| | + 4| |// compile-flags: --test + 5| | + 6| |#[allow(dead_code)] + 7| 0|fn unused() {} + 8| | + 9| 1|#[test] + 10| 1|fn my_test() {} + diff --git a/tests/run-make/coverage/test_harness.rs b/tests/run-make/coverage/test_harness.rs new file mode 100644 index 00000000000..12a755734c1 --- /dev/null +++ b/tests/run-make/coverage/test_harness.rs @@ -0,0 +1,10 @@ +// Verify that the entry point injected by the test harness doesn't cause +// weird artifacts in the coverage report (e.g. issue #10749). + +// compile-flags: --test + +#[allow(dead_code)] +fn unused() {} + +#[test] +fn my_test() {} diff --git a/tests/ui/borrowck/tainted-promoteds.rs b/tests/ui/borrowck/tainted-promoteds.rs new file mode 100644 index 00000000000..2b6f0ddbd6c --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.rs @@ -0,0 +1,12 @@ +// Regression test for issue #110856, where a borrowck error for a MIR tainted +// all promoteds within. This in turn generated a spurious "erroneous constant +// used" note when trying to evaluate a promoted. + +pub fn f() -> u32 { + let a = 0; + a = &0 * &1 * &2 * &3; + //~^ ERROR: cannot assign twice to immutable variable + a +} + +fn main() {} diff --git a/tests/ui/borrowck/tainted-promoteds.stderr b/tests/ui/borrowck/tainted-promoteds.stderr new file mode 100644 index 00000000000..b276ea9aceb --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.stderr @@ -0,0 +1,14 @@ +error[E0384]: cannot assign twice to immutable variable `a` + --> $DIR/tainted-promoteds.rs:7:5 + | +LL | let a = 0; + | - + | | + | first assignment to `a` + | help: consider making this binding mutable: `mut a` +LL | a = &0 * &1 * &2 * &3; + | ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. |
