mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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:
commit
d6ddee637b
@ -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 },
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ impl FromRawFd for FileDesc {
|
||||
}
|
||||
|
||||
impl AsInner<OwnedFd> for FileDesc {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &OwnedFd {
|
||||
&self.fd
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ impl FileDesc {
|
||||
}
|
||||
|
||||
impl AsInner<Fd> for FileDesc {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &Fd {
|
||||
&self.fd
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ impl IntoInner<Vec<u8>> for Buf {
|
||||
}
|
||||
|
||||
impl AsInner<[u8]> for Buf {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &[u8] {
|
||||
&self.inner
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -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",
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ impl Handle {
|
||||
}
|
||||
|
||||
impl AsInner<OwnedHandle> for Handle {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &OwnedHandle {
|
||||
&self.0
|
||||
}
|
||||
|
@ -446,6 +446,7 @@ impl<'a> Read for &'a Socket {
|
||||
}
|
||||
|
||||
impl AsInner<OwnedSocket> for Socket {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &OwnedSocket {
|
||||
&self.0
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ impl FromInner<Wtf8Buf> for Buf {
|
||||
}
|
||||
|
||||
impl AsInner<Wtf8> for Buf {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &Wtf8 {
|
||||
&self.inner
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -501,6 +501,7 @@ pub struct Wtf8 {
|
||||
}
|
||||
|
||||
impl AsInner<[u8]> for Wtf8 {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &[u8] {
|
||||
&self.bytes
|
||||
}
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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])
|
||||
|
@ -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() {}
|
||||
|
10
tests/run-make/coverage/test_harness.rs
Normal file
10
tests/run-make/coverage/test_harness.rs
Normal 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() {}
|
12
tests/ui/borrowck/tainted-promoteds.rs
Normal file
12
tests/ui/borrowck/tainted-promoteds.rs
Normal 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() {}
|
14
tests/ui/borrowck/tainted-promoteds.stderr
Normal file
14
tests/ui/borrowck/tainted-promoteds.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user