Skip to content

Rollup of 7 pull requests #111066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_builtin_macros/src/test_harness.rs
Original file line number Diff line number Diff line change
@@ -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 },
5 changes: 1 addition & 4 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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);
}

7 changes: 6 additions & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions library/std/src/net/udp.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions library/std/src/os/linux/process.rs
Original file line number Diff line number Diff line change
@@ -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()
}
16 changes: 11 additions & 5 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
@@ -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");
8 changes: 8 additions & 0 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions library/std/src/sys/hermit/fd.rs
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ impl FromRawFd for FileDesc {
}

impl AsInner<OwnedFd> for FileDesc {
#[inline]
fn as_inner(&self) -> &OwnedFd {
&self.fd
}
3 changes: 3 additions & 0 deletions library/std/src/sys/hermit/fs.rs
Original file line number Diff line number Diff line change
@@ -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()
}
2 changes: 2 additions & 0 deletions library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
@@ -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()
}
1 change: 1 addition & 0 deletions library/std/src/sys/sgx/fd.rs
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ impl FileDesc {
}

impl AsInner<Fd> for FileDesc {
#[inline]
fn as_inner(&self) -> &Fd {
&self.fd
}
3 changes: 3 additions & 0 deletions library/std/src/sys/sgx/net.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions library/std/src/sys/solid/net.rs
Original file line number Diff line number Diff line change
@@ -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()
}
2 changes: 2 additions & 0 deletions library/std/src/sys/unix/fd.rs
Original file line number Diff line number Diff line change
@@ -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()
}
Loading