From 503cedac0c33782ab2ec6765f6b790850d260bd2 Mon Sep 17 00:00:00 2001 From: Nick Hynes Date: Tue, 16 Jul 2019 02:34:00 +0000 Subject: [PATCH 01/19] Test that maplike FromIter satisfies uniqueness --- src/libstd/collections/hash/map.rs | 4 +++- src/libstd/collections/hash/set.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 2925d8362c8d9..1e28ee8da26b4 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -3138,13 +3138,15 @@ mod test_map { #[test] fn test_from_iter() { - let xs = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; + let xs = [(1, 1), (2, 2), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]; let map: HashMap<_, _> = xs.iter().cloned().collect(); for &(k, v) in &xs { assert_eq!(map.get(&k), Some(&v)); } + + assert_eq!(map.iter().len(), xs.len() - 1); } #[test] diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 403914c070780..d243412405a79 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1782,13 +1782,15 @@ mod test_set { #[test] fn test_from_iter() { - let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + let xs = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]; let set: HashSet<_> = xs.iter().cloned().collect(); for x in &xs { assert!(set.contains(x)); } + + assert_eq!(set.iter().len(), xs.len() - 1); } #[test] From 8040c54b085967bc6b29cf6d27eda5908c204ca3 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 16 Jul 2019 08:51:53 +0200 Subject: [PATCH 02/19] Stabilize <*mut _>::cast and <*const _>::cast FCP: https://github.com/rust-lang/rust/issues/60602#issuecomment-511146402 --- src/libcore/ptr/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index df66a2978de41..a7f6926de4263 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -1043,7 +1043,7 @@ impl *const T { } /// Cast to a pointer to a different type - #[unstable(feature = "ptr_cast", issue = "60602")] + #[stable(feature = "ptr_cast", since = "1.38.0")] #[inline] pub const fn cast(self) -> *const U { self as _ @@ -1678,7 +1678,7 @@ impl *mut T { } /// Cast to a pointer to a different type - #[unstable(feature = "ptr_cast", issue = "60602")] + #[stable(feature = "ptr_cast", since = "1.38.0")] #[inline] pub const fn cast(self) -> *mut U { self as _ From 48b6069eafa1a2d0904ef39596604a93fe99ed6a Mon Sep 17 00:00:00 2001 From: Martin Indra Date: Thu, 18 Jul 2019 21:03:56 +0200 Subject: [PATCH 03/19] Fix typo in src/libstd/net/udp.rs doc comment Affect is usually used as a verb, effect as a verb. --- src/libstd/net/udp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 61d9149952ee5..c430e103951f1 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -422,7 +422,7 @@ impl UdpSocket { /// Sets the value of the `IP_MULTICAST_LOOP` option for this socket. /// /// If enabled, multicast packets will be looped back to the local socket. - /// Note that this may not have any affect on IPv6 sockets. + /// Note that this may not have any effect on IPv6 sockets. /// /// # Examples /// @@ -464,7 +464,7 @@ impl UdpSocket { /// this socket. The default value is 1 which means that multicast packets /// don't leave the local network unless explicitly requested. /// - /// Note that this may not have any affect on IPv6 sockets. + /// Note that this may not have any effect on IPv6 sockets. /// /// # Examples /// From 886fb218ed1daf519a8517ab5e382b55fb6ff659 Mon Sep 17 00:00:00 2001 From: Samy Kacimi Date: Thu, 18 Jul 2019 22:32:24 +0200 Subject: [PATCH 04/19] normalize use of backticks in compiler messages for libcore/ptr https://github.com/rust-lang/rust/issues/60532 --- src/libcore/ptr/unique.rs | 4 ++-- src/test/ui/feature-gate/issue-49983-see-issue-0.stderr | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/ptr/unique.rs b/src/libcore/ptr/unique.rs index 5911518919e6d..d2517e51fc5a6 100644 --- a/src/libcore/ptr/unique.rs +++ b/src/libcore/ptr/unique.rs @@ -26,8 +26,8 @@ use crate::ptr::NonNull; /// Unlike `*mut T`, `Unique` is covariant over `T`. This should always be correct /// for any type which upholds Unique's aliasing requirements. #[unstable(feature = "ptr_internals", issue = "0", - reason = "use NonNull instead and consider PhantomData \ - (if you also use #[may_dangle]), Send, and/or Sync")] + reason = "use `NonNull` instead and consider `PhantomData` \ + (if you also use `#[may_dangle]`), `Send`, and/or `Sync`")] #[doc(hidden)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] diff --git a/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr b/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr index adbbebd40c57f..314238a34df86 100644 --- a/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr +++ b/src/test/ui/feature-gate/issue-49983-see-issue-0.stderr @@ -1,4 +1,4 @@ -error[E0658]: use of unstable library feature 'ptr_internals': use NonNull instead and consider PhantomData (if you also use #[may_dangle]), Send, and/or Sync +error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData` (if you also use `#[may_dangle]`), `Send`, and/or `Sync` --> $DIR/issue-49983-see-issue-0.rs:4:30 | LL | #[allow(unused_imports)] use core::ptr::Unique; From 33452b0587ad543c6d7cc0f41daad6d4be71842f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 17 Jul 2019 09:33:08 +0200 Subject: [PATCH 05/19] warn about deprecated-in-future in most of libstd --- src/libstd/lib.rs | 2 +- src/libstd/sync/mod.rs | 2 +- src/libstd/sys/cloudabi/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index f394195d77aca..79b2f09f40af1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -205,7 +205,7 @@ // Don't link to std. We are std. #![no_std] -//#![warn(deprecated_in_future)] // FIXME: std still has quite a few uses of `mem::uninitialized` +#![warn(deprecated_in_future)] #![warn(missing_docs)] #![warn(missing_debug_implementations)] #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index fd6e46fd61dc5..5d4cdb16472cb 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -163,7 +163,7 @@ pub use self::condvar::{Condvar, WaitTimeoutResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated)] +#[allow(deprecated_in_future)] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; diff --git a/src/libstd/sys/cloudabi/mod.rs b/src/libstd/sys/cloudabi/mod.rs index 3fef7552259c8..77a52a8743d95 100644 --- a/src/libstd/sys/cloudabi/mod.rs +++ b/src/libstd/sys/cloudabi/mod.rs @@ -1,4 +1,4 @@ -#![allow(deprecated)] // mem::uninitialized +#![allow(deprecated_in_future)] // mem::uninitialized; becomes `deprecated` when nightly is 1.39 use crate::io::ErrorKind; use crate::mem; From 13ed0cf9e86a4fdbf75152849353050fea5d4461 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 17 Jul 2019 09:51:58 +0200 Subject: [PATCH 06/19] do not use mem::uninitialized in std::io --- src/libcore/fmt/float.rs | 7 ++++--- src/libstd/io/util.rs | 24 ++++++++++-------------- src/libstd/lib.rs | 1 + 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 4bd7d3b4b22e3..a2fff913ac720 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -12,10 +12,11 @@ fn float_to_decimal_common_exact(fmt: &mut Formatter<'_>, num: &T, unsafe { let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64 let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit(); - // FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized - // `MaybeUninit` (here and elsewhere in this file). Revisit this once + // FIXME(#53491): This is calling `get_mut` on an uninitialized + // `MaybeUninit` (here and elsewhere in this file). Revisit this once // we decided whether that is valid or not. - // Using `freeze` is *not enough*; `flt2dec::Part` is an enum! + // We can do this only because we are libstd and coupled to the compiler. + // (FWIW, using `freeze` would not be enough; `flt2dec::Part` is an enum!) let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact, *num, sign, precision, false, buf.get_mut(), parts.get_mut()); diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 1efccb53b7551..20979e02a4373 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -2,7 +2,7 @@ use crate::fmt; use crate::io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoSlice, IoSliceMut}; -use crate::mem; +use crate::mem::MaybeUninit; /// Copies the entire contents of a reader into a writer. /// @@ -43,27 +43,23 @@ use crate::mem; pub fn copy(reader: &mut R, writer: &mut W) -> io::Result where R: Read, W: Write { - let mut buf = unsafe { - // This is still technically undefined behavior due to creating a reference - // to uninitialized data, but within libstd we can rely on more guarantees - // than if this code were in an external lib - - // FIXME: This should probably be changed to an array of `MaybeUninit` - // once the `mem::MaybeUninit` slice APIs stabilize - let mut buf: mem::MaybeUninit<[u8; super::DEFAULT_BUF_SIZE]> = mem::MaybeUninit::uninit(); - reader.initializer().initialize(&mut *buf.as_mut_ptr()); - buf.assume_init() - }; + let mut buf = MaybeUninit::<[u8; super::DEFAULT_BUF_SIZE]>::uninit(); + // FIXME(#53491): This is calling `get_mut` and `get_ref` on an uninitialized + // `MaybeUninit`. Revisit this once we decided whether that is valid or not. + // This is still technically undefined behavior due to creating a reference + // to uninitialized data, but within libstd we can rely on more guarantees + // than if this code were in an external lib + unsafe { reader.initializer().initialize(buf.get_mut()); } let mut written = 0; loop { - let len = match reader.read(&mut buf) { + let len = match reader.read(unsafe { buf.get_mut() }) { Ok(0) => return Ok(written), Ok(len) => len, Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => return Err(e), }; - writer.write_all(&buf[..len])?; + writer.write_all(unsafe { &buf.get_ref()[..len] })?; written += len as u64; } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 79b2f09f40af1..49fb4be39b451 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -272,6 +272,7 @@ #![feature(libc)] #![feature(link_args)] #![feature(linkage)] +#![feature(maybe_uninit_ref)] #![feature(mem_take)] #![feature(needs_panic_runtime)] #![feature(never_type)] From 7c1e4054787f99dff36aa66318b7589f78dfc7d9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 17 Jul 2019 10:34:34 +0200 Subject: [PATCH 07/19] ONCE_INIT is deprecated-in-future only for bootstrap --- src/libstd/io/util.rs | 2 +- src/libstd/sync/mod.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 20979e02a4373..33cc87eb79555 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -48,7 +48,7 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< // `MaybeUninit`. Revisit this once we decided whether that is valid or not. // This is still technically undefined behavior due to creating a reference // to uninitialized data, but within libstd we can rely on more guarantees - // than if this code were in an external lib + // than if this code were in an external lib. unsafe { reader.initializer().initialize(buf.get_mut()); } let mut written = 0; diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 5d4cdb16472cb..e29faf18d83e5 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -163,7 +163,8 @@ pub use self::condvar::{Condvar, WaitTimeoutResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] -#[allow(deprecated_in_future)] +#[cfg_attr(bootstrap, allow(deprecated_in_future))] +#[allow(deprecated)] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; From e074db764a0f25af073cb3f472d39a86e6fa7f39 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 19 Jul 2019 10:44:11 +0200 Subject: [PATCH 08/19] use const array repeat expressions for uninit_array --- src/liballoc/collections/btree/node.rs | 6 +++--- src/liballoc/lib.rs | 1 + src/libcore/fmt/num.rs | 4 ++-- src/libcore/lib.rs | 1 + src/libcore/macros.rs | 23 ++++++++++++++++++++--- src/libcore/mem/maybe_uninit.rs | 1 + src/libcore/slice/sort.rs | 4 ++-- 7 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 7cf077d61d687..e067096f0c780 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -106,8 +106,8 @@ impl LeafNode { LeafNode { // As a general policy, we leave fields uninitialized if they can be, as this should // be both slightly faster and easier to track in Valgrind. - keys: uninitialized_array![_; CAPACITY], - vals: uninitialized_array![_; CAPACITY], + keys: uninit_array![_; CAPACITY], + vals: uninit_array![_; CAPACITY], parent: ptr::null(), parent_idx: MaybeUninit::uninit(), len: 0 @@ -159,7 +159,7 @@ impl InternalNode { unsafe fn new() -> Self { InternalNode { data: LeafNode::new(), - edges: uninitialized_array![_; 2*B], + edges: uninit_array![_; 2*B], } } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 2e48825e81c29..68df0137ee637 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -77,6 +77,7 @@ #![feature(box_syntax)] #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] +#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] #![feature(dispatch_from_dyn)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index f9b4c26496cdc..e2d00e654ddb8 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -51,7 +51,7 @@ trait GenericRadix { // characters for a base 2 number. let zero = T::zero(); let is_nonnegative = x >= zero; - let mut buf = uninitialized_array![u8; 128]; + let mut buf = uninit_array![u8; 128]; let mut curr = buf.len(); let base = T::from_u8(Self::BASE); if is_nonnegative { @@ -189,7 +189,7 @@ static DEC_DIGITS_LUT: &[u8; 200] = macro_rules! impl_Display { ($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => { fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut buf = uninitialized_array![u8; 39]; + let mut buf = uninit_array![u8; 39]; let mut curr = buf.len() as isize; let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf); let lut_ptr = DEC_DIGITS_LUT.as_ptr(); diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index fe149d634e223..8d3c42cbf3501 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -75,6 +75,7 @@ #![feature(const_fn)] #![feature(const_fn_union)] #![cfg_attr(not(bootstrap), feature(const_generics))] +#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] #![feature(custom_inner_attributes)] #![feature(decl_macro)] #![feature(doc_cfg)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 293a2dd94922f..9855c5fb9c32f 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -626,20 +626,37 @@ macro_rules! todo { /// Creates an array of [`MaybeUninit`]. /// /// This macro constructs an uninitialized array of the type `[MaybeUninit; N]`. +/// It exists solely because bootstrap does not yet support const array-init expressions. /// /// [`MaybeUninit`]: mem/union.MaybeUninit.html +// FIXME: Remove both versions of this macro once bootstrap is 1.38. #[macro_export] #[unstable(feature = "maybe_uninit_array", issue = "53491")] -macro_rules! uninitialized_array { +#[cfg(bootstrap)] +macro_rules! uninit_array { // This `assume_init` is safe because an array of `MaybeUninit` does not // require initialization. - // FIXME(#49147): Could be replaced by an array initializer, once those can - // be any const expression. ($t:ty; $size:expr) => (unsafe { MaybeUninit::<[MaybeUninit<$t>; $size]>::uninit().assume_init() }); } +/// Creates an array of [`MaybeUninit`]. +/// +/// This macro constructs an uninitialized array of the type `[MaybeUninit; N]`. +/// It exists solely because bootstrap does not yet support const array-init expressions. +/// +/// [`MaybeUninit`]: mem/union.MaybeUninit.html +// FIXME: Just inline this version of the macro once bootstrap is 1.38. +#[macro_export] +#[unstable(feature = "maybe_uninit_array", issue = "53491")] +#[cfg(not(bootstrap))] +macro_rules! uninit_array { + ($t:ty; $size:expr) => ( + [MaybeUninit::<$t>::uninit(); $size] + ); +} + /// Built-in macros to the compiler itself. /// /// These macros do not have any corresponding definition with a `macro_rules!` diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index f6f7ccffdb005..1c69e7f90f6c7 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -248,6 +248,7 @@ impl MaybeUninit { /// [type]: union.MaybeUninit.html #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline(always)] + #[rustc_promotable] pub const fn uninit() -> MaybeUninit { MaybeUninit { uninit: () } } diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index c293b1900187e..fbf9caeaece56 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -216,14 +216,14 @@ fn partition_in_blocks(v: &mut [T], pivot: &T, is_less: &mut F) -> usize let mut block_l = BLOCK; let mut start_l = ptr::null_mut(); let mut end_l = ptr::null_mut(); - let mut offsets_l: [MaybeUninit; BLOCK] = uninitialized_array![u8; BLOCK]; + let mut offsets_l: [MaybeUninit; BLOCK] = uninit_array![u8; BLOCK]; // The current block on the right side (from `r.sub(block_r)` to `r`). let mut r = unsafe { l.add(v.len()) }; let mut block_r = BLOCK; let mut start_r = ptr::null_mut(); let mut end_r = ptr::null_mut(); - let mut offsets_r: [MaybeUninit; BLOCK] = uninitialized_array![u8; BLOCK]; + let mut offsets_r: [MaybeUninit; BLOCK] = uninit_array![u8; BLOCK]; // FIXME: When we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather // than two fixed-size arrays of length `BLOCK`. VLAs might be more cache-efficient. From ad261f6852c928d3ce0a6dd34ec6c3a38792e4de Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 19 Jul 2019 17:23:47 +0200 Subject: [PATCH 09/19] avoid uninit_array! macro where it is not needed --- src/libcore/fmt/num.rs | 4 ++-- src/libcore/lib.rs | 1 - src/libcore/slice/sort.rs | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index e2d00e654ddb8..3b5c9fbff250a 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -51,7 +51,7 @@ trait GenericRadix { // characters for a base 2 number. let zero = T::zero(); let is_nonnegative = x >= zero; - let mut buf = uninit_array![u8; 128]; + let mut buf = [MaybeUninit::::uninit(); 128]; let mut curr = buf.len(); let base = T::from_u8(Self::BASE); if is_nonnegative { @@ -189,7 +189,7 @@ static DEC_DIGITS_LUT: &[u8; 200] = macro_rules! impl_Display { ($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => { fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut buf = uninit_array![u8; 39]; + let mut buf = [MaybeUninit::::uninit(); 39]; let mut curr = buf.len() as isize; let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf); let lut_ptr = DEC_DIGITS_LUT.as_ptr(); diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 8d3c42cbf3501..fe149d634e223 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -75,7 +75,6 @@ #![feature(const_fn)] #![feature(const_fn_union)] #![cfg_attr(not(bootstrap), feature(const_generics))] -#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] #![feature(custom_inner_attributes)] #![feature(decl_macro)] #![feature(doc_cfg)] diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs index fbf9caeaece56..2f2170f7ff14c 100644 --- a/src/libcore/slice/sort.rs +++ b/src/libcore/slice/sort.rs @@ -216,14 +216,14 @@ fn partition_in_blocks(v: &mut [T], pivot: &T, is_less: &mut F) -> usize let mut block_l = BLOCK; let mut start_l = ptr::null_mut(); let mut end_l = ptr::null_mut(); - let mut offsets_l: [MaybeUninit; BLOCK] = uninit_array![u8; BLOCK]; + let mut offsets_l = [MaybeUninit::::uninit(); BLOCK]; // The current block on the right side (from `r.sub(block_r)` to `r`). let mut r = unsafe { l.add(v.len()) }; let mut block_r = BLOCK; let mut start_r = ptr::null_mut(); let mut end_r = ptr::null_mut(); - let mut offsets_r: [MaybeUninit; BLOCK] = uninit_array![u8; BLOCK]; + let mut offsets_r = [MaybeUninit::::uninit(); BLOCK]; // FIXME: When we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather // than two fixed-size arrays of length `BLOCK`. VLAs might be more cache-efficient. From 19a848d2eae3824c14bd0e7f37b096215f4c5a1f Mon Sep 17 00:00:00 2001 From: Samy Kacimi Date: Fri, 19 Jul 2019 20:08:21 +0200 Subject: [PATCH 10/19] normalize use of backticks in compiler messages for librustc_metadata https://github.com/rust-lang/rust/issues/60532 --- src/librustc_metadata/creader.rs | 6 +++--- src/librustc_metadata/error_codes.rs | 5 +++-- src/librustc_metadata/native_libs.rs | 8 ++++---- src/test/ui/allocator/two-allocators2.rs | 2 +- src/test/ui/allocator/two-allocators2.stderr | 2 +- src/test/ui/allocator/two-allocators3.rs | 2 +- src/test/ui/allocator/two-allocators3.stderr | 2 +- src/test/ui/bad/bad-extern-link-attrs.stderr | 4 ++-- src/test/ui/empty/empty-linkname.stderr | 2 +- src/test/ui/error-codes/E0454.stderr | 2 +- src/test/ui/error-codes/E0458.stderr | 2 +- src/test/ui/error-codes/E0459.stderr | 2 +- src/test/ui/missing/missing-allocator.stderr | 2 +- src/test/ui/rfc1717/missing-link-attr.stderr | 2 +- src/test/ui/wasm-import-module.stderr | 6 +++--- 15 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 2073b317939d7..126cfec157ff3 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -938,14 +938,14 @@ impl<'a> CrateLoader<'a> { } match global_allocator { Some(Some(other_crate)) => { - self.sess.err(&format!("the #[global_allocator] in {} \ + self.sess.err(&format!("the `#[global_allocator]` in {} \ conflicts with this global \ allocator in: {}", other_crate, data.root.name)); } Some(None) => { - self.sess.err(&format!("the #[global_allocator] in this \ + self.sess.err(&format!("the `#[global_allocator]` in this \ crate conflicts with global \ allocator in: {}", data.root.name)); } @@ -971,7 +971,7 @@ impl<'a> CrateLoader<'a> { if !has_default { self.sess.err("no global memory allocator found but one is \ required; link to std or \ - add #[global_allocator] to a static item \ + add `#[global_allocator]` to a static item \ that implements the GlobalAlloc trait."); } self.sess.allocator_kind.set(Some(AllocatorKind::DefaultLib)); diff --git a/src/librustc_metadata/error_codes.rs b/src/librustc_metadata/error_codes.rs index 7c63173659135..909fca2ab586f 100644 --- a/src/librustc_metadata/error_codes.rs +++ b/src/librustc_metadata/error_codes.rs @@ -7,7 +7,8 @@ E0454: r##" A link name was given with an empty name. Erroneous code example: ```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen) -#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name +#[link(name = "")] extern {} +// error: `#[link(name = "")]` given with empty name ``` The rust compiler cannot link to an external library if you don't give it its @@ -61,7 +62,7 @@ A link was used without a name parameter. Erroneous code example: ```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen) #[link(kind = "dylib")] extern {} -// error: #[link(...)] specified without `name = "foo"` +// error: `#[link(...)]` specified without `name = "foo"` ``` Please add the name parameter to allow the rust compiler to find the library diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 5da5384f8aaa7..66971bb6f8b1c 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -102,7 +102,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> { match item.value_str() { Some(s) => lib.wasm_import_module = Some(s), None => { - let msg = "must be of the form #[link(wasm_import_module = \"...\")]"; + let msg = "must be of the form `#[link(wasm_import_module = \"...\")]`"; self.tcx.sess.span_err(item.span(), msg); } } @@ -117,7 +117,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> { let requires_name = kind_specified || lib.wasm_import_module.is_none(); if lib.name.is_none() && requires_name { struct_span_err!(self.tcx.sess, m.span, E0459, - "#[link(...)] specified without \ + "`#[link(...)]` specified without \ `name = \"foo\"`") .span_label(m.span, "missing `name` argument") .emit(); @@ -136,7 +136,7 @@ impl Collector<'tcx> { match span { Some(span) => { struct_span_err!(self.tcx.sess, span, E0454, - "#[link(name = \"\")] given with empty name") + "`#[link(name = \"\")]` given with empty name") .span_label(span, "empty name given") .emit(); } @@ -187,7 +187,7 @@ impl Collector<'tcx> { &format!("an empty renaming target was specified for library `{}`",name)); } else if !any_duplicate { self.tcx.sess.err(&format!("renaming of the library `{}` was specified, \ - however this crate contains no #[link(...)] \ + however this crate contains no `#[link(...)]` \ attributes referencing this library.", name)); } else if renames.contains(name) { self.tcx.sess.err(&format!("multiple renamings were \ diff --git a/src/test/ui/allocator/two-allocators2.rs b/src/test/ui/allocator/two-allocators2.rs index 96da780e4a254..6dfefe19c7fa4 100644 --- a/src/test/ui/allocator/two-allocators2.rs +++ b/src/test/ui/allocator/two-allocators2.rs @@ -1,6 +1,6 @@ // aux-build:system-allocator.rs // no-prefer-dynamic -// error-pattern: the #[global_allocator] in +// error-pattern: the `#[global_allocator]` in extern crate system_allocator; diff --git a/src/test/ui/allocator/two-allocators2.stderr b/src/test/ui/allocator/two-allocators2.stderr index 2b23ce38ede76..b1fb4421ea048 100644 --- a/src/test/ui/allocator/two-allocators2.stderr +++ b/src/test/ui/allocator/two-allocators2.stderr @@ -1,4 +1,4 @@ -error: the #[global_allocator] in this crate conflicts with global allocator in: system_allocator +error: the `#[global_allocator]` in this crate conflicts with global allocator in: system_allocator error: aborting due to previous error diff --git a/src/test/ui/allocator/two-allocators3.rs b/src/test/ui/allocator/two-allocators3.rs index 8a06335c0318a..31dea2d4478f7 100644 --- a/src/test/ui/allocator/two-allocators3.rs +++ b/src/test/ui/allocator/two-allocators3.rs @@ -1,7 +1,7 @@ // aux-build:system-allocator.rs // aux-build:system-allocator2.rs // no-prefer-dynamic -// error-pattern: the #[global_allocator] in +// error-pattern: the `#[global_allocator]` in extern crate system_allocator; diff --git a/src/test/ui/allocator/two-allocators3.stderr b/src/test/ui/allocator/two-allocators3.stderr index 86e385a96a1b6..ecffb192e2acb 100644 --- a/src/test/ui/allocator/two-allocators3.stderr +++ b/src/test/ui/allocator/two-allocators3.stderr @@ -1,4 +1,4 @@ -error: the #[global_allocator] in system_allocator conflicts with this global allocator in: system_allocator2 +error: the `#[global_allocator]` in system_allocator conflicts with this global allocator in: system_allocator2 error: aborting due to previous error diff --git a/src/test/ui/bad/bad-extern-link-attrs.stderr b/src/test/ui/bad/bad-extern-link-attrs.stderr index 18b0dc9ea386e..525c605a9cf67 100644 --- a/src/test/ui/bad/bad-extern-link-attrs.stderr +++ b/src/test/ui/bad/bad-extern-link-attrs.stderr @@ -1,10 +1,10 @@ -error[E0459]: #[link(...)] specified without `name = "foo"` +error[E0459]: `#[link(...)]` specified without `name = "foo"` --> $DIR/bad-extern-link-attrs.rs:1:1 | LL | #[link()] | ^^^^^^^^^ missing `name` argument -error[E0454]: #[link(name = "")] given with empty name +error[E0454]: `#[link(name = "")]` given with empty name --> $DIR/bad-extern-link-attrs.rs:2:1 | LL | #[link(name = "")] diff --git a/src/test/ui/empty/empty-linkname.stderr b/src/test/ui/empty/empty-linkname.stderr index df41cb894139c..b9d1841f16ca3 100644 --- a/src/test/ui/empty/empty-linkname.stderr +++ b/src/test/ui/empty/empty-linkname.stderr @@ -1,4 +1,4 @@ -error[E0454]: #[link(name = "")] given with empty name +error[E0454]: `#[link(name = "")]` given with empty name --> $DIR/empty-linkname.rs:1:1 | LL | #[link(name = "")] diff --git a/src/test/ui/error-codes/E0454.stderr b/src/test/ui/error-codes/E0454.stderr index 352c3baa83aa2..499162694e57d 100644 --- a/src/test/ui/error-codes/E0454.stderr +++ b/src/test/ui/error-codes/E0454.stderr @@ -1,4 +1,4 @@ -error[E0454]: #[link(name = "")] given with empty name +error[E0454]: `#[link(name = "")]` given with empty name --> $DIR/E0454.rs:1:1 | LL | #[link(name = "")] extern {} diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr index d60fd96c77936..51f7764aaf283 100644 --- a/src/test/ui/error-codes/E0458.stderr +++ b/src/test/ui/error-codes/E0458.stderr @@ -6,7 +6,7 @@ LL | #[link(kind = "wonderful_unicorn")] extern {} | | | unknown kind -error[E0459]: #[link(...)] specified without `name = "foo"` +error[E0459]: `#[link(...)]` specified without `name = "foo"` --> $DIR/E0458.rs:1:1 | LL | #[link(kind = "wonderful_unicorn")] extern {} diff --git a/src/test/ui/error-codes/E0459.stderr b/src/test/ui/error-codes/E0459.stderr index da7069fbb477b..c618fea9afc8a 100644 --- a/src/test/ui/error-codes/E0459.stderr +++ b/src/test/ui/error-codes/E0459.stderr @@ -1,4 +1,4 @@ -error[E0459]: #[link(...)] specified without `name = "foo"` +error[E0459]: `#[link(...)]` specified without `name = "foo"` --> $DIR/E0459.rs:1:1 | LL | #[link(kind = "dylib")] extern {} diff --git a/src/test/ui/missing/missing-allocator.stderr b/src/test/ui/missing/missing-allocator.stderr index 11e0085d1ce2e..59648c42a5f31 100644 --- a/src/test/ui/missing/missing-allocator.stderr +++ b/src/test/ui/missing/missing-allocator.stderr @@ -1,4 +1,4 @@ -error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait. +error: no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait. error: aborting due to previous error diff --git a/src/test/ui/rfc1717/missing-link-attr.stderr b/src/test/ui/rfc1717/missing-link-attr.stderr index 30555e8094435..d836741f9eddf 100644 --- a/src/test/ui/rfc1717/missing-link-attr.stderr +++ b/src/test/ui/rfc1717/missing-link-attr.stderr @@ -1,4 +1,4 @@ -error: renaming of the library `foo` was specified, however this crate contains no #[link(...)] attributes referencing this library. +error: renaming of the library `foo` was specified, however this crate contains no `#[link(...)]` attributes referencing this library. error: aborting due to previous error diff --git a/src/test/ui/wasm-import-module.stderr b/src/test/ui/wasm-import-module.stderr index 20eec4c9f59bf..47d6cb6899723 100644 --- a/src/test/ui/wasm-import-module.stderr +++ b/src/test/ui/wasm-import-module.stderr @@ -1,16 +1,16 @@ -error: must be of the form #[link(wasm_import_module = "...")] +error: must be of the form `#[link(wasm_import_module = "...")]` --> $DIR/wasm-import-module.rs:1:22 | LL | #[link(name = "...", wasm_import_module)] | ^^^^^^^^^^^^^^^^^^ -error: must be of the form #[link(wasm_import_module = "...")] +error: must be of the form `#[link(wasm_import_module = "...")]` --> $DIR/wasm-import-module.rs:4:22 | LL | #[link(name = "...", wasm_import_module(x))] | ^^^^^^^^^^^^^^^^^^^^^ -error: must be of the form #[link(wasm_import_module = "...")] +error: must be of the form `#[link(wasm_import_module = "...")]` --> $DIR/wasm-import-module.rs:7:22 | LL | #[link(name = "...", wasm_import_module())] From 60ca55cbdaaea86efb06ec5346f65bfa15552be8 Mon Sep 17 00:00:00 2001 From: Samy Kacimi Date: Sat, 20 Jul 2019 18:49:34 +0200 Subject: [PATCH 11/19] normalize use of backticks in compiler messages for librustc_incremental https://github.com/rust-lang/rust/issues/60532 --- src/librustc_incremental/assert_dep_graph.rs | 2 +- src/librustc_incremental/persist/dirty_clean.rs | 2 +- src/librustc_incremental/persist/fs.rs | 6 +++--- src/test/incremental/unchecked_dirty_clean.rs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index ba893f5f93691..07d426af6ee95 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -190,7 +190,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou for &(target_span, _, _, _) in then_this_would_need { tcx.sess.span_err( target_span, - "no #[rustc_if_this_changed] annotation detected"); + "no `#[rustc_if_this_changed]` annotation detected"); } return; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index c23bb6b47f490..aa98ebae543a3 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -610,7 +610,7 @@ impl FindAllAttrs<'tcx> { for attr in &self.found_attrs { if !checked_attrs.contains(&attr.id) { self.tcx.sess.span_err(attr.span, &format!("found unchecked \ - #[rustc_dirty]/#[rustc_clean] attribute")); + `#[rustc_dirty]` / `#[rustc_clean]` attribute")); } } } diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 7f697b5448464..0ab67af613bd7 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -538,7 +538,7 @@ fn find_source_directory_in_iter(iter: I, if source_directories_already_tried.contains(&session_dir) || !is_session_directory(&directory_name) || !is_finalized(&directory_name) { - debug!("find_source_directory_in_iter - ignoring."); + debug!("find_source_directory_in_iter - ignoring"); continue } @@ -693,7 +693,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { let timestamp = match extract_timestamp_from_session_dir(lock_file_name) { Ok(timestamp) => timestamp, Err(()) => { - debug!("Found lock-file with malformed timestamp: {}", + debug!("found lock-file with malformed timestamp: {}", crate_directory.join(&lock_file_name).display()); // Ignore it continue @@ -746,7 +746,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { let timestamp = match extract_timestamp_from_session_dir(directory_name) { Ok(timestamp) => timestamp, Err(()) => { - debug!("Found session-dir with malformed timestamp: {}", + debug!("found session-dir with malformed timestamp: {}", crate_directory.join(directory_name).display()); // Ignore it continue diff --git a/src/test/incremental/unchecked_dirty_clean.rs b/src/test/incremental/unchecked_dirty_clean.rs index 9ea9431e20aec..66bdb670167ed 100644 --- a/src/test/incremental/unchecked_dirty_clean.rs +++ b/src/test/incremental/unchecked_dirty_clean.rs @@ -11,13 +11,13 @@ fn main() { #[rustc_dirty(label="Hir", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked #[rustc_dirty]/#[rustc_clean] attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute { // empty block } #[rustc_clean(label="Hir", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked #[rustc_dirty]/#[rustc_clean] attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute { // empty block } @@ -25,10 +25,10 @@ fn main() { struct _Struct { #[rustc_dirty(label="Hir", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked #[rustc_dirty]/#[rustc_clean] attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute _field1: i32, #[rustc_clean(label="Hir", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked #[rustc_dirty]/#[rustc_clean] attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute _field2: i32, } From 0385d64d197c0200ce089d2108ded2d43de91c7a Mon Sep 17 00:00:00 2001 From: Samy Kacimi Date: Fri, 19 Jul 2019 00:05:23 +0200 Subject: [PATCH 12/19] normalize use of backticks in compiler messages for librustc_lint --- src/librustc_lint/builtin.rs | 6 +- src/librustc_lint/lib.rs | 4 +- src/librustc_lint/unused.rs | 10 +-- .../plugin-attr-register-deny.stderr | 2 +- ...issue-43106-gating-of-builtin-attrs.stderr | 70 +++++++++---------- .../ui/invalid/invalid-plugin-attr.stderr | 2 +- src/test/ui/issues/issue-45562.fixed | 2 +- src/test/ui/issues/issue-45562.rs | 2 +- src/test/ui/issues/issue-45562.stderr | 2 +- src/test/ui/lint/lint-misplaced-attr.stderr | 2 +- src/test/ui/lint/lint-unexported-no-mangle.rs | 4 +- .../ui/lint/lint-unexported-no-mangle.stderr | 8 +-- src/test/ui/lint/suggestions.rs | 6 +- src/test/ui/lint/suggestions.stderr | 6 +- src/test/ui/missing_debug_impls.stderr | 4 +- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c9605445c2401..4105e030477f1 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -591,7 +591,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { if !self.impling_types.as_ref().unwrap().contains(&item.hir_id) { cx.span_lint(MISSING_DEBUG_IMPLEMENTATIONS, item.span, - "type does not implement `fmt::Debug`; consider adding #[derive(Debug)] \ + "type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` \ or a manual implementation") } } @@ -867,7 +867,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { if attr::contains_name(&it.attrs, sym::no_mangle) { // Const items do not refer to a particular location in memory, and therefore // don't have anything to attach a symbol to - let msg = "const items should never be #[no_mangle]"; + let msg = "const items should never be `#[no_mangle]`"; let mut err = cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg); // account for "pub const" (#45562) @@ -1358,7 +1358,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { declare_lint! { UNNAMEABLE_TEST_ITEMS, Warn, - "detects an item that cannot be named being marked as #[test_case]", + "detects an item that cannot be named being marked as `#[test_case]`", report_in_external_macro: true } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 82348e330f5b6..c7a8c2b892351 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -481,9 +481,9 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { store.register_removed("resolve_trait_on_defaulted_unit", "converted into hard error, see https://github.com/rust-lang/rust/issues/48950"); store.register_removed("private_no_mangle_fns", - "no longer a warning, #[no_mangle] functions always exported"); + "no longer a warning, `#[no_mangle]` functions always exported"); store.register_removed("private_no_mangle_statics", - "no longer a warning, #[no_mangle] statics always exported"); + "no longer a warning, `#[no_mangle]` statics always exported"); store.register_removed("bad_repr", "replaced with a generic attribute input check"); store.register_removed("duplicate_matcher_binding_name", diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 2db2e0bc0da96..4cccaa942b742 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -24,7 +24,7 @@ use log::debug; declare_lint! { pub UNUSED_MUST_USE, Warn, - "unused result of a type flagged as #[must_use]", + "unused result of a type flagged as `#[must_use]`", report_in_external_macro: true } @@ -316,7 +316,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes { let name = attr.name_or_empty(); if !attr::is_used(attr) { - debug!("Emitting warning for: {:?}", attr); + debug!("emitting warning for: {:?}", attr); cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute"); // Is it a builtin attribute that must be used at the crate level? let known_crate = attr_info.map(|&&(_, ty, ..)| { @@ -332,7 +332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes { let msg = match attr.style { ast::AttrStyle::Outer => { "crate-level attribute should be an inner attribute: add an exclamation \ - mark: #![foo]" + mark: `#![foo]`" } ast::AttrStyle::Inner => "crate-level attribute should be in the root module", }; @@ -570,9 +570,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind { let msg = match m { adjustment::AutoBorrowMutability::Immutable => - "unnecessary allocation, use & instead", + "unnecessary allocation, use `&` instead", adjustment::AutoBorrowMutability::Mutable { .. }=> - "unnecessary allocation, use &mut instead" + "unnecessary allocation, use `&mut` instead" }; cx.span_lint(UNUSED_ALLOCATION, e.span, msg); } diff --git a/src/test/ui-fulldeps/plugin-attr-register-deny.stderr b/src/test/ui-fulldeps/plugin-attr-register-deny.stderr index 7fea5134d7a32..64a67f6e16036 100644 --- a/src/test/ui-fulldeps/plugin-attr-register-deny.stderr +++ b/src/test/ui-fulldeps/plugin-attr-register-deny.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/plugin-attr-register-deny.rs:14:5 | LL | #[bar] diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr index f987cb97d1a4b..94757c5a35af2 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr @@ -632,7 +632,7 @@ warning: unused attribute LL | #[no_std] fn f() { } | ^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:5 | LL | #[no_std] fn f() { } @@ -644,7 +644,7 @@ warning: unused attribute LL | #[no_std] struct S; | ^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5 | LL | #[no_std] struct S; @@ -656,7 +656,7 @@ warning: unused attribute LL | #[no_std] type T = S; | ^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:491:5 | LL | #[no_std] type T = S; @@ -668,7 +668,7 @@ warning: unused attribute LL | #[no_std] impl S { } | ^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:495:5 | LL | #[no_std] impl S { } @@ -680,7 +680,7 @@ warning: unused attribute LL | #[no_std] | ^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:475:1 | LL | #[no_std] @@ -704,7 +704,7 @@ warning: unused attribute LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:5 | LL | #[crate_name = "0900"] fn f() { } @@ -716,7 +716,7 @@ warning: unused attribute LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:642:5 | LL | #[crate_name = "0900"] struct S; @@ -728,7 +728,7 @@ warning: unused attribute LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:5 | LL | #[crate_name = "0900"] type T = S; @@ -740,7 +740,7 @@ warning: unused attribute LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:5 | LL | #[crate_name = "0900"] impl S { } @@ -752,7 +752,7 @@ warning: unused attribute LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:630:1 | LL | #[crate_name = "0900"] @@ -776,7 +776,7 @@ warning: unused attribute LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5 | LL | #[crate_type = "0800"] fn f() { } @@ -788,7 +788,7 @@ warning: unused attribute LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:667:5 | LL | #[crate_type = "0800"] struct S; @@ -800,7 +800,7 @@ warning: unused attribute LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5 | LL | #[crate_type = "0800"] type T = S; @@ -812,7 +812,7 @@ warning: unused attribute LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:675:5 | LL | #[crate_type = "0800"] impl S { } @@ -824,7 +824,7 @@ warning: unused attribute LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:655:1 | LL | #[crate_type = "0800"] @@ -848,7 +848,7 @@ warning: unused attribute LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:5 | LL | #[feature(x0600)] fn f() { } @@ -860,7 +860,7 @@ warning: unused attribute LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:692:5 | LL | #[feature(x0600)] struct S; @@ -872,7 +872,7 @@ warning: unused attribute LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:5 | LL | #[feature(x0600)] type T = S; @@ -884,7 +884,7 @@ warning: unused attribute LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:5 | LL | #[feature(x0600)] impl S { } @@ -896,7 +896,7 @@ warning: unused attribute LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:680:1 | LL | #[feature(x0600)] @@ -920,7 +920,7 @@ warning: unused attribute LL | #[no_main] fn f() { } | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:714:5 | LL | #[no_main] fn f() { } @@ -932,7 +932,7 @@ warning: unused attribute LL | #[no_main] struct S; | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 | LL | #[no_main] struct S; @@ -944,7 +944,7 @@ warning: unused attribute LL | #[no_main] type T = S; | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:722:5 | LL | #[no_main] type T = S; @@ -956,7 +956,7 @@ warning: unused attribute LL | #[no_main] impl S { } | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5 | LL | #[no_main] impl S { } @@ -968,7 +968,7 @@ warning: unused attribute LL | #[no_main] | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:1 | LL | #[no_main] @@ -992,7 +992,7 @@ warning: unused attribute LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:752:5 | LL | #[recursion_limit="0200"] fn f() { } @@ -1004,7 +1004,7 @@ warning: unused attribute LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:5 | LL | #[recursion_limit="0200"] struct S; @@ -1016,7 +1016,7 @@ warning: unused attribute LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 | LL | #[recursion_limit="0200"] type T = S; @@ -1028,7 +1028,7 @@ warning: unused attribute LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:5 | LL | #[recursion_limit="0200"] impl S { } @@ -1040,7 +1040,7 @@ warning: unused attribute LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:744:1 | LL | #[recursion_limit="0200"] @@ -1064,7 +1064,7 @@ warning: unused attribute LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:777:5 | LL | #[type_length_limit="0100"] fn f() { } @@ -1076,7 +1076,7 @@ warning: unused attribute LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:781:5 | LL | #[type_length_limit="0100"] struct S; @@ -1088,7 +1088,7 @@ warning: unused attribute LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:5 | LL | #[type_length_limit="0100"] type T = S; @@ -1100,7 +1100,7 @@ warning: unused attribute LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:5 | LL | #[type_length_limit="0100"] impl S { } @@ -1112,7 +1112,7 @@ warning: unused attribute LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:769:1 | LL | #[type_length_limit="0100"] diff --git a/src/test/ui/invalid/invalid-plugin-attr.stderr b/src/test/ui/invalid/invalid-plugin-attr.stderr index c7b2ce47489a4..36714c39b315a 100644 --- a/src/test/ui/invalid/invalid-plugin-attr.stderr +++ b/src/test/ui/invalid/invalid-plugin-attr.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/invalid-plugin-attr.rs:4:1 | LL | #[plugin(bla)] diff --git a/src/test/ui/issues/issue-45562.fixed b/src/test/ui/issues/issue-45562.fixed index c23f5909bbe22..ac700fbd04643 100644 --- a/src/test/ui/issues/issue-45562.fixed +++ b/src/test/ui/issues/issue-45562.fixed @@ -1,6 +1,6 @@ // run-rustfix #[no_mangle] pub static RAH: usize = 5; -//~^ ERROR const items should never be #[no_mangle] +//~^ ERROR const items should never be `#[no_mangle]` fn main() {} diff --git a/src/test/ui/issues/issue-45562.rs b/src/test/ui/issues/issue-45562.rs index 8ac4f6794f66c..eabb5a5cecf81 100644 --- a/src/test/ui/issues/issue-45562.rs +++ b/src/test/ui/issues/issue-45562.rs @@ -1,6 +1,6 @@ // run-rustfix #[no_mangle] pub const RAH: usize = 5; -//~^ ERROR const items should never be #[no_mangle] +//~^ ERROR const items should never be `#[no_mangle]` fn main() {} diff --git a/src/test/ui/issues/issue-45562.stderr b/src/test/ui/issues/issue-45562.stderr index e6e33aa85c375..be259d3f8a49e 100644 --- a/src/test/ui/issues/issue-45562.stderr +++ b/src/test/ui/issues/issue-45562.stderr @@ -1,4 +1,4 @@ -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/issue-45562.rs:3:14 | LL | #[no_mangle] pub const RAH: usize = 5; diff --git a/src/test/ui/lint/lint-misplaced-attr.stderr b/src/test/ui/lint/lint-misplaced-attr.stderr index 1419f858f8e78..cd4a89f91c4cc 100644 --- a/src/test/ui/lint/lint-misplaced-attr.stderr +++ b/src/test/ui/lint/lint-misplaced-attr.stderr @@ -22,7 +22,7 @@ error: unused attribute LL | #[crate_type = "bin"] fn main() {} | ^^^^^^^^^^^^^^^^^^^^^ -error: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] +error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/lint-misplaced-attr.rs:11:1 | LL | #[crate_type = "bin"] fn main() {} diff --git a/src/test/ui/lint/lint-unexported-no-mangle.rs b/src/test/ui/lint/lint-unexported-no-mangle.rs index 5945c90023c9d..f260fc32303cf 100644 --- a/src/test/ui/lint/lint-unexported-no-mangle.rs +++ b/src/test/ui/lint/lint-unexported-no-mangle.rs @@ -6,10 +6,10 @@ fn foo() { #[allow(dead_code)] #[no_mangle] -const FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] +const FOO: u64 = 1; //~ ERROR const items should never be `#[no_mangle]` #[no_mangle] -pub const PUB_FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] +pub const PUB_FOO: u64 = 1; //~ ERROR const items should never be `#[no_mangle]` #[no_mangle] pub fn bar() { diff --git a/src/test/ui/lint/lint-unexported-no-mangle.stderr b/src/test/ui/lint/lint-unexported-no-mangle.stderr index 586ee8ed411c0..c2cbf5feaada4 100644 --- a/src/test/ui/lint/lint-unexported-no-mangle.stderr +++ b/src/test/ui/lint/lint-unexported-no-mangle.stderr @@ -1,12 +1,12 @@ -warning: lint `private_no_mangle_fns` has been removed: `no longer a warning, #[no_mangle] functions always exported` +warning: lint `private_no_mangle_fns` has been removed: `no longer a warning, `#[no_mangle]` functions always exported` | = note: requested on the command line with `-F private_no_mangle_fns` -warning: lint `private_no_mangle_statics` has been removed: `no longer a warning, #[no_mangle] statics always exported` +warning: lint `private_no_mangle_statics` has been removed: `no longer a warning, `#[no_mangle]` statics always exported` | = note: requested on the command line with `-F private_no_mangle_statics` -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/lint-unexported-no-mangle.rs:9:1 | LL | const FOO: u64 = 1; @@ -16,7 +16,7 @@ LL | const FOO: u64 = 1; | = note: requested on the command line with `-F no-mangle-const-items` -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/lint-unexported-no-mangle.rs:12:1 | LL | pub const PUB_FOO: u64 = 1; diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index 67bd6dd501bd8..aa5518d1a7adc 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -4,7 +4,7 @@ #![feature(no_debug)] #[no_mangle] const DISCOVERY: usize = 1; -//~^ ERROR const items should never be #[no_mangle] +//~^ ERROR const items should never be `#[no_mangle]` //~| HELP try a static value #[no_mangle] @@ -20,7 +20,7 @@ mod badlands { // item is already `pub` (but triggered the lint because, e.g., it's in a // private module). (Issue #47383) #[no_mangle] pub const DAUNTLESS: bool = true; - //~^ ERROR const items should never be #[no_mangle] + //~^ ERROR const items should never be `#[no_mangle]` //~| HELP try a static value #[no_mangle] pub fn val_jean() {} //~^ WARN functions generic over types or consts must be mangled @@ -28,7 +28,7 @@ mod badlands { // ... but we can suggest just-`pub` instead of restricted #[no_mangle] pub(crate) const VETAR: bool = true; - //~^ ERROR const items should never be #[no_mangle] + //~^ ERROR const items should never be `#[no_mangle]` //~| HELP try a static value #[no_mangle] pub(crate) fn crossfield() {} //~^ WARN functions generic over types or consts must be mangled diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index eb1e95dcdc52c..2042ed7553786 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -52,7 +52,7 @@ LL | || b = 1; | |____________| | help: remove this `mut` -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/suggestions.rs:6:14 | LL | #[no_mangle] const DISCOVERY: usize = 1; @@ -83,7 +83,7 @@ LL | Equinox { warp_factor: warp_factor } => {} | = note: `#[warn(non_shorthand_field_patterns)]` on by default -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/suggestions.rs:22:18 | LL | #[no_mangle] pub const DAUNTLESS: bool = true; @@ -99,7 +99,7 @@ LL | #[no_mangle] pub fn val_jean() {} | | | help: remove this attribute -error: const items should never be #[no_mangle] +error: const items should never be `#[no_mangle]` --> $DIR/suggestions.rs:30:18 | LL | #[no_mangle] pub(crate) const VETAR: bool = true; diff --git a/src/test/ui/missing_debug_impls.stderr b/src/test/ui/missing_debug_impls.stderr index bb8390a8f313c..b953058778791 100644 --- a/src/test/ui/missing_debug_impls.stderr +++ b/src/test/ui/missing_debug_impls.stderr @@ -1,4 +1,4 @@ -error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation +error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation --> $DIR/missing_debug_impls.rs:7:1 | LL | pub enum A {} @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(missing_debug_implementations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation +error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation --> $DIR/missing_debug_impls.rs:20:1 | LL | pub struct Foo; From 4b47e78a16524ed4878bfffaaf60c32bb18d88ae Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 21 Jul 2019 12:02:28 +0200 Subject: [PATCH 13/19] use a const to hack around promotion limitations --- src/liballoc/lib.rs | 1 + src/libcore/macros.rs | 2 +- src/libcore/mem/maybe_uninit.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 68df0137ee637..dbc1f3b47c80d 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -85,6 +85,7 @@ #![feature(fmt_internals)] #![feature(fn_traits)] #![feature(fundamental)] +#![feature(internal_uninit_const)] #![feature(lang_items)] #![feature(libc)] #![feature(nll)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 9855c5fb9c32f..296bb43f9fad4 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -653,7 +653,7 @@ macro_rules! uninit_array { #[cfg(not(bootstrap))] macro_rules! uninit_array { ($t:ty; $size:expr) => ( - [MaybeUninit::<$t>::uninit(); $size] + [MaybeUninit::<$t>::UNINIT; $size] ); } diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 1c69e7f90f6c7..9ce89f9669d22 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -248,11 +248,18 @@ impl MaybeUninit { /// [type]: union.MaybeUninit.html #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline(always)] - #[rustc_promotable] pub const fn uninit() -> MaybeUninit { MaybeUninit { uninit: () } } + /// A promotable constant, equivalent to `uninit()`. + #[unstable( + feature = "internal_uninit_const", + issue = "0", + reason = "hack to work around promotability", + )] + pub const UNINIT: Self = Self::uninit(); + /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, From 8dc5635e13c608757cf0c9c99dac747ed334fbe9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 21 Jul 2019 12:47:34 +0200 Subject: [PATCH 14/19] read: fix doc comment --- src/libstd/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index a8d4d1181aa4f..e951b575773b3 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -511,8 +511,8 @@ pub trait Read { /// /// Correspondingly, however, *callers* of this method may not assume any guarantees /// about how the implementation uses `buf`. The trait is safe to implement, - // so it is possible that the code that's supposed to write to the buffer might also read - // from it. It is your responsibility to make sure that `buf` is initialized + /// so it is possible that the code that's supposed to write to the buffer might also read + /// from it. It is your responsibility to make sure that `buf` is initialized /// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one /// obtains via [`MaybeUninit`]) is not safe, and can lead to undefined behavior. /// From f3abbf71035e469fce6db37bdb444ce3e50e870f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 21 Jul 2019 12:59:51 +0200 Subject: [PATCH 15/19] tidy is being silly --- src/libcore/mem/maybe_uninit.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 9ce89f9669d22..2e88db8df1163 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -253,11 +253,8 @@ impl MaybeUninit { } /// A promotable constant, equivalent to `uninit()`. - #[unstable( - feature = "internal_uninit_const", - issue = "0", - reason = "hack to work around promotability", - )] + #[unstable(feature = "internal_uninit_const", issue = "0", + reason = "hack to work around promotability")] pub const UNINIT: Self = Self::uninit(); /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being From 1520fabd5fa356d9abf427c63466e243fd5b03de Mon Sep 17 00:00:00 2001 From: Andrew Dassonville Date: Sun, 21 Jul 2019 07:49:26 -0700 Subject: [PATCH 16/19] Fix typo in Unicode character name --- src/libsyntax/parse/lexer/unicode_chars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs index e51657c0f132a..b728a9e1988c8 100644 --- a/src/libsyntax/parse/lexer/unicode_chars.rs +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -50,7 +50,7 @@ const UNICODE_ARRAY: &[(char, &str, char)] = &[ ('─', "Box Drawings Light Horizontal", '-'), ('━', "Box Drawings Heavy Horizontal", '-'), ('㇐', "CJK Stroke H", '-'), - ('ꟷ', "Latin Epigraphic Letter Dideways", '-'), + ('ꟷ', "Latin Epigraphic Letter Sideways I", '-'), ('ᅳ', "Hangul Jungseong Eu", '-'), ('ㅡ', "Hangul Letter Eu", '-'), ('一', "CJK Unified Ideograph-4E00", '-'), From 51ee196235e1b9e02ca5f782c8338bb9ad6c41fc Mon Sep 17 00:00:00 2001 From: Samy Kacimi Date: Sun, 21 Jul 2019 15:51:43 +0200 Subject: [PATCH 17/19] normalize use of backticks in compiler messages for librustc/hir https://github.com/rust-lang/rust/issues/60532 --- src/librustc/hir/def_id.rs | 4 ++-- src/librustc/hir/lowering.rs | 4 ++-- .../feature-gate-associated_type_bounds.stderr | 6 +++--- .../feature-gate-impl_trait_in_bindings.stderr | 4 ++-- src/test/ui/impl-trait/where-allowed.stderr | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index debed38361a14..057d878a0ab8d 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -69,14 +69,14 @@ impl CrateNum { pub fn as_usize(self) -> usize { match self { CrateNum::Index(id) => id.as_usize(), - _ => bug!("tried to get index of nonstandard crate {:?}", self), + _ => bug!("tried to get index of non-standard crate {:?}", self), } } pub fn as_u32(self) -> u32 { match self { CrateNum::Index(id) => id.as_u32(), - _ => bug!("tried to get index of nonstandard crate {:?}", self), + _ => bug!("tried to get index of non-standard crate {:?}", self), } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index c228bc2cf6b8c..288fd2714e251 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1693,8 +1693,8 @@ impl<'a> LoweringContext<'a> { if pos == ImplTraitPosition::Binding && nightly_options::is_nightly_build() { help!(err, - "add #![feature(impl_trait_in_bindings)] to the crate attributes \ - to enable"); + "add `#![feature(impl_trait_in_bindings)]` to the crate \ + attributes to enable"); } err.emit(); hir::TyKind::Err diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index cd74916bea48a..84af2a0163ae4 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -121,7 +121,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/feature-gate-associated_type_bounds.rs:60:15 @@ -129,7 +129,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/feature-gate-associated_type_bounds.rs:67:12 @@ -137,7 +137,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | let _: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error: aborting due to 16 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr index a54e7e1b3bfd1..bd648b40590ef 100644 --- a/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr @@ -10,7 +10,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | const FOO: impl Copy = 42; | ^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/feature-gate-impl_trait_in_bindings.rs:4:13 @@ -18,7 +18,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | static BAR: impl Copy = 42; | ^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/where-allowed.stderr b/src/test/ui/impl-trait/where-allowed.stderr index e7a8430faeac5..9895b028a4e26 100644 --- a/src/test/ui/impl-trait/where-allowed.stderr +++ b/src/test/ui/impl-trait/where-allowed.stderr @@ -232,7 +232,7 @@ error[E0562]: `impl Trait` not allowed outside of function and inherent method r LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ | - = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/where-allowed.rs:222:46 From e2ddb85416da4ca3235c67c99456e9cb4a498f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20R=C3=B3=C5=BCa=C5=84ski?= Date: Sun, 21 Jul 2019 21:07:38 +0200 Subject: [PATCH 18/19] Change wrong variable name. --- src/liballoc/collections/btree/map.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index d466948a0178e..7cf779b3e7281 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -75,10 +75,10 @@ use Entry::*; /// /// // look up the values associated with some keys. /// let to_find = ["Up!", "Office Space"]; -/// for book in &to_find { -/// match movie_reviews.get(book) { -/// Some(review) => println!("{}: {}", book, review), -/// None => println!("{} is unreviewed.", book) +/// for movie in &to_find { +/// match movie_reviews.get(movie) { +/// Some(review) => println!("{}: {}", movie, review), +/// None => println!("{} is unreviewed.", movie) /// } /// } /// From 647bf96b796a56e01557c14731719ab93f39063f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Jul 2019 12:59:18 +0300 Subject: [PATCH 19/19] fix lexing of comments with many \r closes #62863 --- src/libsyntax/parse/lexer/mod.rs | 2 +- ...several-carriage-returns-in-doc-comment.rs | 10 ++++++++++ ...ral-carriage-returns-in-doc-comment.stderr | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/parser/several-carriage-returns-in-doc-comment.rs create mode 100644 src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 317c49c7d3543..bfefd9adbfe8f 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -226,7 +226,7 @@ impl<'a> StringReader<'a> { loop { idx = match string[idx..].find('\r') { None => break, - Some(it) => it + 1 + Some(it) => idx + it + 1 }; if string[idx..].chars().next() != Some('\n') { self.err_span_(start + BytePos(idx as u32 - 1), diff --git a/src/test/ui/parser/several-carriage-returns-in-doc-comment.rs b/src/test/ui/parser/several-carriage-returns-in-doc-comment.rs new file mode 100644 index 0000000000000..ee14c55d292a7 --- /dev/null +++ b/src/test/ui/parser/several-carriage-returns-in-doc-comment.rs @@ -0,0 +1,10 @@ +// Issue #62863 +// ignore-tidy-cr + +// Note: if you see ^M in this file, that's how your editor renders literal `\r` + +/// This do c comment contains three isolated `\r` symbols +//~^ ERROR bare CR not allowed in doc-comment +//~| ERROR bare CR not allowed in doc-comment +//~| ERROR bare CR not allowed in doc-comment +fn main() {} diff --git a/src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr b/src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr new file mode 100644 index 0000000000000..07066fc22e6cd --- /dev/null +++ b/src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr @@ -0,0 +1,20 @@ +error: bare CR not allowed in doc-comment + --> $DIR/several-carriage-returns-in-doc-comment.rs:6:12 + | +LL | /// This do c comment contains three isolated `\r` symbols + | ^ + +error: bare CR not allowed in doc-comment + --> $DIR/several-carriage-returns-in-doc-comment.rs:6:32 + | +LL | /// This do c comment contains three isolated `\r` symbols + | ^ + +error: bare CR not allowed in doc-comment + --> $DIR/several-carriage-returns-in-doc-comment.rs:6:52 + | +LL | /// This do c comment contains three isolated `\r` symbols + | ^ + +error: aborting due to 3 previous errors +