From 2a2b212ea3fd8e8bbc4bd209593a943b44fd9aee Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 8 Mar 2022 16:26:10 -0500 Subject: [PATCH 1/7] remove_dir_all: use fallback implementation on Miri --- library/std/src/sys/unix/fs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 03684608f75..ef8a57bdd2e 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1480,14 +1480,14 @@ pub fn chroot(dir: &Path) -> io::Result<()> { pub use remove_dir_impl::remove_dir_all; -// Fallback for REDOX and ESP-IDF -#[cfg(any(target_os = "redox", target_os = "espidf"))] +// Fallback for REDOX and ESP-IDF (and Miri) +#[cfg(any(target_os = "redox", target_os = "espidf", miri))] mod remove_dir_impl { pub use crate::sys_common::fs::remove_dir_all; } // Modern implementation using openat(), unlinkat() and fdopendir() -#[cfg(not(any(target_os = "redox", target_os = "espidf")))] +#[cfg(not(any(target_os = "redox", target_os = "espidf", miri)))] mod remove_dir_impl { use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir}; use crate::ffi::CStr; From 28eb06bd98169c985f4951b6aaf6855d52ffd514 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 8 Mar 2022 20:09:44 -0500 Subject: [PATCH 2/7] docs --- library/std/src/fs.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0b65336a5a7..d3e668ed9c7 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2049,9 +2049,10 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// /// [changes]: io#platform-specific-behavior /// -/// On macOS before version 10.10 and REDOX this function is not protected against time-of-check to -/// time-of-use (TOCTOU) race conditions, and should not be used in security-sensitive code on -/// those platforms. All other platforms are protected. +/// On macOS before version 10.10 and REDOX, as well as when running in Miri for any target, this +/// function is not protected against time-of-check to time-of-use (TOCTOU) race conditions, and +/// should not be used in security-sensitive code on those platforms. All other platforms are +/// protected. /// /// # Errors /// From 08fbe3dafa24429d17009bd5ee475e10a53be9b6 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Mon, 14 Mar 2022 22:01:06 -0400 Subject: [PATCH 3/7] Include tracking issue in diagnostic --- compiler/rustc_attr/src/builtin.rs | 3 +-- .../ui/deprecation/feature-gate-deprecated_suggestion.stderr | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 613320087d2..ffad7dcf557 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -750,8 +750,7 @@ where if sess.is_nightly_build() { diag.help("add `#![feature(deprecated_suggestion)]` to the crate root"); } - // FIXME(jhpratt) change this to an actual tracking issue - diag.note("see #XXX for more details").emit(); + diag.note("see #94785 for more details").emit(); } if !get(mi, &mut suggestion) { diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr index 3b995fed75c..438ce3349d2 100644 --- a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr @@ -5,7 +5,7 @@ LL | #[deprecated(suggestion = "foo")] | ^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(deprecated_suggestion)]` to the crate root - = note: see #XXX for more details + = note: see #94785 for more details error: aborting due to previous error From 06a1fc98eb93ca7062b11ec45053db990a4c127f Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Mon, 14 Mar 2022 22:05:30 -0400 Subject: [PATCH 4/7] Correct meta item diagnostic --- compiler/rustc_attr/src/builtin.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index ffad7dcf557..e1eb014738f 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -763,10 +763,10 @@ where meta.span(), AttrError::UnknownMetaItem( pprust::path_to_string(&mi.path), - if attr.has_name(sym::deprecated) { - &["since", "note"] - } else { + if sess.features_untracked().deprecated_suggestion { &["since", "note", "suggestion"] + } else { + &["since", "note"] }, ), ); From 8a75d5551432512688bdb6865b3858f5d317d9b0 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 15 Mar 2022 20:59:13 -0700 Subject: [PATCH 5/7] Add Stream alias for AsyncIterator --- library/core/src/async_iter/async_iter.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/async_iter/async_iter.rs b/library/core/src/async_iter/async_iter.rs index f29de31171a..016a3685e85 100644 --- a/library/core/src/async_iter/async_iter.rs +++ b/library/core/src/async_iter/async_iter.rs @@ -12,6 +12,7 @@ use crate::task::{Context, Poll}; /// [impl]: index.html#implementing-async-iterator #[unstable(feature = "async_iterator", issue = "79024")] #[must_use = "async iterators do nothing unless polled"] +#[doc(alias = "Stream")] pub trait AsyncIterator { /// The type of items yielded by the async iterator. type Item; From edee46e257ec4aa6d6a78ac4f061cd525ef231f9 Mon Sep 17 00:00:00 2001 From: Waleed Dahshan <58462210+wmstack@users.noreply.github.com> Date: Sat, 19 Mar 2022 18:52:30 +1100 Subject: [PATCH 6/7] Provide more useful documentation of conversion methods I thought that the documentation for these methods needed to be a bit more explanatory for new users. For advanced users, the comments are relatively unnecessary. I think it would be useful to explain precisely what the method does. As a new user, when you see the `into` method, where the type is inferred, if you are new you don't even know what you convert to, because it is implicit. I believe this can help new users understand. --- library/core/src/convert/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index f5ea5f5ba50..e2ffc8c9121 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -154,7 +154,7 @@ pub const fn identity(x: T) -> T { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")] pub trait AsRef { - /// Performs the conversion. + /// Converts this type into a shared reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] fn as_ref(&self) -> &T; } @@ -196,7 +196,7 @@ pub trait AsRef { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")] pub trait AsMut { - /// Performs the conversion. + /// Converts this type into a mutable reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] fn as_mut(&mut self) -> &mut T; } @@ -272,7 +272,7 @@ pub trait AsMut { #[rustc_diagnostic_item = "Into"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { - /// Performs the conversion. + /// Converts this type into the (usually inferred) input type. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn into(self) -> T; @@ -367,7 +367,7 @@ pub trait Into: Sized { note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix", ))] pub trait From: Sized { - /// Performs the conversion. + /// Converts to this type from the input type. #[lang = "from"] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] From 1338a45d9814b031466753a99a58ca688014f9cf Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 19 Mar 2022 02:03:37 -0700 Subject: [PATCH 7/7] Give more details in `Display` for `hir::Target` Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error. ``` error[E0718]: `into_try_type` language item must be applied to a method --> library\core\src\ops\try_trait.rs:352:32 | 352 | #[cfg_attr(not(bootstrap), lang = "into_try_type")] | ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method ``` --- compiler/rustc_hir/src/target.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/target.rs b/compiler/rustc_hir/src/target.rs index 29c948fe318..70d9db4a84b 100644 --- a/compiler/rustc_hir/src/target.rs +++ b/compiler/rustc_hir/src/target.rs @@ -86,7 +86,11 @@ impl Display for Target { Target::Statement => "statement", Target::Arm => "match arm", Target::AssocConst => "associated const", - Target::Method(_) => "method", + Target::Method(kind) => match kind { + MethodKind::Inherent => "inherent method", + MethodKind::Trait { body: false } => "required trait method", + MethodKind::Trait { body: true } => "provided trait method", + }, Target::AssocTy => "associated type", Target::ForeignFn => "foreign function", Target::ForeignStatic => "foreign static item",