Skip to content
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

Rollup of 7 pull requests #86032

Merged
merged 14 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 35 additions & 1 deletion library/core/src/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -688,13 +688,47 @@ 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),
Excluded(ref mut x) => Excluded(x),
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> {
Expand Down
42 changes: 33 additions & 9 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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()
Expand Down Expand Up @@ -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
///
Expand Down Expand Up @@ -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
///
Expand Down Expand Up @@ -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
///
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] |
Expand Down Expand Up @@ -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] |
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!\">\
Expand All @@ -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\">\
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\" \
Expand Down
5 changes: 2 additions & 3 deletions src/test/rustdoc-ui/doc-spotlight.fixed
Original file line number Diff line number Diff line change
@@ -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 {}
5 changes: 2 additions & 3 deletions src/test/rustdoc-ui/doc-spotlight.rs
Original file line number Diff line number Diff line change
@@ -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 {}
13 changes: 9 additions & 4 deletions src/test/rustdoc-ui/doc-spotlight.stderr
Original file line number Diff line number Diff line change
@@ -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

7 changes: 7 additions & 0 deletions src/test/ui/rustdoc/deny-invalid-doc-attrs.rs
Original file line number Diff line number Diff line change
@@ -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() {}
16 changes: 16 additions & 0 deletions src/test/ui/rustdoc/deny-invalid-doc-attrs.stderr
Original file line number Diff line number Diff line change
@@ -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