Skip to content
36 changes: 0 additions & 36 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::convert::{Infallible, TryFrom};
use crate::fmt;
use crate::hash::{self, Hash};
use crate::iter::TrustedLen;
use crate::marker::Unsize;
use crate::mem::{self, MaybeUninit};
use crate::ops::{Index, IndexMut};
use crate::slice::{Iter, IterMut};
Expand All @@ -36,41 +35,6 @@ pub fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }
}

/// Utility trait implemented only on arrays of fixed size
///
/// This trait can be used to implement other traits on fixed-size arrays
/// without causing much metadata bloat.
///
/// The trait is marked unsafe in order to restrict implementors to fixed-size
/// arrays. A user of this trait can assume that implementors have the exact
/// layout in memory of a fixed size array (for example, for unsafe
/// initialization).
///
/// Note that the traits [`AsRef`] and [`AsMut`] provide similar methods for types that
/// may not be fixed-size arrays. Implementors should prefer those traits
/// instead.
#[unstable(feature = "fixed_size_array", issue = "27778")]
pub unsafe trait FixedSizeArray<T> {
/// Converts the array to immutable slice
#[unstable(feature = "fixed_size_array", issue = "27778")]
fn as_slice(&self) -> &[T];
/// Converts the array to mutable slice
#[unstable(feature = "fixed_size_array", issue = "27778")]
fn as_mut_slice(&mut self) -> &mut [T];
}

#[unstable(feature = "fixed_size_array", issue = "27778")]
unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
#[inline]
fn as_slice(&self) -> &[T] {
self
}
#[inline]
fn as_mut_slice(&mut self) -> &mut [T] {
self
}
}

/// The error type returned when a conversion from a slice to an array fails.
#[stable(feature = "try_from", since = "1.34.0")]
#[derive(Debug, Copy, Clone)]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
#![cfg_attr(bootstrap, feature(doc_spotlight))]
#![cfg_attr(not(bootstrap), feature(doc_notable_trait))]
#![feature(duration_consts_2)]
#![feature(duration_saturating_ops)]
#![feature(extended_key_value_attributes)]
#![feature(extern_types)]
#![feature(fundamental)]
Expand Down
9 changes: 3 additions & 6 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,13 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_saturating_ops)]
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 0).saturating_add(Duration::new(0, 1)), Duration::new(0, 1));
/// assert_eq!(Duration::new(1, 0).saturating_add(Duration::new(u64::MAX, 0)), Duration::MAX);
/// ```
#[unstable(feature = "duration_saturating_ops", issue = "76416")]
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn saturating_add(self, rhs: Duration) -> Duration {
Expand Down Expand Up @@ -537,14 +536,13 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_saturating_ops)]
/// #![feature(duration_zero)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1));
/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO);
/// ```
#[unstable(feature = "duration_saturating_ops", issue = "76416")]
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn saturating_sub(self, rhs: Duration) -> Duration {
Expand Down Expand Up @@ -590,14 +588,13 @@ impl Duration {
/// # Examples
///
/// ```
/// #![feature(duration_saturating_ops)]
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 500_000_001).saturating_mul(2), Duration::new(1, 2));
/// assert_eq!(Duration::new(u64::MAX - 1, 0).saturating_mul(2), Duration::MAX);
/// ```
#[unstable(feature = "duration_saturating_ops", issue = "76416")]
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn saturating_mul(self, rhs: u32) -> Duration {
Expand Down
20 changes: 1 addition & 19 deletions library/core/tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
use core::array::{self, FixedSizeArray, IntoIter};
use core::array::{self, IntoIter};
use core::convert::TryFrom;

#[test]
fn fixed_size_array() {
let mut array = [0; 64];
let mut zero_sized = [(); 64];
let mut empty_array = [0; 0];
let mut empty_zero_sized = [(); 0];

assert_eq!(FixedSizeArray::as_slice(&array).len(), 64);
assert_eq!(FixedSizeArray::as_slice(&zero_sized).len(), 64);
assert_eq!(FixedSizeArray::as_slice(&empty_array).len(), 0);
assert_eq!(FixedSizeArray::as_slice(&empty_zero_sized).len(), 0);

assert_eq!(FixedSizeArray::as_mut_slice(&mut array).len(), 64);
assert_eq!(FixedSizeArray::as_mut_slice(&mut zero_sized).len(), 64);
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_array).len(), 0);
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_zero_sized).len(), 0);
}

#[test]
fn array_from_ref() {
let value: String = "Hello World!".into();
Expand Down
2 changes: 0 additions & 2 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
#![feature(div_duration)]
#![feature(duration_consts_2)]
#![feature(duration_constants)]
#![feature(duration_saturating_ops)]
#![feature(duration_zero)]
#![feature(exact_size_is_empty)]
#![feature(extern_types)]
#![feature(fixed_size_array)]
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
/// ```no_run
/// use std::fs;
/// use std::net::SocketAddr;
/// use std::error::Error;
///
/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
/// fn main() -> Result<(), Box<dyn Error>> {
/// let foo: SocketAddr = fs::read_to_string("address.txt")?.parse()?;
/// Ok(())
/// }
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
feature(slice_index_methods, coerce_unsized, sgx_platform)
)]
#![deny(rustc::existing_doc_keyword)]
#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"), feature(fixed_size_array))]
// std is implemented with unstable features, many of which are internal
// compiler details that will never be stable
// NB: the following list is sorted to minimize merge conflicts.
Expand Down
60 changes: 60 additions & 0 deletions src/test/rustdoc-ui/bare-urls.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// run-rustfix

