diff --git a/.mailmap b/.mailmap index 5673cc5cfbc9d..c5ecfb54fca52 100644 --- a/.mailmap +++ b/.mailmap @@ -167,6 +167,8 @@ Matthijs Hofstra Melody Horn Michael Williams Michael Woerister +Michael Woerister +Michael Woerister Mickaƫl Raybaud-Roig m-r-r Ms2ger Mukilan Thiagarajan diff --git a/Cargo.lock b/Cargo.lock index 98dd10955d57d..a0a74a435992f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1272,9 +1272,10 @@ name = "installer" version = "0.0.0" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/doc/unstable-book/src/language-features/slice-patterns.md b/src/doc/unstable-book/src/language-features/slice-patterns.md index 133174268ef93..00c81f03ba173 100644 --- a/src/doc/unstable-book/src/language-features/slice-patterns.md +++ b/src/doc/unstable-book/src/language-features/slice-patterns.md @@ -1,8 +1,8 @@ # `slice_patterns` -The tracking issue for this feature is: [#23121] +The tracking issue for this feature is: [#62254] -[#23121]: https://github.com/rust-lang/rust/issues/23121 +[#62254]: https://github.com/rust-lang/rust/issues/62254 ------------------------ diff --git a/src/etc/gdb_load_rust_pretty_printers.py b/src/etc/gdb_load_rust_pretty_printers.py index c551346bb00bf..fe38c49d2707d 100644 --- a/src/etc/gdb_load_rust_pretty_printers.py +++ b/src/etc/gdb_load_rust_pretty_printers.py @@ -1,2 +1,3 @@ +import gdb import gdb_rust_pretty_printing gdb_rust_pretty_printing.register_printers(gdb.current_objfile()) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 9109a730cce2d..19b0f82db4335 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -367,12 +367,19 @@ impl Clone for Box { /// ``` /// let x = Box::new(5); /// let y = x.clone(); + /// + /// // The value is the same + /// assert_eq!(x, y); + /// + /// // But they are unique objects + /// assert_ne!(&*x as *const i32, &*y as *const i32); /// ``` #[rustfmt::skip] #[inline] fn clone(&self) -> Box { box { (**self).clone() } } + /// Copies `source`'s contents into `self` without creating a new allocation. /// /// # Examples @@ -380,10 +387,15 @@ impl Clone for Box { /// ``` /// let x = Box::new(5); /// let mut y = Box::new(10); + /// let yp: *const i32 = &*y; /// /// y.clone_from(&x); /// - /// assert_eq!(*y, 5); + /// // The value is the same + /// assert_eq!(x, y); + /// + /// // And no allocation occurred + /// assert_eq!(yp, &*y); /// ``` #[inline] fn clone_from(&mut self, source: &Box) { diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 92fe0834dd029..c0544d7469ca7 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1367,6 +1367,40 @@ impl Vec { self.truncate(new_len); } } + + /// Consumes and leaks the `Vec`, returning a mutable reference to the contents, + /// `&'a mut [T]`. Note that the type `T` must outlive the chosen lifetime + /// `'a`. If the type has only static references, or none at all, then this + /// may be chosen to be `'static`. + /// + /// This function is similar to the `leak` function on `Box`. + /// + /// This function is mainly useful for data that lives for the remainder of + /// the program's life. Dropping the returned reference will cause a memory + /// leak. + /// + /// # Examples + /// + /// Simple usage: + /// + /// ``` + /// #![feature(vec_leak)] + /// + /// fn main() { + /// let x = vec![1, 2, 3]; + /// let static_ref: &'static mut [usize] = Vec::leak(x); + /// static_ref[0] += 1; + /// assert_eq!(static_ref, &[2, 2, 3]); + /// } + /// ``` + #[unstable(feature = "vec_leak", issue = "62195")] + #[inline] + pub fn leak<'a>(vec: Vec) -> &'a mut [T] + where + T: 'a // Technically not needed, but kept to be explicit. + { + Box::leak(vec.into_boxed_slice()) + } } impl Vec { diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index a697b7bd6e589..c0de8e2ceb3f3 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -251,12 +251,12 @@ pub trait AsMut { /// /// # Examples /// -/// [`String`] implements `Into>`: +/// [`String`] implements [`Into`]`<`[`Vec`]`<`[`u8`]`>>`: /// /// In order to express that we want a generic function to take all arguments that can be /// converted to a specified type `T`, we can use a trait bound of [`Into`]``. /// For example: The function `is_hello` takes all arguments that can be converted into a -/// `Vec`. +/// [`Vec`]`<`[`u8`]`>`. /// /// ``` /// fn is_hello>>(s: T) { @@ -274,6 +274,7 @@ pub trait AsMut { /// [`String`]: ../../std/string/struct.String.html /// [`From`]: trait.From.html /// [`Into`]: trait.Into.html +/// [`Vec`]: ../../std/vec/struct.Vec.html #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { /// Performs the conversion. @@ -410,12 +411,12 @@ pub trait TryInto: Sized { /// /// This is useful when you are doing a type conversion that may /// trivially succeed but may also need special handling. -/// For example, there is no way to convert an `i64` into an `i32` -/// using the [`From`] trait, because an `i64` may contain a value -/// that an `i32` cannot represent and so the conversion would lose data. -/// This might be handled by truncating the `i64` to an `i32` (essentially -/// giving the `i64`'s value modulo `i32::MAX`) or by simply returning -/// `i32::MAX`, or by some other method. The `From` trait is intended +/// For example, there is no way to convert an [`i64`] into an [`i32`] +/// using the [`From`] trait, because an [`i64`] may contain a value +/// that an [`i32`] cannot represent and so the conversion would lose data. +/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially +/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning +/// [`i32::MAX`], or by some other method. The [`From`] trait is intended /// for perfect conversions, so the `TryFrom` trait informs the /// programmer when a type conversion could go bad and lets them /// decide how to handle it. @@ -425,8 +426,8 @@ pub trait TryInto: Sized { /// - `TryFrom for U` implies [`TryInto`]` for T` /// - [`try_from`] is reflexive, which means that `TryFrom for T` /// is implemented and cannot fail -- the associated `Error` type for -/// calling `T::try_from()` on a value of type `T` is `Infallible`. -/// When the `!` type is stablized `Infallible` and `!` will be +/// calling `T::try_from()` on a value of type `T` is [`Infallible`]. +/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be /// equivalent. /// /// `TryFrom` can be implemented as follows: @@ -451,7 +452,7 @@ pub trait TryInto: Sized { /// /// # Examples /// -/// As described, [`i32`] implements `TryFrom`: +/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`: /// /// ``` /// use std::convert::TryFrom; @@ -474,6 +475,8 @@ pub trait TryInto: Sized { /// /// [`try_from`]: trait.TryFrom.html#tymethod.try_from /// [`TryInto`]: trait.TryInto.html +/// [`i32::MAX`]: ../../std/i32/constant.MAX.html +/// [`!`]: ../../std/primitive.never.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryFrom: Sized { /// The type returned in the event of a conversion error. diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index b30eff8baa9c8..d9b68612785e9 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -36,6 +36,8 @@ issue = "0")] #![allow(missing_docs)] +use crate::mem; + #[stable(feature = "drop_in_place", since = "1.8.0")] #[rustc_deprecated(reason = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.18.0")] @@ -1331,6 +1333,26 @@ extern "rust-intrinsic" { // (`transmute` also falls into this category, but it cannot be wrapped due to the // check that `T` and `U` have the same size.) +/// Checks whether `ptr` is properly aligned with respect to +/// `align_of::()`. +pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { + !ptr.is_null() && ptr as usize % mem::align_of::() == 0 +} + +/// Checks whether the regions of memory starting at `src` and `dst` of size +/// `count * size_of::()` overlap. +fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { + let src_usize = src as usize; + let dst_usize = dst as usize; + let size = mem::size_of::().checked_mul(count).unwrap(); + let diff = if src_usize > dst_usize { + src_usize - dst_usize + } else { + dst_usize - src_usize + }; + size > diff +} + /// Copies `count * size_of::()` bytes from `src` to `dst`. The source /// and destination must *not* overlap. /// @@ -1420,7 +1442,11 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize); } - copy_nonoverlapping(src, dst, count); + + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); + debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory"); + copy_nonoverlapping(src, dst, count) } /// Copies `count * size_of::()` bytes from `src` to `dst`. The source @@ -1480,6 +1506,9 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { fn copy(src: *const T, dst: *mut T, count: usize); } + + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); copy(src, dst, count) } @@ -1561,6 +1590,8 @@ pub unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { extern "rust-intrinsic" { fn write_bytes(dst: *mut T, val: u8, count: usize); } + + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); write_bytes(dst, val, count) } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 04c50329de3d0..1f31b65b3603b 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -74,6 +74,7 @@ #![feature(concat_idents)] #![feature(const_fn)] #![feature(const_fn_union)] +#![feature(custom_inner_attributes)] #![feature(doc_cfg)] #![feature(doc_spotlight)] #![feature(extern_types)] diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index c6d44324ef5ee..4757ab26cdf0b 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -25,7 +25,7 @@ use crate::cmp::Ordering::{self, Less, Equal, Greater}; use crate::cmp; use crate::fmt; -use crate::intrinsics::{assume, exact_div, unchecked_sub}; +use crate::intrinsics::{assume, exact_div, unchecked_sub, is_aligned_and_not_null}; use crate::isize; use crate::iter::*; use crate::ops::{FnMut, Try, self}; @@ -4453,6 +4453,21 @@ impl<'a, T> DoubleEndedIterator for ChunksExact<'a, T> { Some(snd) } } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + let len = self.len(); + if n >= len { + self.v = &[]; + None + } else { + let start = (len - 1 - n) * self.chunk_size; + let end = start + self.chunk_size; + let nth_back = &self.v[start..end]; + self.v = &self.v[..start]; + Some(nth_back) + } + } } #[stable(feature = "chunks_exact", since = "1.31.0")] @@ -5213,7 +5228,7 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); &*ptr::slice_from_raw_parts(data, len) @@ -5234,7 +5249,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); &mut *ptr::slice_from_raw_parts_mut(data, len) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 34f2d8917ea47..f7b4e4ea7824f 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3716,10 +3716,10 @@ impl str { /// /// # Text directionality /// - /// A string is a sequence of bytes. 'Left' in this context means the first - /// position of that byte string; for a language like Arabic or Hebrew - /// which are 'right to left' rather than 'left to right', this will be - /// the _right_ side, not the left. + /// A string is a sequence of bytes. `start` in this context means the first + /// position of that byte string; for a left-to-right language like English or + /// Russian, this will be left side, and for right-to-left languages like + /// like Arabic or Hebrew, this will be the right side. /// /// # Examples /// @@ -3755,10 +3755,10 @@ impl str { /// /// # Text directionality /// - /// A string is a sequence of bytes. 'Right' in this context means the last - /// position of that byte string; for a language like Arabic or Hebrew - /// which are 'right to left' rather than 'left to right', this will be - /// the _left_ side, not the right. + /// A string is a sequence of bytes. `end` in this context means the last + /// position of that byte string; for a left-to-right language like English or + /// Russian, this will be right side, and for right-to-left languages like + /// like Arabic or Hebrew, this will be the left side. /// /// # Examples /// @@ -3804,10 +3804,10 @@ impl str { /// /// # Text directionality /// - /// A string is a sequence of bytes. `start` in this context means the first - /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be left side, and for right-to-left languages like - /// like Arabic or Hebrew, this will be the right side. + /// A string is a sequence of bytes. 'Left' in this context means the first + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _right_ side, not the left. /// /// # Examples /// @@ -3840,10 +3840,10 @@ impl str { /// /// # Text directionality /// - /// A string is a sequence of bytes. `end` in this context means the last - /// position of that byte string; for a left-to-right language like English or - /// Russian, this will be right side, and for right-to-left languages like - /// like Arabic or Hebrew, this will be the left side. + /// A string is a sequence of bytes. 'Right' in this context means the last + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _left_ side, not the right. /// /// # Examples /// diff --git a/src/libcore/tests/ascii.rs b/src/libcore/tests/ascii.rs index ec98e0464c9e6..439ed0c81c8b6 100644 --- a/src/libcore/tests/ascii.rs +++ b/src/libcore/tests/ascii.rs @@ -151,7 +151,7 @@ macro_rules! assert_none { stringify!($what), b); } } - )* + )+ }}; ($what:ident, $($str:tt),+,) => (assert_none!($what,$($str),+)) } diff --git a/src/libcore/tests/pattern.rs b/src/libcore/tests/pattern.rs index b78ed0210770f..06c3a78c1698a 100644 --- a/src/libcore/tests/pattern.rs +++ b/src/libcore/tests/pattern.rs @@ -5,7 +5,7 @@ use std::str::pattern::*; macro_rules! search_asserts { ($haystack:expr, $needle:expr, $testname:expr, [$($func:ident),*], $result:expr) => { let mut searcher = $needle.into_searcher($haystack); - let arr = [$( Step::from(searcher.$func()) ),+]; + let arr = [$( Step::from(searcher.$func()) ),*]; assert_eq!(&arr[..], &$result, $testname); } } diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 03e65d2fe0b81..13b02c7184234 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -275,6 +275,25 @@ fn test_chunks_exact_nth() { assert_eq!(c2.next(), None); } +#[test] +fn test_chunks_exact_nth_back() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks_exact(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks_exact(3); + assert_eq!(c2.nth_back(0).unwrap(), &[0, 1, 2]); + assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &[i32] = &[0, 1, 2, 3, 4]; + let mut c3 = v3.chunks_exact(10); + assert_eq!(c3.nth_back(0), None); +} + #[test] fn test_chunks_exact_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; diff --git a/src/librustc_codegen_llvm/back/archive.rs b/src/librustc_codegen_llvm/back/archive.rs index e0e26e9af2537..90c0cf748d1e0 100644 --- a/src/librustc_codegen_llvm/back/archive.rs +++ b/src/librustc_codegen_llvm/back/archive.rs @@ -36,11 +36,20 @@ enum Addition { name_in_archive: String, }, Archive { + path: PathBuf, archive: ArchiveRO, skip: Box bool>, }, } +impl Addition { + fn path(&self) -> &Path { + match self { + Addition::File { path, .. } | Addition::Archive { path, .. } => path, + } + } +} + fn is_relevant_child(c: &Child<'_>) -> bool { match c.name() { Some(name) => !name.contains("SYMDEF"), @@ -188,12 +197,16 @@ impl<'a> LlvmArchiveBuilder<'a> { -> io::Result<()> where F: FnMut(&str) -> bool + 'static { - let archive = match ArchiveRO::open(archive) { + let archive_ro = match ArchiveRO::open(archive) { Ok(ar) => ar, Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)), }; + if self.additions.iter().any(|ar| ar.path() == archive) { + return Ok(()) + } self.additions.push(Addition::Archive { - archive, + path: archive.to_path_buf(), + archive: archive_ro, skip: Box::new(skip), }); Ok(()) @@ -243,7 +256,7 @@ impl<'a> LlvmArchiveBuilder<'a> { strings.push(path); strings.push(name); } - Addition::Archive { archive, skip } => { + Addition::Archive { archive, skip, .. } => { for child in archive.iter() { let child = child.map_err(string_to_io_error)?; if !is_relevant_child(&child) { diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index a5c295cd4525c..708ba79ec3ab2 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1736,7 +1736,9 @@ extern "C" { pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>); pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); - pub fn LLVMRustGetSectionName(SI: &SectionIterator<'_>, data: &mut *const c_char) -> size_t; + #[allow(improper_ctypes)] + pub fn LLVMRustGetSectionName(SI: &SectionIterator<'_>, + data: &mut Option>) -> size_t; #[allow(improper_ctypes)] pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); diff --git a/src/librustc_codegen_llvm/metadata.rs b/src/librustc_codegen_llvm/metadata.rs index 7cf497cb5d036..cd7255888118c 100644 --- a/src/librustc_codegen_llvm/metadata.rs +++ b/src/librustc_codegen_llvm/metadata.rs @@ -8,7 +8,6 @@ use rustc_data_structures::owning_ref::OwningRef; use rustc_codegen_ssa::METADATA_FILENAME; use std::path::Path; -use std::ptr; use std::slice; use rustc_fs_util::path_to_c_string; @@ -67,10 +66,16 @@ fn search_meta_section<'a>(of: &'a ObjectFile, unsafe { let si = mk_section_iter(of.llof); while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { - let mut name_buf = ptr::null(); + let mut name_buf = None; let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf); - let name = slice::from_raw_parts(name_buf as *const u8, name_len as usize).to_vec(); - let name = String::from_utf8(name).unwrap(); + let name = name_buf.map_or( + String::new(), // We got a NULL ptr, ignore `name_len`. + |buf| String::from_utf8( + slice::from_raw_parts(buf.as_ptr() as *const u8, + name_len as usize) + .to_vec() + ).unwrap() + ); debug!("get_metadata_section: name {}", name); if read_metadata_section_name(target) == name { let cbuf = llvm::LLVMGetSectionContents(si.llsi); diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index e3d297e78623e..707b7cae16ce7 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -653,10 +653,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(sess: &'a Session, linker_error.emit(); if sess.target.target.options.is_like_msvc && linker_not_found { - sess.note_without_error("the msvc targets depend on the msvc linker \ - but `link.exe` was not found"); - sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017 \ - was installed with the Visual C++ option"); + sess.note_without_error( + "the msvc targets depend on the msvc linker \ + but `link.exe` was not found", + ); + sess.note_without_error( + "please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 \ + was installed with the Visual C++ option", + ); } sess.abort_if_errors(); } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index a86d3cc43948d..6ae5e94b11af3 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -642,14 +642,14 @@ pub fn build_output_filenames( ); None } else { + if !sess.opts.cg.extra_filename.is_empty() { + sess.warn("ignoring -C extra-filename flag due to -o flag"); + } Some(out_file.clone()) }; if *odir != None { sess.warn("ignoring --out-dir flag due to -o flag"); } - if !sess.opts.cg.extra_filename.is_empty() { - sess.warn("ignoring -C extra-filename flag due to -o flag"); - } OutputFilenames { out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(), diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index fbacdf6cd93bb..e6c9d9f5c79d8 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -1,7 +1,7 @@ use rustc::ty::{self, Ty, TypeAndMut}; use rustc::ty::layout::{self, TyLayout, Size}; use rustc::ty::adjustment::{PointerCast}; -use syntax::ast::{FloatTy, IntTy, UintTy}; +use syntax::ast::FloatTy; use syntax::symbol::sym; use rustc_apfloat::ieee::{Single, Double}; @@ -151,7 +151,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> { "Unexpected cast from type {:?}", src_layout.ty ); match val.to_bits_or_ptr(src_layout.size, self) { - Err(ptr) => self.cast_from_ptr(ptr, dest_layout.ty), + Err(ptr) => self.cast_from_ptr(ptr, src_layout, dest_layout), Ok(data) => self.cast_from_int(data, src_layout, dest_layout), } } @@ -239,17 +239,25 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> { fn cast_from_ptr( &self, ptr: Pointer, - ty: Ty<'tcx> + src_layout: TyLayout<'tcx>, + dest_layout: TyLayout<'tcx>, ) -> InterpResult<'tcx, Scalar> { use rustc::ty::TyKind::*; - match ty.sty { + + match dest_layout.ty.sty { // Casting to a reference or fn pointer is not permitted by rustc, // no need to support it here. - RawPtr(_) | - Int(IntTy::Isize) | - Uint(UintTy::Usize) => Ok(ptr.into()), - Int(_) | Uint(_) => err!(ReadPointerAsBytes), - _ => err!(Unimplemented(format!("ptr to {:?} cast", ty))), + RawPtr(_) => Ok(ptr.into()), + Int(_) | Uint(_) => { + let size = self.memory.pointer_size(); + + match self.force_bits(Scalar::Ptr(ptr), size) { + Ok(bits) => self.cast_from_int(bits, src_layout, dest_layout), + Err(_) if dest_layout.size == size => Ok(ptr.into()), + Err(e) => Err(e), + } + } + _ => bug!("invalid MIR: ptr to {:?} cast", dest_layout.ty) } } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 392a46a262f50..522dc1aa9f8de 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -19,9 +19,8 @@ use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::expand::{AstFragment, Invocation, InvocationKind}; use syntax::ext::hygiene::Mark; use syntax::ext::tt::macro_rules; -use syntax::feature_gate::{ - feature_err, is_builtin_attr_name, AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES, -}; +use syntax::feature_gate::{feature_err, emit_feature_err, is_builtin_attr_name}; +use syntax::feature_gate::{AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES}; use syntax::symbol::{Symbol, kw, sym}; use syntax::visit::Visitor; use syntax::util::lev_distance::find_best_match_for_name; @@ -298,12 +297,25 @@ impl<'a> Resolver<'a> { let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force); // Report errors and enforce feature gates for the resolved macro. + let features = self.session.features_untracked(); if res != Err(Determinacy::Undetermined) { // Do not report duplicated errors on every undetermined resolution. for segment in &path.segments { if let Some(args) = &segment.args { self.session.span_err(args.span(), "generic arguments in macro path"); } + if kind == MacroKind::Attr && !features.rustc_attrs && + segment.ident.as_str().starts_with("rustc") { + let msg = "attributes starting with `rustc` are \ + reserved for use by the `rustc` compiler"; + emit_feature_err( + &self.session.parse_sess, + sym::rustc_attrs, + segment.ident.span, + GateIssue::Language, + msg, + ); + } } } @@ -320,24 +332,15 @@ impl<'a> Resolver<'a> { } Res::NonMacroAttr(attr_kind) => { if kind == MacroKind::Attr { - let features = self.session.features_untracked(); if attr_kind == NonMacroAttrKind::Custom { assert!(path.segments.len() == 1); - let name = path.segments[0].ident.as_str(); - if name.starts_with("rustc_") { - if !features.rustc_attrs { - let msg = "unless otherwise specified, attributes with the prefix \ - `rustc_` are reserved for internal compiler diagnostics"; - self.report_unknown_attribute(path.span, &name, msg, - sym::rustc_attrs); - } - } else if !features.custom_attribute { + if !features.custom_attribute { let msg = format!("The attribute `{}` is currently unknown to the \ compiler and may have meaning added to it in the \ future", path); self.report_unknown_attribute( path.span, - &name, + &path.segments[0].ident.as_str(), &msg, sym::custom_attribute, ); diff --git a/src/librustc_target/spec/windows_msvc_base.rs b/src/librustc_target/spec/windows_msvc_base.rs index fdd747cdb865a..b139083e99fc1 100644 --- a/src/librustc_target/spec/windows_msvc_base.rs +++ b/src/librustc_target/spec/windows_msvc_base.rs @@ -19,6 +19,10 @@ pub fn opts() -> TargetOptions { target_family: Some("windows".to_string()), is_like_windows: true, is_like_msvc: true, + // set VSLANG to 1033 can prevent link.exe from using + // language packs, and avoid generating Non-UTF-8 error + // messages if a link error occurred. + link_env: vec![("VSLANG".to_string(), "1033".to_string())], pre_link_args: args, crt_static_allows_dylibs: true, crt_static_respected: true, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index b435c99ad01f5..bcb66f1715942 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -458,7 +458,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match ty.sty { ty::Array(..) | ty::Slice(..) => { err.help("the semantics of slice patterns changed \ - recently; see issue #23121"); + recently; see issue #62254"); } _ => {} } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 5a2fe2b244f55..2925d8362c8d9 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2608,6 +2608,12 @@ mod test_map { use realstd::collections::CollectionAllocErr::*; use realstd::usize; + // https://github.com/rust-lang/rust/issues/62301 + fn _assert_hashmap_is_unwind_safe() { + fn assert_unwind_safe() {} + assert_unwind_safe::>>(); + } + #[test] fn test_zero_capacities() { type HM = HashMap; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 7a3b5d30500a9..1d4fd98dd754f 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -4,6 +4,7 @@ use crate::any::Any; use crate::cell::UnsafeCell; +use crate::collections; use crate::fmt; use crate::future::Future; use crate::pin::Pin; @@ -285,6 +286,11 @@ impl RefUnwindSafe for atomic::AtomicBool {} #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] impl RefUnwindSafe for atomic::AtomicPtr {} +// https://github.com/rust-lang/rust/issues/62301 +#[stable(feature = "hashbrown", since = "1.36.0")] +impl UnwindSafe for collections::HashMap + where K: UnwindSafe, V: UnwindSafe, S: UnwindSafe {} + #[stable(feature = "catch_unwind", since = "1.9.0")] impl Deref for AssertUnwindSafe { type Target = T; diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a568f46663730..000f80f99e7a9 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1765,33 +1765,6 @@ mod tests { assert_eq!(out, "foobar\n"); } - - #[test] - #[cfg_attr(target_os = "android", ignore)] - #[cfg(unix)] - fn uid_works() { - use crate::os::unix::prelude::*; - - let mut p = Command::new("/bin/sh") - .arg("-c").arg("true") - .uid(unsafe { libc::getuid() }) - .gid(unsafe { libc::getgid() }) - .spawn().unwrap(); - assert!(p.wait().unwrap().success()); - } - - #[test] - #[cfg_attr(target_os = "android", ignore)] - #[cfg(unix)] - fn uid_to_root_fails() { - use crate::os::unix::prelude::*; - - // if we're already root, this isn't a valid test. Most of the bots run - // as non-root though (android is an exception). - if unsafe { libc::getuid() == 0 } { return } - assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err()); - } - #[test] #[cfg_attr(target_os = "android", ignore)] fn test_process_status() { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 5473f55aa3370..3f2bae50325d5 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1525,9 +1525,7 @@ impl<'feat> ExpansionConfig<'feat> { } fn enable_custom_inner_attributes(&self) -> bool { - self.features.map_or(false, |features| { - features.custom_inner_attributes || features.custom_attribute || features.rustc_attrs - }) + self.features.map_or(false, |features| features.custom_inner_attributes) } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e6a09e7f873ea..fd87eedbf52a9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -323,7 +323,7 @@ declare_features! ( (active, nll, "1.0.0", Some(43234), None), // Allows using slice patterns. - (active, slice_patterns, "1.0.0", Some(23121), None), + (active, slice_patterns, "1.0.0", Some(62254), None), // Allows the definition of `const` functions with some advanced features. (active, const_fn, "1.2.0", Some(57563), None), @@ -610,7 +610,7 @@ declare_features! ( (removed, allocator, "1.0.0", None, None, None), (removed, simd, "1.0.0", Some(27731), None, Some("removed in favor of `#[repr(simd)]`")), - (removed, advanced_slice_patterns, "1.0.0", Some(23121), None, + (removed, advanced_slice_patterns, "1.0.0", Some(62254), None, Some("merged into `#![feature(slice_patterns)]`")), (removed, macro_reexport, "1.0.0", Some(29638), None, Some("subsumed by `pub use`")), @@ -1292,6 +1292,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ attribute is just used for rustc unit \ tests and will never be stable", cfg_fn!(rustc_attrs))), + (sym::rustc_dump_env_program_clauses, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "the `#[rustc_dump_env_program_clauses]` \ + attribute is just used for rustc unit \ + tests and will never be stable", + cfg_fn!(rustc_attrs))), + (sym::rustc_object_lifetime_default, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "the `#[rustc_object_lifetime_default]` \ + attribute is just used for rustc unit \ + tests and will never be stable", + cfg_fn!(rustc_attrs))), (sym::rustc_test_marker, Normal, template!(Word), Gated(Stability::Unstable, sym::rustc_attrs, "the `#[rustc_test_marker]` attribute \ @@ -1353,6 +1365,26 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ "internal implementation detail", cfg_fn!(rustc_attrs))), + (sym::rustc_allocator_nounwind, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "internal implementation detail", + cfg_fn!(rustc_attrs))), + + (sym::rustc_doc_only_macro, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "internal implementation detail", + cfg_fn!(rustc_attrs))), + + (sym::rustc_promotable, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "internal implementation detail", + cfg_fn!(rustc_attrs))), + + (sym::rustc_allow_const_fn_ptr, Whitelisted, template!(Word), Gated(Stability::Unstable, + sym::rustc_attrs, + "internal implementation detail", + cfg_fn!(rustc_attrs))), + (sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable, sym::rustc_attrs, "used by the test suite", @@ -1639,6 +1671,14 @@ impl<'a> Context<'a> { } debug!("check_attribute: {:?} is builtin, {:?}, {:?}", attr.path, ty, gateage); return; + } else { + for segment in &attr.path.segments { + if segment.ident.as_str().starts_with("rustc") { + let msg = "attributes starting with `rustc` are \ + reserved for use by the `rustc` compiler"; + gate_feature!(self, rustc_attrs, segment.ident.span, msg); + } + } } for &(n, ty) in self.plugin_attributes { if attr.path == n { @@ -1649,19 +1689,13 @@ impl<'a> Context<'a> { return; } } - if !attr::is_known(attr) { - if attr.name_or_empty().as_str().starts_with("rustc_") { - let msg = "unless otherwise specified, attributes with the prefix `rustc_` \ - are reserved for internal compiler diagnostics"; - gate_feature!(self, rustc_attrs, attr.span, msg); - } else if !is_macro { - // Only run the custom attribute lint during regular feature gate - // checking. Macro gating runs before the plugin attributes are - // registered, so we skip this in that case. - let msg = format!("The attribute `{}` is currently unknown to the compiler and \ - may have meaning added to it in the future", attr.path); - gate_feature!(self, custom_attribute, attr.span, &msg); - } + if !is_macro && !attr::is_known(attr) { + // Only run the custom attribute lint during regular feature gate + // checking. Macro gating runs before the plugin attributes are + // registered, so we skip this in that case. + let msg = format!("The attribute `{}` is currently unknown to the compiler and \ + may have meaning added to it in the future", attr.path); + gate_feature!(self, custom_attribute, attr.span, &msg); } } } diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index 20280aa3c4130..e92c68f5b0c57 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -4,11 +4,13 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").expect("TARGET was not set"); - if cfg!(feature = "llvm-libunwind") && + // FIXME: the not(bootstrap) part is needed because of the issue addressed by #62286, + // and could be removed once that change is in beta. + if cfg!(all(not(bootstrap), feature = "llvm-libunwind")) && (target.contains("linux") || target.contains("fuchsia")) { // Build the unwinding from libunwind C/C++ source code. - #[cfg(feature = "llvm-libunwind")] + #[cfg(all(not(bootstrap), feature = "llvm-libunwind"))] llvm_libunwind::compile(); } else if target.contains("linux") { if target.contains("musl") { @@ -42,7 +44,7 @@ fn main() { } } -#[cfg(feature = "llvm-libunwind")] +#[cfg(all(not(bootstrap), feature = "llvm-libunwind"))] mod llvm_libunwind { use std::env; use std::path::Path; diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 5794e0b7683cb..7e640897af705 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -67,6 +67,8 @@ pub enum _Unwind_Context {} pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); +#[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind"), + link(name = "unwind", kind = "static"))] extern "C" { #[unwind(allowed)] pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !; @@ -91,6 +93,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm } pub use _Unwind_Action::*; + #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind"), + link(name = "unwind", kind = "static"))] extern "C" { pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word; pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word); @@ -144,6 +148,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm pub const UNWIND_POINTER_REG: c_int = 12; pub const UNWIND_IP_REG: c_int = 15; + #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind"), + link(name = "unwind", kind = "static"))] extern "C" { fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context, regclass: _Unwind_VRS_RegClass, @@ -206,6 +212,8 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm cfg_if::cfg_if! { if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { // Not 32-bit iOS + #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind"), + link(name = "unwind", kind = "static"))] extern "C" { #[unwind(allowed)] pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; @@ -215,6 +223,8 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { } } else { // 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace() + #[cfg_attr(all(not(bootstrap), feature = "llvm-libunwind"), + link(name = "unwind", kind = "static"))] extern "C" { #[unwind(allowed)] pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; diff --git a/src/test/codegen/issue-45222.rs b/src/test/codegen/issue-45222.rs index da65f2dfca5d1..7f99ca724cf73 100644 --- a/src/test/codegen/issue-45222.rs +++ b/src/test/codegen/issue-45222.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] diff --git a/src/test/codegen/issue-45466.rs b/src/test/codegen/issue-45466.rs index 7d6e31cc740f5..c79542767774a 100644 --- a/src/test/codegen/issue-45466.rs +++ b/src/test/codegen/issue-45466.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type="rlib"] diff --git a/src/test/codegen/swap-small-types.rs b/src/test/codegen/swap-small-types.rs index c8466fed7d1bd..6205e6a6559c9 100644 --- a/src/test/codegen/swap-small-types.rs +++ b/src/test/codegen/swap-small-types.rs @@ -1,5 +1,6 @@ // compile-flags: -O // only-x86_64 +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] diff --git a/src/test/run-pass-fulldeps/issue-15778-pass.rs b/src/test/run-pass-fulldeps/issue-15778-pass.rs index 2add3ccbe36f2..35152e7f4babd 100644 --- a/src/test/run-pass-fulldeps/issue-15778-pass.rs +++ b/src/test/run-pass-fulldeps/issue-15778-pass.rs @@ -2,7 +2,8 @@ // ignore-stage1 // compile-flags: -D crate-not-okay -#![feature(plugin, rustc_attrs)] +#![feature(plugin, custom_attribute, custom_inner_attributes, rustc_attrs)] + #![plugin(lint_for_crate)] #![rustc_crate_okay] #![rustc_crate_blue] @@ -10,4 +11,4 @@ #![rustc_crate_grey] #![rustc_crate_green] -pub fn main() { } +fn main() {} diff --git a/src/test/run-pass/attr-on-generic-formals.rs b/src/test/run-pass/attr-on-generic-formals.rs deleted file mode 100644 index 9ebf0fcb1c192..0000000000000 --- a/src/test/run-pass/attr-on-generic-formals.rs +++ /dev/null @@ -1,52 +0,0 @@ -#![allow(unused_attributes)] - -// This test ensures we can attach attributes to the formals in all -// places where generic parameter lists occur, assuming appropriate -// feature gates are enabled. -// -// (We are prefixing all tested features with `rustc_`, to ensure that -// the attributes themselves won't be rejected by the compiler when -// using `rustc_attrs` feature. There is a separate compile-fail/ test -// ensuring that the attribute feature-gating works in this context.) - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct StLt<#[rustc_lt_struct] 'a>(&'a u32); -struct StTy<#[rustc_ty_struct] I>(I); - -enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B } -enum EnTy<#[rustc_ty_enum] J> { A(J), B } - -trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } -trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); } - -type TyLt<#[rustc_lt_type] 'd> = &'d u32; -type TyTy<#[rustc_ty_type] L> = (L, ); - -impl<#[rustc_lt_inherent] 'e> StLt<'e> { } -impl<#[rustc_ty_inherent] M> StTy { } - -impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> { - fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } -} -impl<#[rustc_ty_impl_for] N> TrTy for StTy { - fn foo(&self, _: N) { } -} - -fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } -fn f_ty<#[rustc_ty_fn] O>(_: O) { } - -impl StTy { - fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } - fn m_ty<#[rustc_ty_meth] P>(_: P) { } -} - -fn hof_lt(_: Q) - where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 -{ -} - -fn main() { - -} diff --git a/src/test/run-pass/command-uid-gid.rs b/src/test/run-pass/command-uid-gid.rs new file mode 100644 index 0000000000000..2b52c5d104c24 --- /dev/null +++ b/src/test/run-pass/command-uid-gid.rs @@ -0,0 +1,26 @@ +#![feature(rustc_private)] + +fn main() { + #[cfg(unix)] + run() +} + +#[cfg(unix)] +fn run() { + extern crate libc; + use std::process::Command; + use std::os::unix::prelude::*; + + let mut p = Command::new("/bin/sh") + .arg("-c").arg("true") + .uid(unsafe { libc::getuid() }) + .gid(unsafe { libc::getgid() }) + .spawn().unwrap(); + assert!(p.wait().unwrap().success()); + + // if we're already root, this isn't a valid test. Most of the bots run + // as non-root though (android is an exception). + if unsafe { libc::getuid() != 0 } { + assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err()); + } +} diff --git a/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.rs b/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.rs index ca5fdd9da859b..df9c8d894652b 100644 --- a/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.rs +++ b/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.rs @@ -6,10 +6,8 @@ struct RefIntPair<'a, 'b>(&'a u32, &'b u32); -impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { +impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { //~^ ERROR trailing attribute after generic parameter } -fn main() { - -} +fn main() {} diff --git a/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.stderr b/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.stderr index 55e7a9877846f..5b4f5222a2b14 100644 --- a/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.stderr +++ b/src/test/ui/attributes/attrs-with-no-formal-in-generics-1.stderr @@ -1,8 +1,8 @@ error: trailing attribute after generic parameter - --> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25 + --> $DIR/attrs-with-no-formal-in-generics-1.rs:9:29 | -LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { - | ^^^^^^^ attributes must go before parameters +LL | impl<#[rustc_dummy] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { + | ^^^^^^^ attributes must go before parameters error: aborting due to previous error diff --git a/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.rs b/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.rs index c795612acf08c..d1d044035260b 100644 --- a/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.rs +++ b/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.rs @@ -6,7 +6,7 @@ struct RefAny<'a, T>(&'a T); -impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} +impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {} //~^ ERROR trailing attribute after generic parameter fn main() {} diff --git a/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.stderr b/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.stderr index acd0ae3678a7c..fce3ff7de78e8 100644 --- a/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.stderr +++ b/src/test/ui/attributes/attrs-with-no-formal-in-generics-2.stderr @@ -1,8 +1,8 @@ error: trailing attribute after generic parameter - --> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35 + --> $DIR/attrs-with-no-formal-in-generics-2.rs:9:43 | -LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} - | ^^^^^^^ attributes must go before parameters +LL | impl<#[rustc_dummy] 'a, #[rustc_dummy] T, #[oops]> RefAny<'a, T> {} + | ^^^^^^^ attributes must go before parameters error: aborting due to previous error diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs index 0395795ef7bfe..0f9d37292958a 100644 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs +++ b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs @@ -5,7 +5,7 @@ const fn error(_: fn()) {} #[stable(feature = "rust1", since = "1.0.0")] #[rustc_allow_const_fn_ptr] -//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved +//~^ ERROR internal implementation detail const fn compiles(_: fn()) {} fn main() {} diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr index c934307e918b9..d2ca0c8bc381b 100644 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr +++ b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr @@ -1,8 +1,8 @@ -error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics - --> $DIR/allow_const_fn_ptr_feature_gate.rs:7:3 +error[E0658]: internal implementation detail + --> $DIR/allow_const_fn_ptr_feature_gate.rs:7:1 | LL | #[rustc_allow_const_fn_ptr] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(rustc_attrs)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs index 5ec413cc71de0..d3a2e486416af 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs @@ -1,6 +1,23 @@ // Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. -#[rustc_foo] -//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved +#![feature(decl_macro)] +mod rustc { pub macro unknown() {} } +mod unknown { pub macro rustc() {} } + +#[rustc::unknown] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR macro `rustc::unknown` may not be used in attributes +fn f() {} + +#[unknown::rustc] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR macro `unknown::rustc` may not be used in attributes +fn g() {} + +#[rustc_dummy] +//~^ ERROR used by the test suite +#[rustc_unknown] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR attribute `rustc_unknown` is currently unknown fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 3c823c8d4e25f..cdc7b27a749e5 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -1,12 +1,60 @@ -error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics - --> $DIR/feature-gate-rustc-attrs.rs:3:3 +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:8:3 | -LL | #[rustc_foo] - | ^^^^^^^^^ +LL | #[rustc::unknown] + | ^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to previous error +error: macro `rustc::unknown` may not be used in attributes + --> $DIR/feature-gate-rustc-attrs.rs:8:1 + | +LL | #[rustc::unknown] + | ^^^^^^^^^^^^^^^^^ + +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:13:12 + | +LL | #[unknown::rustc] + | ^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(rustc_attrs)] to the crate attributes to enable + +error: macro `unknown::rustc` may not be used in attributes + --> $DIR/feature-gate-rustc-attrs.rs:13:1 + | +LL | #[unknown::rustc] + | ^^^^^^^^^^^^^^^^^ + +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:20:3 + | +LL | #[rustc_unknown] + | ^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(rustc_attrs)] to the crate attributes to enable + +error[E0658]: The attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/feature-gate-rustc-attrs.rs:20:3 + | +LL | #[rustc_unknown] + | ^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: used by the test suite + --> $DIR/feature-gate-rustc-attrs.rs:18:1 + | +LL | #[rustc_dummy] + | ^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(rustc_attrs)] to the crate attributes to enable + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-slice-patterns.stderr b/src/test/ui/feature-gates/feature-gate-slice-patterns.stderr index fe3c1e0afdd6b..03bf933cd084d 100644 --- a/src/test/ui/feature-gates/feature-gate-slice-patterns.stderr +++ b/src/test/ui/feature-gates/feature-gate-slice-patterns.stderr @@ -4,7 +4,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [1, 2, ..] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error[E0658]: syntax for subslices in slice patterns is not yet stabilized @@ -13,7 +13,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [1, .., 5] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error[E0658]: syntax for subslices in slice patterns is not yet stabilized @@ -22,7 +22,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [.., 4, 5] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error[E0658]: syntax for subslices in slice patterns is not yet stabilized @@ -31,7 +31,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [ xs.., 4, 5 ] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error[E0658]: syntax for subslices in slice patterns is not yet stabilized @@ -40,7 +40,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [ 1, xs.., 5 ] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error[E0658]: syntax for subslices in slice patterns is not yet stabilized @@ -49,7 +49,7 @@ error[E0658]: syntax for subslices in slice patterns is not yet stabilized LL | [ 1, 2, xs.. ] => {} | ^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/23121 + = note: for more information, see https://github.com/rust-lang/rust/issues/62254 = help: add #![feature(slice_patterns)] to the crate attributes to enable error: aborting due to 6 previous errors diff --git a/src/test/ui/generic/generic-param-attrs.rs b/src/test/ui/generic/generic-param-attrs.rs index 601d2a9e0a31f..6c628914f1f8d 100644 --- a/src/test/ui/generic/generic-param-attrs.rs +++ b/src/test/ui/generic/generic-param-attrs.rs @@ -1,44 +1,38 @@ // This test previously ensured that attributes on formals in generic parameter // lists are rejected without a feature gate. -// -// (We are prefixing all tested features with `rustc_`, to ensure that -// the attributes themselves won't be rejected by the compiler when -// using `rustc_attrs` feature. There is a separate compile-fail/ test -// ensuring that the attribute feature-gating works in this context.) // compile-pass #![feature(rustc_attrs)] -#![allow(dead_code)] - -struct StLt<#[rustc_lt_struct] 'a>(&'a u32); -struct StTy<#[rustc_ty_struct] I>(I); -enum EnLt<#[rustc_lt_enum] 'b> { A(&'b u32), B } -enum EnTy<#[rustc_ty_enum] J> { A(J), B } -trait TrLt<#[rustc_lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } -trait TrTy<#[rustc_ty_trait] K> { fn foo(&self, _: K); } -type TyLt<#[rustc_lt_type] 'd> = &'d u32; -type TyTy<#[rustc_ty_type] L> = (L, ); - -impl<#[rustc_lt_inherent] 'e> StLt<'e> { } -impl<#[rustc_ty_inherent] M> StTy { } -impl<#[rustc_lt_impl_for] 'f> TrLt<'f> for StLt<'f> { + +struct StLt<#[rustc_dummy] 'a>(&'a u32); +struct StTy<#[rustc_dummy] I>(I); +enum EnLt<#[rustc_dummy] 'b> { A(&'b u32), B } +enum EnTy<#[rustc_dummy] J> { A(J), B } +trait TrLt<#[rustc_dummy] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } +trait TrTy<#[rustc_dummy] K> { fn foo(&self, _: K); } +type TyLt<#[rustc_dummy] 'd> = &'d u32; +type TyTy<#[rustc_dummy] L> = (L, ); + +impl<#[rustc_dummy] 'e> StLt<'e> { } +impl<#[rustc_dummy] M> StTy { } +impl<#[rustc_dummy] 'f> TrLt<'f> for StLt<'f> { fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } } -impl<#[rustc_ty_impl_for] N> TrTy for StTy { +impl<#[rustc_dummy] N> TrTy for StTy { fn foo(&self, _: N) { } } -fn f_lt<#[rustc_lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } -fn f_ty<#[rustc_ty_fn] O>(_: O) { } +fn f_lt<#[rustc_dummy] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } +fn f_ty<#[rustc_dummy] O>(_: O) { } impl StTy { - fn m_lt<#[rustc_lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } - fn m_ty<#[rustc_ty_meth] P>(_: P) { } + fn m_lt<#[rustc_dummy] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } + fn m_ty<#[rustc_dummy] P>(_: P) { } } fn hof_lt(_: Q) - where Q: for <#[rustc_lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 + where Q: for <#[rustc_dummy] 'i> Fn(&'i [u32]) -> &'i u32 {} fn main() {} diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs b/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs index 1245ce8583e29..fb50dce1af616 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs @@ -1,10 +1,7 @@ -// compile-flags:-Zborrowck=mir -Zverbose - // Test that we can deduce when projections like `T::Item` outlive the // function body. Test that this does not imply that `T: 'a` holds. -#![allow(warnings)] -#![feature(rustc_attrs)] +// compile-flags:-Zborrowck=mir -Zverbose use std::cell::Cell; @@ -18,7 +15,6 @@ where f(&value, Cell::new(&n)); } -#[rustc_errors] fn generic1(value: T) { // No error here: twice(value, |value_ref, item| invoke1(item)); @@ -30,7 +26,6 @@ where { } -#[rustc_errors] fn generic2(value: T) { twice(value, |value_ref, item| invoke2(value_ref, item)); //~^ ERROR the parameter type `T` may not live long enough diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr index 9cdb78a10281c..9f0c60c1e1705 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/projection-implied-bounds.rs:35:18 + --> $DIR/projection-implied-bounds.rs:30:18 | LL | twice(value, |value_ref, item| invoke2(value_ref, item)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/ty-outlives/ty-param-implied-bounds.rs b/src/test/ui/nll/ty-outlives/ty-param-implied-bounds.rs index f61f54f80a78b..6a9ef3b5ce07f 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-implied-bounds.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-implied-bounds.rs @@ -4,9 +4,6 @@ // Test that we assume that universal types like `T` outlive the // function body. -#![allow(warnings)] -#![feature(rustc_attrs)] - use std::cell::Cell; fn twice(value: T, mut f: F) @@ -17,7 +14,6 @@ where f(Cell::new(&value)); } -#[rustc_errors] fn generic(value: T) { // No error here: twice(value, |r| invoke(r)); diff --git a/src/test/ui/object-lifetime/object-lifetime-default.stderr b/src/test/ui/object-lifetime/object-lifetime-default.stderr index 2642cdff2bf6a..f71c8cd0e0c39 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default.stderr @@ -1,20 +1,20 @@ -error: 'a,Ambiguous - --> $DIR/object-lifetime-default.rs:24:1 +error: BaseDefault + --> $DIR/object-lifetime-default.rs:6:1 | -LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct A(T); + | ^^^^^^^^^^^^^^^ -error: 'a,'b - --> $DIR/object-lifetime-default.rs:21:1 +error: BaseDefault + --> $DIR/object-lifetime-default.rs:9:1 | -LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct B<'a,T>(&'a (), T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: 'b - --> $DIR/object-lifetime-default.rs:18:1 +error: 'a + --> $DIR/object-lifetime-default.rs:12:1 | -LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct C<'a,T:'a>(&'a T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Ambiguous --> $DIR/object-lifetime-default.rs:15:1 @@ -22,23 +22,23 @@ error: Ambiguous LL | struct D<'a,'b,T:'a+'b>(&'a T, &'b T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: 'a - --> $DIR/object-lifetime-default.rs:12:1 +error: 'b + --> $DIR/object-lifetime-default.rs:18:1 | -LL | struct C<'a,T:'a>(&'a T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: BaseDefault - --> $DIR/object-lifetime-default.rs:9:1 +error: 'a,'b + --> $DIR/object-lifetime-default.rs:21:1 | -LL | struct B<'a,T>(&'a (), T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: BaseDefault - --> $DIR/object-lifetime-default.rs:6:1 +error: 'a,Ambiguous + --> $DIR/object-lifetime-default.rs:24:1 | -LL | struct A(T); - | ^^^^^^^^^^^^^^^ +LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.rs b/src/test/ui/proc-macro/expand-to-unstable-2.rs index 4b4ba52ecd726..437ae93093470 100644 --- a/src/test/ui/proc-macro/expand-to-unstable-2.rs +++ b/src/test/ui/proc-macro/expand-to-unstable-2.rs @@ -1,12 +1,12 @@ // aux-build:derive-unstable-2.rs -#![allow(warnings)] - #[macro_use] extern crate derive_unstable_2; #[derive(Unstable)] -//~^ ERROR: reserved for internal compiler +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR attribute `rustc_foo` is currently unknown to the compiler + struct A; fn main() { diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.stderr b/src/test/ui/proc-macro/expand-to-unstable-2.stderr index e2f51dd3d5dd2..803773db88e96 100644 --- a/src/test/ui/proc-macro/expand-to-unstable-2.stderr +++ b/src/test/ui/proc-macro/expand-to-unstable-2.stderr @@ -1,5 +1,5 @@ -error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics - --> $DIR/expand-to-unstable-2.rs:8:10 +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/expand-to-unstable-2.rs:6:10 | LL | #[derive(Unstable)] | ^^^^^^^^ @@ -7,6 +7,15 @@ LL | #[derive(Unstable)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to previous error +error[E0658]: The attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/expand-to-unstable-2.rs:6:10 + | +LL | #[derive(Unstable)] + | ^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/reserved/reserved-attr-on-macro.rs b/src/test/ui/reserved/reserved-attr-on-macro.rs index 96c63ba4db8c9..cb535362266c0 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.rs +++ b/src/test/ui/reserved/reserved-attr-on-macro.rs @@ -1,5 +1,7 @@ #[rustc_attribute_should_be_reserved] -//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved +//~^ ERROR attribute `rustc_attribute_should_be_reserved` is currently unknown +//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler + macro_rules! foo { () => (()); } diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index c8738d1ed3429..0c62c82017e18 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -1,4 +1,4 @@ -error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler --> $DIR/reserved-attr-on-macro.rs:1:3 | LL | #[rustc_attribute_should_be_reserved] @@ -7,14 +7,23 @@ LL | #[rustc_attribute_should_be_reserved] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(rustc_attrs)] to the crate attributes to enable +error[E0658]: The attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/reserved-attr-on-macro.rs:1:3 + | +LL | #[rustc_attribute_should_be_reserved] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + error: cannot determine resolution for the macro `foo` - --> $DIR/reserved-attr-on-macro.rs:8:5 + --> $DIR/reserved-attr-on-macro.rs:10:5 | LL | foo!(); | ^^^ | = note: import resolution is stuck, try simplifying macro imports -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/suggestions/attribute-typos.rs b/src/test/ui/suggestions/attribute-typos.rs index 13c6308b97e85..0e10131ce8d1f 100644 --- a/src/test/ui/suggestions/attribute-typos.rs +++ b/src/test/ui/suggestions/attribute-typos.rs @@ -1,13 +1,11 @@ -#[deprcated] //~ ERROR E0658 -fn foo() {} //~| HELP a built-in attribute with a similar name exists - //~| SUGGESTION deprecated - //~| HELP add #![feature(custom_attribute)] to the crate attributes to enable +#[deprcated] //~ ERROR attribute `deprcated` is currently unknown +fn foo() {} -#[tests] //~ ERROR E0658 -fn bar() {} //~| HELP a built-in attribute with a similar name exists - //~| SUGGESTION test - //~| HELP add #![feature(custom_attribute)] to the crate attributes to enable +#[tests] //~ ERROR attribute `tests` is currently unknown to the compiler +fn bar() {} -#[rustc_err] //~ ERROR E0658 -fn main() {} //~| HELP add #![feature(rustc_attrs)] to the crate attributes to enable - // don't suggest rustc attributes +#[rustc_err] +//~^ ERROR attribute `rustc_err` is currently unknown +//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler + +fn main() {} diff --git a/src/test/ui/suggestions/attribute-typos.stderr b/src/test/ui/suggestions/attribute-typos.stderr index 8367ff20aa408..958688b4d3906 100644 --- a/src/test/ui/suggestions/attribute-typos.stderr +++ b/src/test/ui/suggestions/attribute-typos.stderr @@ -1,5 +1,5 @@ -error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics - --> $DIR/attribute-typos.rs:11:3 +error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/attribute-typos.rs:7:3 | LL | #[rustc_err] | ^^^^^^^^^ @@ -7,8 +7,17 @@ LL | #[rustc_err] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(rustc_attrs)] to the crate attributes to enable +error[E0658]: The attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/attribute-typos.rs:7:3 + | +LL | #[rustc_err] + | ^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/attribute-typos.rs:6:3 + --> $DIR/attribute-typos.rs:4:3 | LL | #[tests] | ^^^^^ help: a built-in attribute with a similar name exists: `test` @@ -25,6 +34,6 @@ LL | #[deprcated] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/tools/rust-installer b/src/tools/rust-installer index ccdc47b657a76..4b07f7bc20910 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit ccdc47b657a7600cbd0c2858eb52a8d712cfce18 +Subproject commit 4b07f7bc2091052c6f52b780971f44e07bd3c71d