Auto merge of #86032 - GuillaumeGomez:rollup-y3ij27b, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #83646 (Add a map method to Bound)
 - #85501 (Fix `deny(invalid_doc_attributes)`)
 - #85503 (rustdoc: add tooltips to some buttons)
 - #85710 (Document `From` impls in path.rs)
 - #85760 (Possible errors when accessing file metadata are platform specific)
 - #85974 (td align attribute)
 - #86014 (msp430 linker does not accept -znoexecstack. Set linker_is_gnu to fal…)

Failed merges:

 - #85972 (Rustdoc html fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-06-05 18:41:36 +00:00
commit ac3e680193
13 changed files with 114 additions and 27 deletions

View file

@ -2994,6 +2994,7 @@ declare_lint_pass! {
USELESS_DEPRECATED,
UNSUPPORTED_NAKED_FUNCTIONS,
MISSING_ABI,
INVALID_DOC_ATTRIBUTES,
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
DISJOINT_CAPTURE_MIGRATION,
LEGACY_DERIVE_HELPERS,

View file

@ -17,6 +17,7 @@ pub fn target() -> Target {
// dependency on this specific gcc.
asm_args: vec!["-mcpu=msp430".to_string()],
linker: Some("msp430-elf-gcc".to_string()),
linker_is_gnu: false,
// There are no atomic CAS instructions available in the MSP430
// instruction set, and the LLVM backend doesn't currently support

View file

@ -674,10 +674,10 @@ pub enum Bound<T> {
Unbounded,
}
#[unstable(feature = "bound_as_ref", issue = "80996")]
impl<T> Bound<T> {
/// Converts from `&Bound<T>` to `Bound<&T>`.
#[inline]
#[unstable(feature = "bound_as_ref", issue = "80996")]
pub fn as_ref(&self) -> Bound<&T> {
match *self {
Included(ref x) => Included(x),
@ -688,6 +688,7 @@ impl<T> Bound<T> {
/// Converts from `&mut Bound<T>` to `Bound<&T>`.
#[inline]
#[unstable(feature = "bound_as_ref", issue = "80996")]
pub fn as_mut(&mut self) -> Bound<&mut T> {
match *self {
Included(ref mut x) => Included(x),
@ -695,6 +696,39 @@ impl<T> Bound<T> {
Unbounded => Unbounded,
}
}
/// Maps a `Bound<T>` to a `Bound<U>` by applying a function to the contained value (including
/// both `Included` and `Excluded`), returning a `Bound` of the same kind.
///
/// # Examples
///
/// ```
/// #![feature(bound_map)]
/// use std::ops::Bound::*;
///
/// let bound_string = Included("Hello, World!");
///
/// assert_eq!(bound_string.map(|s| s.len()), Included(13));
/// ```
///
/// ```
/// #![feature(bound_map)]
/// use std::ops::Bound;
/// use Bound::*;
///
/// let unbounded_string: Bound<String> = Unbounded;
///
/// assert_eq!(unbounded_string.map(|s| s.len()), Unbounded);
/// ```
#[inline]
#[unstable(feature = "bound_map", issue = "86026")]
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Bound<U> {
match self {
Unbounded => Unbounded,
Included(x) => Included(f(x)),
Excluded(x) => Excluded(f(x)),
}
}
}
impl<T: Clone> Bound<&T> {

View file

@ -1420,6 +1420,9 @@ impl Clone for PathBuf {
#[stable(feature = "box_from_path", since = "1.17.0")]
impl From<&Path> for Box<Path> {
/// Creates a boxed [`Path`] from a reference.
///
/// This will allocate and clone `path` to it.
fn from(path: &Path) -> Box<Path> {
let boxed: Box<OsStr> = path.inner.into();
let rw = Box::into_raw(boxed) as *mut Path;
@ -1429,6 +1432,9 @@ impl From<&Path> for Box<Path> {
#[stable(feature = "box_from_cow", since = "1.45.0")]
impl From<Cow<'_, Path>> for Box<Path> {
/// Creates a boxed [`Path`] from a clone-on-write pointer.
///
/// Converting from a `Cow::Owned` does not clone or allocate.
#[inline]
fn from(cow: Cow<'_, Path>) -> Box<Path> {
match cow {
@ -1471,6 +1477,9 @@ impl Clone for Box<Path> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + AsRef<OsStr>> From<&T> for PathBuf {
/// Converts a borrowed `OsStr` to a `PathBuf`.
///
/// Allocates a [`PathBuf`] and copies the data into it.
#[inline]
fn from(s: &T) -> PathBuf {
PathBuf::from(s.as_ref().to_os_string())
@ -1575,6 +1584,10 @@ impl Default for PathBuf {
#[stable(feature = "cow_from_path", since = "1.6.0")]
impl<'a> From<&'a Path> for Cow<'a, Path> {
/// Creates a clone-on-write pointer from a reference to
/// [`Path`].
///
/// This conversion does not clone or allocate.
#[inline]
fn from(s: &'a Path) -> Cow<'a, Path> {
Cow::Borrowed(s)
@ -1583,6 +1596,10 @@ impl<'a> From<&'a Path> for Cow<'a, Path> {
#[stable(feature = "cow_from_path", since = "1.6.0")]
impl<'a> From<PathBuf> for Cow<'a, Path> {
/// Creates a clone-on-write pointer from an owned
/// instance of [`PathBuf`].
///
/// This conversion does not clone or allocate.
#[inline]
fn from(s: PathBuf) -> Cow<'a, Path> {
Cow::Owned(s)
@ -1591,6 +1608,10 @@ impl<'a> From<PathBuf> for Cow<'a, Path> {
#[stable(feature = "cow_from_pathbuf_ref", since = "1.28.0")]
impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
/// Creates a clone-on-write pointer from a reference to
/// [`PathBuf`].
///
/// This conversion does not clone or allocate.
#[inline]
fn from(p: &'a PathBuf) -> Cow<'a, Path> {
Cow::Borrowed(p.as_path())
@ -1599,6 +1620,9 @@ impl<'a> From<&'a PathBuf> for Cow<'a, Path> {
#[stable(feature = "pathbuf_from_cow_path", since = "1.28.0")]
impl<'a> From<Cow<'a, Path>> for PathBuf {
/// Converts a clone-on-write pointer to an owned path.
///
/// Converting from a `Cow::Owned` does not clone or allocate.
#[inline]
fn from(p: Cow<'a, Path>) -> Self {
p.into_owned()
@ -2462,10 +2486,10 @@ impl Path {
/// Returns `true` if the path points at an existing entity.
///
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
/// destination file.
///
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
/// If you cannot access the metadata of the file, e.g. because of a
/// permission error or broken symbolic links, this will return `false`.
///
/// # Examples
///
@ -2513,10 +2537,10 @@ impl Path {
/// Returns `true` if the path exists on disk and is pointing at a regular file.
///
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
/// destination file.
///
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
/// If you cannot access the metadata of the file, e.g. because of a
/// permission error or broken symbolic links, this will return `false`.
///
/// # Examples
///
@ -2545,10 +2569,10 @@ impl Path {
/// Returns `true` if the path exists on disk and is pointing at a directory.
///
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`.
/// destination file.
///
/// If you cannot access the directory containing the file, e.g., because of a
/// permission error, this will return `false`.
/// If you cannot access the metadata of the file, e.g. because of a
/// permission error or broken symbolic links, this will return `false`.
///
/// # Examples
///

View file

@ -82,7 +82,7 @@ pub use core::time::Duration;
/// Currently, the following system calls are being used to get the current time using `now()`:
///
/// | Platform | System call |
/// |:---------:|:--------------------------------------------------------------------:|
/// |-----------|----------------------------------------------------------------------|
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
/// | UNIX | [clock_gettime (Monotonic Clock)] |
/// | Darwin | [mach_absolute_time] |
@ -158,7 +158,7 @@ pub struct Instant(time::Instant);
/// Currently, the following system calls are being used to get the current time using `now()`:
///
/// | Platform | System call |
/// |:---------:|:--------------------------------------------------------------------:|
/// |-----------|----------------------------------------------------------------------|
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
/// | UNIX | [clock_gettime (Realtime Clock)] |
/// | Darwin | [gettimeofday] |

View file

@ -217,8 +217,9 @@ crate fn create_config(
// By default, rustdoc ignores all lints.
// Specifically unblock lints relevant to documentation or the lint machinery itself.
let mut lints_to_show = vec![
// it's unclear whether this should be part of rustdoc directly (#77364)
// it's unclear whether these should be part of rustdoc directly (#77364)
rustc_lint::builtin::MISSING_DOCS.name.to_string(),
rustc_lint::builtin::INVALID_DOC_ATTRIBUTES.name.to_string(),
// these are definitely not part of rustdoc, but we want to warn on them anyway.
rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_string(),
rustc_lint::builtin::UNKNOWN_LINTS.name.to_string(),

View file

@ -87,7 +87,7 @@ crate fn render<T: Print, S: Print>(
{sidebar}\
</nav>\
<div class=\"theme-picker\">\
<button id=\"theme-picker\" aria-label=\"Pick another theme!\" aria-haspopup=\"menu\">\
<button id=\"theme-picker\" aria-label=\"Pick another theme!\" aria-haspopup=\"menu\" title=\"themes\">\
<img src=\"{static_root_path}brush{suffix}.svg\" \
width=\"18\" height=\"18\" \
alt=\"Pick another theme!\">\
@ -105,8 +105,8 @@ crate fn render<T: Print, S: Print>(
placeholder=\"Click or press S to search, ? for more options…\" \
type=\"search\">\
</div>\
<button type=\"button\" id=\"help-button\">?</button>
<a id=\"settings-menu\" href=\"{root_path}settings.html\">\
<button type=\"button\" id=\"help-button\" title=\"help\">?</button>
<a id=\"settings-menu\" href=\"{root_path}settings.html\" title=\"settings\">\
<img src=\"{static_root_path}wheel{suffix}.svg\" \
width=\"18\" height=\"18\" \
alt=\"Change settings\">\

View file

@ -78,7 +78,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer,
write!(buf, "<a class=\"{}\" href=\"#\">{}</a>", item.type_(), item.name.as_ref().unwrap());
write!(
buf,
"<button id=\"copy-path\" onclick=\"copy_path(this)\">\
"<button id=\"copy-path\" onclick=\"copy_path(this)\" title=\"copy path\">\
<img src=\"{static_root_path}clipboard{suffix}.svg\" \
width=\"19\" height=\"18\" \
alt=\"Copy item import\" \

View file

@ -1,9 +1,8 @@
// check-pass
// run-rustfix
#![deny(warnings)]
#![feature(doc_notable_trait)]
#[doc(notable_trait)]
//~^ WARN unknown `doc` attribute `spotlight`
//~^ ERROR unknown `doc` attribute `spotlight`
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
trait MyTrait {}

View file

@ -1,9 +1,8 @@
// check-pass
// run-rustfix
#![deny(warnings)]
#![feature(doc_notable_trait)]
#[doc(spotlight)]
//~^ WARN unknown `doc` attribute `spotlight`
//~^ ERROR unknown `doc` attribute `spotlight`
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
trait MyTrait {}

View file

@ -1,14 +1,19 @@
warning: unknown `doc` attribute `spotlight`
--> $DIR/doc-spotlight.rs:6:7
error: unknown `doc` attribute `spotlight`
--> $DIR/doc-spotlight.rs:5:7
|
LL | #[doc(spotlight)]
| ^^^^^^^^^ help: use `notable_trait` instead
|
= note: `#[warn(invalid_doc_attributes)]` on by default
note: the lint level is defined here
--> $DIR/doc-spotlight.rs:2:9
|
LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]`
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
= note: `doc(spotlight)` was renamed to `doc(notable_trait)`
= note: `doc(spotlight)` is now a no-op
warning: 1 warning emitted
error: aborting due to previous error

View file

@ -0,0 +1,7 @@
#![deny(invalid_doc_attributes)]
//~^ NOTE defined here
#![doc(x)]
//~^ ERROR unknown `doc` attribute `x`
//~| WARNING will become a hard error
//~| NOTE see issue #82730
fn main() {}

View file

@ -0,0 +1,16 @@
error: unknown `doc` attribute `x`
--> $DIR/deny-invalid-doc-attrs.rs:3:8
|
LL | #![doc(x)]
| ^
|
note: the lint level is defined here
--> $DIR/deny-invalid-doc-attrs.rs:1:9
|
LL | #![deny(invalid_doc_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
error: aborting due to previous error