#![deny(rustdoc::bare_urls)]

/// <https://somewhere.com>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com/a>
//~^ ERROR this URL is not a hyperlink
/// <https://www.somewhere.com>
//~^ ERROR this URL is not a hyperlink
/// <https://www.somewhere.com/a>
//~^ ERROR this URL is not a hyperlink
/// <https://subdomain.example.com>
//~^ ERROR not a hyperlink
/// <https://somewhere.com?>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com/a?>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com?hello=12>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com/a?hello=12>
//~^ ERROR this URL is not a hyperlink
/// <https://example.com?hello=12#xyz>
//~^ ERROR this URL is not a hyperlink
/// <https://example.com/a?hello=12#xyz>
//~^ ERROR this URL is not a hyperlink
/// <https://example.com#xyz>
//~^ ERROR this URL is not a hyperlink
/// <https://example.com/a#xyz>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com?hello=12&bye=11>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com/a?hello=12&bye=11>
//~^ ERROR this URL is not a hyperlink
/// <https://somewhere.com?hello=12&bye=11#xyz>
//~^ ERROR this URL is not a hyperlink
/// hey! <https://somewhere.com/a?hello=12&bye=11#xyz>
//~^ ERROR this URL is not a hyperlink
pub fn c() {}

/// <https://somewhere.com>
/// [a](http://a.com)
/// [b]
///
/// [b]: http://b.com
///
/// ```
/// This link should not be linted: http://example.com
///
/// Nor this one: <http://example.com> or this one: [x](http://example.com)
/// ```
///
/// [should_not.lint](should_not.lint)
pub fn everything_is_fine_here() {}

#[allow(rustdoc::bare_urls)]
pub mod foo {
/// https://somewhere.com/a?hello=12&bye=11#xyz
pub fn bar() {}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// run-rustfix

#![deny(rustdoc::bare_urls)]

/// https://somewhere.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:3:5
--> $DIR/bare-urls.rs:5:5
|
LL | /// https://somewhere.com
| ^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com>`
|
note: the lint level is defined here
--> $DIR/url-improvements.rs:1:9
--> $DIR/bare-urls.rs:3:9
|
LL | #![deny(rustdoc::bare_urls)]
| ^^^^^^^^^^^^^^^^^^

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:5:5
--> $DIR/bare-urls.rs:7:5
|
LL | /// https://somewhere.com/a
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:7:5
--> $DIR/bare-urls.rs:9:5
|
LL | /// https://www.somewhere.com
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://www.somewhere.com>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:9:5
--> $DIR/bare-urls.rs:11:5
|
LL | /// https://www.somewhere.com/a
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://www.somewhere.com/a>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:11:5
--> $DIR/bare-urls.rs:13:5
|
LL | /// https://subdomain.example.com
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://subdomain.example.com>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:13:5
--> $DIR/bare-urls.rs:15:5
|
LL | /// https://somewhere.com?
| ^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:15:5
--> $DIR/bare-urls.rs:17:5
|
LL | /// https://somewhere.com/a?
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:17:5
--> $DIR/bare-urls.rs:19:5
|
LL | /// https://somewhere.com?hello=12
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:19:5
--> $DIR/bare-urls.rs:21:5
|
LL | /// https://somewhere.com/a?hello=12
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:21:5
--> $DIR/bare-urls.rs:23:5
|
LL | /// https://example.com?hello=12#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com?hello=12#xyz>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:23:5
--> $DIR/bare-urls.rs:25:5
|
LL | /// https://example.com/a?hello=12#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com/a?hello=12#xyz>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:25:5
--> $DIR/bare-urls.rs:27:5
|
LL | /// https://example.com#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com#xyz>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:27:5
--> $DIR/bare-urls.rs:29:5
|
LL | /// https://example.com/a#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://example.com/a#xyz>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:29:5
--> $DIR/bare-urls.rs:31:5
|
LL | /// https://somewhere.com?hello=12&bye=11
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12&bye=11>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:31:5
--> $DIR/bare-urls.rs:33:5
|
LL | /// https://somewhere.com/a?hello=12&bye=11
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12&bye=11>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:33:5
--> $DIR/bare-urls.rs:35:5
|
LL | /// https://somewhere.com?hello=12&bye=11#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com?hello=12&bye=11#xyz>`

error: this URL is not a hyperlink
--> $DIR/url-improvements.rs:35:10
--> $DIR/bare-urls.rs:37:10
|
LL | /// hey! https://somewhere.com/a?hello=12&bye=11#xyz
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<https://somewhere.com/a?hello=12&bye=11#xyz>`
Expand Down