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
This commit is contained in:
bors 2023-05-01 20:35:53 +00:00
commit d6ddee637b
37 changed files with 180 additions and 16 deletions

View file

@ -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 },

View file

@ -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);
}

View file

@ -24,7 +24,7 @@
/// 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 trait Copy: Clone {
/// 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

View file

@ -709,6 +709,7 @@ pub fn set_modified(&self, time: SystemTime) -> io::Result<()> {
// `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 @@ fn _open(&self, path: &Path) -> io::Result<File> {
}
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 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
impl AsInner<fs_imp::FileAttr> for Metadata {
#[inline]
fn as_inner(&self) -> &fs_imp::FileAttr {
&self.0
}
@ -1604,6 +1608,7 @@ pub fn is_symlink(&self) -> bool {
}
impl AsInner<fs_imp::FileType> for FileType {
#[inline]
fn as_inner(&self) -> &fs_imp::FileType {
&self.0
}
@ -1616,6 +1621,7 @@ fn from_inner(f: fs_imp::FilePermissions) -> Permissions {
}
impl AsInner<fs_imp::FilePermissions> for Permissions {
#[inline]
fn as_inner(&self) -> &fs_imp::FilePermissions {
&self.0
}
@ -1770,6 +1776,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
impl AsInner<fs_imp::DirEntry> for DirEntry {
#[inline]
fn as_inner(&self) -> &fs_imp::DirEntry {
&self.0
}
@ -2510,6 +2517,7 @@ fn create_dir_all(&self, path: &Path) -> io::Result<()> {
}
impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
#[inline]
fn as_inner_mut(&mut self) -> &mut fs_imp::DirBuilder {
&mut self.inner
}

View file

@ -691,6 +691,7 @@ fn flush(&mut self) -> io::Result<()> {
}
impl AsInner<net_imp::TcpStream> for TcpStream {
#[inline]
fn as_inner(&self) -> &net_imp::TcpStream {
&self.0
}
@ -1033,6 +1034,7 @@ fn next(&mut self) -> Option<io::Result<TcpStream>> {
impl FusedIterator for IntoIncoming {}
impl AsInner<net_imp::TcpListener> for TcpListener {
#[inline]
fn as_inner(&self) -> &net_imp::TcpListener {
&self.0
}

View file

@ -788,6 +788,7 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
// `AsRawSocket`/`IntoRawSocket`/`FromRawSocket` on Windows.
impl AsInner<net_imp::UdpSocket> for UdpSocket {
#[inline]
fn as_inner(&self) -> &net_imp::UdpSocket {
&self.0
}

View file

@ -52,6 +52,7 @@ pub struct PidFd {
}
impl AsInner<FileDesc> for PidFd {
#[inline]
fn as_inner(&self) -> &FileDesc {
&self.inner
}
@ -70,6 +71,7 @@ fn into_inner(self) -> FileDesc {
}
impl AsRawFd for PidFd {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.as_inner().as_raw_fd()
}

View file

@ -1395,11 +1395,16 @@ pub fn pop(&mut self) -> bool {
///
/// 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 @@ fn _join(&self, path: &Path) -> PathBuf {
/// ```
/// 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");

View file

@ -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 @@ fn flush(&mut self) -> io::Result<()> {
}
impl AsInner<AnonPipe> for ChildStdin {
#[inline]
fn as_inner(&self) -> &AnonPipe {
&self.inner
}
@ -373,6 +375,7 @@ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
}
impl AsInner<AnonPipe> for ChildStdout {
#[inline]
fn as_inner(&self) -> &AnonPipe {
&self.inner
}
@ -438,6 +441,7 @@ fn is_read_vectored(&self) -> bool {
}
impl AsInner<AnonPipe> for ChildStderr {
#[inline]
fn as_inner(&self) -> &AnonPipe {
&self.inner
}
@ -1107,12 +1111,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
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 @@ pub fn code(&self) -> Option<i32> {
}
impl AsInner<imp::ExitStatus> for ExitStatus {
#[inline]
fn as_inner(&self) -> &imp::ExitStatus {
&self.0
}
@ -1884,6 +1891,7 @@ fn from(code: u8) -> Self {
}
impl AsInner<imp::ExitCode> for ExitCode {
#[inline]
fn as_inner(&self) -> &imp::ExitCode {
&self.0
}

View file

@ -75,6 +75,7 @@ unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
}
impl AsInner<OwnedFd> for FileDesc {
#[inline]
fn as_inner(&self) -> &OwnedFd {
&self.fd
}

View file

@ -367,12 +367,14 @@ pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
}
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 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for File {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -340,6 +340,7 @@ pub fn as_raw(&self) -> RawFd {
}
impl AsInner<FileDesc> for Socket {
#[inline]
fn as_inner(&self) -> &FileDesc {
&self.0
}
@ -364,6 +365,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for Socket {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -62,6 +62,7 @@ pub fn flush(&self) -> io::Result<()> {
}
impl AsInner<Fd> for FileDesc {
#[inline]
fn as_inner(&self) -> &Fd {
&self.fd
}

View file

@ -24,6 +24,7 @@ fn new(fd: usercalls::raw::Fd, local_addr: String) -> Socket {
}
impl AsInner<FileDesc> for Socket {
#[inline]
fn as_inner(&self) -> &FileDesc {
&self.inner
}
@ -220,6 +221,7 @@ pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
}
impl AsInner<Socket> for TcpStream {
#[inline]
fn as_inner(&self) -> &Socket {
&self.inner
}
@ -304,6 +306,7 @@ pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
}
impl AsInner<Socket> for TcpListener {
#[inline]
fn as_inner(&self) -> &Socket {
&self.inner
}

View file

@ -112,6 +112,7 @@ fn duplicate(&self) -> io::Result<FileDesc> {
}
impl AsInner<c_int> for FileDesc {
#[inline]
fn as_inner(&self) -> &c_int {
&self.fd
}
@ -462,6 +463,7 @@ pub fn as_raw(&self) -> c_int {
}
impl AsInner<c_int> for Socket {
#[inline]
fn as_inner(&self) -> &c_int {
self.0.as_inner()
}

View file

@ -481,6 +481,7 @@ fn is_read_vectored(&self) -> bool {
}
impl AsInner<OwnedFd> for FileDesc {
#[inline]
fn as_inner(&self) -> &OwnedFd {
&self.0
}
@ -505,6 +506,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for FileDesc {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -547,6 +547,7 @@ pub fn created(&self) -> io::Result<SystemTime> {
}
impl AsInner<stat64> for FileAttr {
#[inline]
fn as_inner(&self) -> &stat64 {
&self.stat
}
@ -1193,8 +1194,6 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
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 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
"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 @@ fn ts_to_tv(ts: &libc::timespec) -> libc::timeval {
})?;
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 @@ pub fn set_mode(&mut self, mode: u32) {
}
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 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for File {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -129,6 +129,7 @@ pub fn as_raw(&self) -> RawFd {
}
impl AsInner<FileDesc> for Socket {
#[inline]
fn as_inner(&self) -> &FileDesc {
&self.0
}
@ -153,6 +154,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for Socket {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
@ -183,6 +185,7 @@ pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
unimpl!();
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -305,6 +308,7 @@ pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
unimpl!();
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -371,6 +375,7 @@ pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
unimpl!();
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}

View file

@ -490,6 +490,7 @@ pub fn as_raw(&self) -> RawFd {
}
impl AsInner<FileDesc> for Socket {
#[inline]
fn as_inner(&self) -> &FileDesc {
&self.0
}
@ -514,6 +515,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for Socket {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -89,6 +89,7 @@ fn into_inner(self) -> Vec<u8> {
}
impl AsInner<[u8]> for Buf {
#[inline]
fn as_inner(&self) -> &[u8] {
&self.inner
}

View file

@ -135,6 +135,7 @@ fn read(fd: &FileDesc, dst: &mut Vec<u8>) -> Result<bool, io::Error> {
}
impl AsRawFd for AnonPipe {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}

View file

@ -166,6 +166,16 @@ pub(super) fn to_timespec_capped(&self) -> Option<libc::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 {
@ -190,6 +200,18 @@ pub(in crate::sys::unix) struct __timespec64 {
_padding: i32,
}
#[cfg(all(
target_os = "linux",
target_env = "gnu",
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",

View file

@ -275,12 +275,14 @@ pub fn sock_shutdown(&self, how: Shutdown) -> io::Result<()> {
}
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 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for WasiFd {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.fd.as_raw_fd()
}

View file

@ -498,6 +498,7 @@ pub fn read_link(&self, file: &Path) -> io::Result<PathBuf> {
}
impl AsInner<WasiFd> for File {
#[inline]
fn as_inner(&self) -> &WasiFd {
&self.fd
}
@ -522,6 +523,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for File {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.fd.as_raw_fd()
}

View file

@ -17,6 +17,7 @@ pub struct TcpStream {
}
impl AsInner<WasiFd> for Socket {
#[inline]
fn as_inner(&self) -> &WasiFd {
&self.0
}
@ -41,6 +42,7 @@ fn as_fd(&self) -> BorrowedFd<'_> {
}
impl AsRawFd for Socket {
#[inline]
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
@ -184,6 +186,7 @@ pub fn set_nonblocking(&self, state: bool) -> io::Result<()> {
}
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -274,6 +277,7 @@ pub fn set_nonblocking(&self, state: bool) -> io::Result<()> {
}
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -284,6 +288,7 @@ pub fn into_socket(self) -> Socket {
}
impl AsInner<Socket> for TcpListener {
#[inline]
fn as_inner(&self) -> &Socket {
&self.inner
}
@ -436,6 +441,7 @@ pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> {
unsupported()
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -446,6 +452,7 @@ pub fn into_socket(self) -> Socket {
}
impl AsInner<Socket> for UdpSocket {
#[inline]
fn as_inner(&self) -> &Socket {
&self.inner
}

View file

@ -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
}

View file

@ -34,6 +34,7 @@ pub fn new_event(manual: bool, init: bool) -> io::Result<Handle> {
}
impl AsInner<OwnedHandle> for Handle {
#[inline]
fn as_inner(&self) -> &OwnedHandle {
&self.0
}

View file

@ -446,6 +446,7 @@ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
}
impl AsInner<OwnedSocket> for Socket {
#[inline]
fn as_inner(&self) -> &OwnedSocket {
&self.0
}

View file

@ -27,6 +27,7 @@ fn from_inner(inner: Wtf8Buf) -> Self {
}
impl AsInner<Wtf8> for Buf {
#[inline]
fn as_inner(&self) -> &Wtf8 {
&self.inner
}

View file

@ -239,6 +239,7 @@ pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpSt
Ok(TcpStream { inner: sock })
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -352,6 +353,7 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
}
impl AsInner<Socket> for TcpStream {
#[inline]
fn as_inner(&self) -> &Socket {
&self.inner
}
@ -427,6 +429,7 @@ pub fn bind(addr: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
Ok(TcpListener { inner: sock })
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}
@ -517,6 +520,7 @@ pub fn bind(addr: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
Ok(UdpSocket { inner: sock })
}
#[inline]
pub fn socket(&self) -> &Socket {
&self.inner
}

View file

@ -501,6 +501,7 @@ pub struct Wtf8 {
}
impl AsInner<[u8]> for Wtf8 {
#[inline]
fn as_inner(&self) -> &[u8] {
&self.bytes
}

View file

@ -119,7 +119,7 @@
/// [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 @@
/// [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
///

View file

@ -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])

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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`.