From 79b8ad84c84481a43704213cd0948d2ba0ea63b4 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sun, 23 Feb 2020 18:18:45 +0100 Subject: [PATCH 01/31] Implement `Copy` for `IoSlice` --- src/libstd/io/mod.rs | 1 + src/libstd/sys/cloudabi/io.rs | 1 + src/libstd/sys/hermit/io.rs | 1 + src/libstd/sys/sgx/io.rs | 1 + src/libstd/sys/unix/io.rs | 1 + src/libstd/sys/vxworks/io.rs | 1 + src/libstd/sys/wasi/io.rs | 1 + src/libstd/sys/wasm/io.rs | 1 + src/libstd/sys/windows/c.rs | 1 + src/libstd/sys/windows/io.rs | 1 + 10 files changed, 10 insertions(+) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 67b382c7a845e..5dd3ec996761e 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1051,6 +1051,7 @@ impl<'a> DerefMut for IoSliceMut<'a> { /// ABI compatible with the `iovec` type on Unix platforms and `WSABUF` on /// Windows. #[stable(feature = "iovec", since = "1.36.0")] +#[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a>(sys::io::IoSlice<'a>); diff --git a/src/libstd/sys/cloudabi/io.rs b/src/libstd/sys/cloudabi/io.rs index 976e122463d1b..d5f475b4310fd 100644 --- a/src/libstd/sys/cloudabi/io.rs +++ b/src/libstd/sys/cloudabi/io.rs @@ -1,5 +1,6 @@ use crate::mem; +#[derive(Copy, Clone)] pub struct IoSlice<'a>(&'a [u8]); impl<'a> IoSlice<'a> { diff --git a/src/libstd/sys/hermit/io.rs b/src/libstd/sys/hermit/io.rs index 976e122463d1b..d5f475b4310fd 100644 --- a/src/libstd/sys/hermit/io.rs +++ b/src/libstd/sys/hermit/io.rs @@ -1,5 +1,6 @@ use crate::mem; +#[derive(Copy, Clone)] pub struct IoSlice<'a>(&'a [u8]); impl<'a> IoSlice<'a> { diff --git a/src/libstd/sys/sgx/io.rs b/src/libstd/sys/sgx/io.rs index 976e122463d1b..d5f475b4310fd 100644 --- a/src/libstd/sys/sgx/io.rs +++ b/src/libstd/sys/sgx/io.rs @@ -1,5 +1,6 @@ use crate::mem; +#[derive(Copy, Clone)] pub struct IoSlice<'a>(&'a [u8]); impl<'a> IoSlice<'a> { diff --git a/src/libstd/sys/unix/io.rs b/src/libstd/sys/unix/io.rs index b4a64e93c842b..deb5ee76bd035 100644 --- a/src/libstd/sys/unix/io.rs +++ b/src/libstd/sys/unix/io.rs @@ -3,6 +3,7 @@ use crate::slice; use libc::{c_void, iovec}; +#[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { vec: iovec, diff --git a/src/libstd/sys/vxworks/io.rs b/src/libstd/sys/vxworks/io.rs index f1a2c8446ff8b..0f68ebf8da9cc 100644 --- a/src/libstd/sys/vxworks/io.rs +++ b/src/libstd/sys/vxworks/io.rs @@ -3,6 +3,7 @@ use crate::slice; use libc::{c_void, iovec}; +#[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { vec: iovec, diff --git a/src/libstd/sys/wasi/io.rs b/src/libstd/sys/wasi/io.rs index ee20ea6dab87a..0ad2e152855b7 100644 --- a/src/libstd/sys/wasi/io.rs +++ b/src/libstd/sys/wasi/io.rs @@ -1,6 +1,7 @@ use crate::marker::PhantomData; use crate::slice; +#[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { vec: wasi::Ciovec, diff --git a/src/libstd/sys/wasm/io.rs b/src/libstd/sys/wasm/io.rs index 976e122463d1b..d5f475b4310fd 100644 --- a/src/libstd/sys/wasm/io.rs +++ b/src/libstd/sys/wasm/io.rs @@ -1,5 +1,6 @@ use crate::mem; +#[derive(Copy, Clone)] pub struct IoSlice<'a>(&'a [u8]); impl<'a> IoSlice<'a> { diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 4d377341be30f..d7e1a8010308a 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -295,6 +295,7 @@ pub struct WSADATA { pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1], } +#[derive(Copy, Clone)] #[repr(C)] pub struct WSABUF { pub len: ULONG, diff --git a/src/libstd/sys/windows/io.rs b/src/libstd/sys/windows/io.rs index 9d8018fd5e864..5525d2832526f 100644 --- a/src/libstd/sys/windows/io.rs +++ b/src/libstd/sys/windows/io.rs @@ -2,6 +2,7 @@ use crate::marker::PhantomData; use crate::slice; use crate::sys::c; +#[derive(Copy, Clone)] #[repr(transparent)] pub struct IoSlice<'a> { vec: c::WSABUF, From 9fa79813f9a9b63b298bdb5469f085072481830b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 5 Mar 2020 21:56:42 +0100 Subject: [PATCH 02/31] rustdoc: don't call into_iter() on iterator. (clippy::identity_conversion) --- src/librustdoc/html/markdown.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 42529a6682ec1..2479363f94588 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -870,7 +870,7 @@ pub fn plain_summary_line(md: &str) -> String { } let mut s = String::with_capacity(md.len() * 3 / 2); let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true }; - p.into_iter().filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i)); + p.filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i)); s } From 6bfff8a30356e3dd7eaa1c6b9d08e1e7d978d5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 5 Mar 2020 22:01:12 +0100 Subject: [PATCH 03/31] rustdoc: Use .any(p) instead of find(p).is_some(). (clippy::search_is_some) --- src/librustdoc/html/render.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 07fe439ace226..c851bc3cdd80c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3401,10 +3401,8 @@ fn render_assoc_items( let deref_impl = traits.iter().find(|t| t.inner_impl().trait_.def_id() == c.deref_trait_did); if let Some(impl_) = deref_impl { - let has_deref_mut = traits - .iter() - .find(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did) - .is_some(); + let has_deref_mut = + traits.iter().any(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did); render_deref_methods(w, cx, impl_, containing_item, has_deref_mut); } @@ -3816,7 +3814,7 @@ fn render_impl( ) { for trait_item in &t.items { let n = trait_item.name.clone(); - if i.items.iter().find(|m| m.name == n).is_some() { + if i.items.iter().any(|m| m.name == n) { continue; } let did = i.trait_.as_ref().unwrap().def_id().unwrap(); From 7aad89a9001cc5e1a10aa1730483749a1ed04f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 5 Mar 2020 21:50:44 +0100 Subject: [PATCH 04/31] Use ?-operator in more places (clippy::question_mark, had some false negatives fixed recently) --- src/libcore/str/pattern.rs | 13 +++++-------- src/librustc/hir/map/mod.rs | 2 +- src/librustc/ty/util.rs | 7 +------ src/librustc_driver/lib.rs | 7 +------ src/librustc_infer/traits/specialize/mod.rs | 7 +------ src/librustc_resolve/lib.rs | 6 +----- src/librustc_span/lib.rs | 6 +----- src/librustdoc/clean/inline.rs | 6 +----- src/librustdoc/html/markdown.rs | 6 +----- 9 files changed, 13 insertions(+), 47 deletions(-) diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 6c826e5dcdec0..ffa418cba6c99 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> { let haystack = self.haystack.as_bytes(); loop { // get the haystack up to but not including the last character searched - let bytes = if let Some(slice) = haystack.get(self.finger..self.finger_back) { - slice - } else { - return None; - }; + let bytes = haystack.get(self.finger..self.finger_back)?; // the last byte of the utf8 encoded needle // SAFETY: we have an invariant that `utf8_size < 5` let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) }; @@ -575,11 +571,12 @@ macro_rules! pattern_methods { #[inline] fn is_suffix_of(self, haystack: &'a str) -> bool - where $t: ReverseSearcher<'a> + where + $t: ReverseSearcher<'a>, { ($pmap)(self).is_suffix_of(haystack) } - } + }; } macro_rules! searcher_methods { @@ -614,7 +611,7 @@ macro_rules! searcher_methods { fn next_reject_back(&mut self) -> Option<(usize, usize)> { self.0.next_reject_back() } - } + }; } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index bd26e02efb749..f69b3325ba504 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -298,7 +298,7 @@ impl<'hir> Map<'hir> { } pub fn def_kind(&self, hir_id: HirId) -> Option { - let node = if let Some(node) = self.find(hir_id) { node } else { return None }; + let node = self.find(hir_id)?; Some(match node { Node::Item(item) => match item.kind { diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index fcebedb2601c2..69daa2da1fd0e 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> { adt_did: DefId, validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>, ) -> Option { - let drop_trait = if let Some(def_id) = self.lang_items().drop_trait() { - def_id - } else { - return None; - }; - + let drop_trait = self.lang_items().drop_trait()?; self.ensure().coherent_trait(drop_trait); let mut dtor_did = None; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 789507fb48b52..f7d2fe6e3f8bf 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1120,12 +1120,7 @@ fn extra_compiler_flags() -> Option<(Vec, bool)> { return None; } - let matches = if let Some(matches) = handle_options(&args) { - matches - } else { - return None; - }; - + let matches = handle_options(&args)?; let mut result = Vec::new(); let mut excluded_cargo_defaults = false; for flag in ICE_REPORT_COMPILER_FLAGS { diff --git a/src/librustc_infer/traits/specialize/mod.rs b/src/librustc_infer/traits/specialize/mod.rs index ee1c737c208f7..de7fe3d9a2e2f 100644 --- a/src/librustc_infer/traits/specialize/mod.rs +++ b/src/librustc_infer/traits/specialize/mod.rs @@ -413,12 +413,7 @@ pub(super) fn specialization_graph_provider( fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option { use std::fmt::Write; - let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) { - tr - } else { - return None; - }; - + let trait_ref = tcx.impl_trait_ref(impl_def_id)?; let mut w = "impl".to_owned(); let substs = InternalSubsts::identity_for_item(tcx, impl_def_id); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 44eba0d533d3a..4009f4047ea7d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2778,12 +2778,8 @@ impl<'a> Resolver<'a> { } else { let crate_id = if !speculative { self.crate_loader.process_path_extern(ident.name, ident.span) - } else if let Some(crate_id) = - self.crate_loader.maybe_process_path_extern(ident.name, ident.span) - { - crate_id } else { - return None; + self.crate_loader.maybe_process_path_extern(ident.name, ident.span)? }; let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); Some( diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 502ea64aab9b5..66fb4cd251a9b 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -1167,11 +1167,7 @@ impl SourceFile { } let begin = { - let line = if let Some(line) = self.lines.get(line_number) { - line - } else { - return None; - }; + let line = self.lines.get(line_number)?; let begin: BytePos = *line - self.start_pos; begin.to_usize() }; diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 618dfa0d33aae..ae597acf1dc34 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -42,11 +42,7 @@ pub fn try_inline( attrs: Option>, visited: &mut FxHashSet, ) -> Option> { - let did = if let Some(did) = res.opt_def_id() { - did - } else { - return None; - }; + let did = res.opt_def_id()?; if did.is_local() { return None; } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 2479363f94588..e13bf270440e2 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -844,11 +844,7 @@ pub fn plain_summary_line(md: &str) -> String { type Item = String; fn next(&mut self) -> Option { - let next_event = self.inner.next(); - if next_event.is_none() { - return None; - } - let next_event = next_event.unwrap(); + let next_event = self.inner.next()?; let (ret, is_in) = match next_event { Event::Start(Tag::Paragraph) => (None, 1), Event::Start(Tag::Heading(_)) => (None, 1), From 45108b195f5a98304e34503bd0655f3871179816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 23:31:14 +0100 Subject: [PATCH 05/31] rustdoc: simplify boolean condition (clippy::nonminimal_bool) --- src/librustdoc/clean/inline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ae597acf1dc34..341313a6e5fd4 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -577,7 +577,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean: name: ref _name, }, ref bounds, - } => !(*s == "Self" && did == trait_did) && !bounds.is_empty(), + } => !(bounds.is_empty() || *s == "Self" && did == trait_did), _ => true, }); g From 1351db31fb646085e6c6f4bc5917d9392eb2a720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 23:50:23 +0100 Subject: [PATCH 06/31] iterate over a maps values directly. (clippy::for_kv_map) --- src/librustdoc/html/render.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c851bc3cdd80c..6fcf22743b1ac 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1542,7 +1542,7 @@ impl Context { } if self.shared.sort_modules_alphabetically { - for (_, items) in &mut map { + for items in map.values_mut() { items.sort(); } } From 254ceae30aa9504c59046b603d63bf43697f79b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 23:55:20 +0100 Subject: [PATCH 07/31] call .as_deref() instead of .as_ref().map(Deref::deref) (clippy::option_as_ref_deref) --- src/librustc_resolve/late/diagnostics.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index fd62c80293425..4d451691f4419 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -1107,11 +1107,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { } }; - match ( - lifetime_names.len(), - lifetime_names.iter().next(), - snippet.as_ref().map(|s| s.as_str()), - ) { + match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) { (1, Some(name), Some("&")) => { suggest_existing(err, format!("&{} ", name)); } From 0d7faaf6bd3bae11ac8098f2c0d931994b791875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 23:59:22 +0100 Subject: [PATCH 08/31] rustdoc: remove redundant static lifetimes (clippy::redundant_static_lifetimes) --- src/librustdoc/html/static_files.rs | 56 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 9fc1d76185fb7..6790f3bd5d0b1 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -8,106 +8,106 @@ //! directly written to a `Write` handle. /// The file contents of the main `rustdoc.css` file, responsible for the core layout of the page. -pub static RUSTDOC_CSS: &'static str = include_str!("static/rustdoc.css"); +pub static RUSTDOC_CSS: &str = include_str!("static/rustdoc.css"); /// The file contents of `settings.css`, responsible for the items on the settings page. -pub static SETTINGS_CSS: &'static str = include_str!("static/settings.css"); +pub static SETTINGS_CSS: &str = include_str!("static/settings.css"); /// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled. -pub static NOSCRIPT_CSS: &'static str = include_str!("static/noscript.css"); +pub static NOSCRIPT_CSS: &str = include_str!("static/noscript.css"); /// The file contents of `normalize.css`, included to even out standard elements between browser /// implementations. -pub static NORMALIZE_CSS: &'static str = include_str!("static/normalize.css"); +pub static NORMALIZE_CSS: &str = include_str!("static/normalize.css"); /// The file contents of `main.js`, which contains the core JavaScript used on documentation pages, /// including search behavior and docblock folding, among others. -pub static MAIN_JS: &'static str = include_str!("static/main.js"); +pub static MAIN_JS: &str = include_str!("static/main.js"); /// The file contents of `settings.js`, which contains the JavaScript used to handle the settings /// page. -pub static SETTINGS_JS: &'static str = include_str!("static/settings.js"); +pub static SETTINGS_JS: &str = include_str!("static/settings.js"); /// The file contents of `storage.js`, which contains functionality related to browser Local /// Storage, used to store documentation settings. -pub static STORAGE_JS: &'static str = include_str!("static/storage.js"); +pub static STORAGE_JS: &str = include_str!("static/storage.js"); /// The file contents of `brush.svg`, the icon used for the theme-switch button. -pub static BRUSH_SVG: &'static [u8] = include_bytes!("static/brush.svg"); +pub static BRUSH_SVG: &[u8] = include_bytes!("static/brush.svg"); /// The file contents of `wheel.svg`, the icon used for the settings button. -pub static WHEEL_SVG: &'static [u8] = include_bytes!("static/wheel.svg"); +pub static WHEEL_SVG: &[u8] = include_bytes!("static/wheel.svg"); /// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox. -pub static DOWN_ARROW_SVG: &'static [u8] = include_bytes!("static/down-arrow.svg"); +pub static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/down-arrow.svg"); /// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation /// output. -pub static COPYRIGHT: &'static [u8] = include_bytes!("static/COPYRIGHT.txt"); +pub static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt"); /// The contents of `LICENSE-APACHE.txt`, the text of the Apache License, version 2.0. -pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE.txt"); +pub static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt"); /// The contents of `LICENSE-MIT.txt`, the text of the MIT License. -pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt"); +pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt"); /// The contents of `rust-logo.png`, the default icon of the documentation. -pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png"); +pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png"); /// The contents of `favicon.ico`, the default favicon of the documentation. -pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico"); +pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico"); /// The built-in themes given to every documentation site. pub mod themes { /// The "light" theme, selected by default when no setting is available. Used as the basis for /// the `--check-theme` functionality. - pub static LIGHT: &'static str = include_str!("static/themes/light.css"); + pub static LIGHT: &str = include_str!("static/themes/light.css"); /// The "dark" theme. - pub static DARK: &'static str = include_str!("static/themes/dark.css"); + pub static DARK: &str = include_str!("static/themes/dark.css"); } /// Files related to the Fira Sans font. pub mod fira_sans { /// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font. - pub static REGULAR: &'static [u8] = include_bytes!("static/FiraSans-Regular.woff"); + pub static REGULAR: &[u8] = include_bytes!("static/FiraSans-Regular.woff"); /// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font. - pub static MEDIUM: &'static [u8] = include_bytes!("static/FiraSans-Medium.woff"); + pub static MEDIUM: &[u8] = include_bytes!("static/FiraSans-Medium.woff"); /// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font. - pub static LICENSE: &'static [u8] = include_bytes!("static/FiraSans-LICENSE.txt"); + pub static LICENSE: &[u8] = include_bytes!("static/FiraSans-LICENSE.txt"); } /// Files related to the Source Serif Pro font. pub mod source_serif_pro { /// The file `SourceSerifPro-Regular.ttf.woff`, the Regular variant of the Source Serif Pro /// font. - pub static REGULAR: &'static [u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff"); + pub static REGULAR: &[u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff"); /// The file `SourceSerifPro-Bold.ttf.woff`, the Bold variant of the Source Serif Pro font. - pub static BOLD: &'static [u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff"); + pub static BOLD: &[u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff"); /// The file `SourceSerifPro-It.ttf.woff`, the Italic variant of the Source Serif Pro font. - pub static ITALIC: &'static [u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff"); + pub static ITALIC: &[u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff"); /// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font. - pub static LICENSE: &'static [u8] = include_bytes!("static/SourceSerifPro-LICENSE.md"); + pub static LICENSE: &[u8] = include_bytes!("static/SourceSerifPro-LICENSE.md"); } /// Files related to the Source Code Pro font. pub mod source_code_pro { /// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font. - pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.woff"); + pub static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff"); /// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font. - pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); + pub static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. - pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); + pub static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); } /// Files related to the sidebar in rustdoc sources. pub mod sidebar { /// File script to handle sidebar. - pub static SOURCE_SCRIPT: &'static str = include_str!("static/source-script.js"); + pub static SOURCE_SCRIPT: &str = include_str!("static/source-script.js"); } From cca3d5216099de7333501b65a4d5cffe03270d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 00:15:46 +0100 Subject: [PATCH 09/31] libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast) --- src/libtest/stats.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index aab8d012fdf68..077005371c0cf 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -204,7 +204,7 @@ impl Stats for [f64] { } fn median(&self) -> f64 { - self.percentile(50 as f64) + self.percentile(50_f64) } fn var(&self) -> f64 { @@ -230,7 +230,7 @@ impl Stats for [f64] { } fn std_dev_pct(&self) -> f64 { - let hundred = 100 as f64; + let hundred = 100_f64; (self.std_dev() / self.mean()) * hundred } @@ -244,7 +244,7 @@ impl Stats for [f64] { } fn median_abs_dev_pct(&self) -> f64 { - let hundred = 100 as f64; + let hundred = 100_f64; (self.median_abs_dev() / self.median()) * hundred } @@ -257,11 +257,11 @@ impl Stats for [f64] { fn quartiles(&self) -> (f64, f64, f64) { let mut tmp = self.to_vec(); local_sort(&mut tmp); - let first = 25f64; + let first = 25_f64; let a = percentile_of_sorted(&tmp, first); - let second = 50f64; + let second = 50_f64; let b = percentile_of_sorted(&tmp, second); - let third = 75f64; + let third = 75_f64; let c = percentile_of_sorted(&tmp, third); (a, b, c) } @@ -281,7 +281,7 @@ fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 { } let zero: f64 = 0.0; assert!(zero <= pct); - let hundred = 100f64; + let hundred = 100_f64; assert!(pct <= hundred); if pct == hundred { return sorted_samples[sorted_samples.len() - 1]; @@ -307,7 +307,7 @@ pub fn winsorize(samples: &mut [f64], pct: f64) { let mut tmp = samples.to_vec(); local_sort(&mut tmp); let lo = percentile_of_sorted(&tmp, pct); - let hundred = 100 as f64; + let hundred = 100_f64; let hi = percentile_of_sorted(&tmp, hundred - pct); for samp in samples { if *samp > hi { From 77af19eb71632a3b3561ec2ae4f544925b517d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 00:19:25 +0100 Subject: [PATCH 10/31] remove unneeded mutable references (cippy::unnecessary_mut_passed) --- src/librustc_infer/traits/auto_trait.rs | 4 ++-- src/librustc_mir/transform/generator.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_infer/traits/auto_trait.rs b/src/librustc_infer/traits/auto_trait.rs index 3166fe0657697..f3df0b036def8 100644 --- a/src/librustc_infer/traits/auto_trait.rs +++ b/src/librustc_infer/traits/auto_trait.rs @@ -113,7 +113,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { return AutoTraitResult::ExplicitImpl; } - return tcx.infer_ctxt().enter(|mut infcx| { + return tcx.infer_ctxt().enter(|infcx| { let mut fresh_preds = FxHashSet::default(); // Due to the way projections are handled by SelectionContext, we need to run @@ -164,7 +164,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { let (full_env, full_user_env) = self .evaluate_predicates( - &mut infcx, + &infcx, trait_did, ty, new_env, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index d060a0eab3db0..27a1373cdcc7a 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -944,7 +944,7 @@ fn create_generator_drop_shim<'tcx>( // unrelated code from the resume part of the function simplify::remove_dead_blocks(&mut body); - dump_mir(tcx, None, "generator_drop", &0, source, &mut body, |_, _| Ok(())); + dump_mir(tcx, None, "generator_drop", &0, source, &body, |_, _| Ok(())); body } From f326f0f70fe48d3d8a47cfff373bff1402078850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 00:37:51 +0100 Subject: [PATCH 11/31] libtest: remove redundant argument to writeln!() (clippy::writeln_empty_string) --- src/librustc_mir/util/liveness.rs | 4 ++-- src/librustc_mir/util/pretty.rs | 10 +++++----- src/libtest/console.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index b12ad1e4c15cc..f6c6f55549593 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -293,7 +293,7 @@ fn dump_matched_mir_node<'tcx>( writeln!(file, "// MIR local liveness analysis for `{}`", node_path)?; writeln!(file, "// source = {:?}", source)?; writeln!(file, "// pass_name = {}", pass_name)?; - writeln!(file, "")?; + writeln!(file)?; write_mir_fn(tcx, source, body, &mut file, result)?; Ok(()) }); @@ -316,7 +316,7 @@ pub fn write_mir_fn<'tcx>( write_basic_block(tcx, block, body, &mut |_, _| Ok(()), w)?; print(w, " ", &result.outs)?; if block.index() + 1 != body.basic_blocks().len() { - writeln!(w, "")?; + writeln!(w)?; } } diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 1fd5f3c439587..c7cfa8917e640 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -134,7 +134,7 @@ fn dump_matched_mir_node<'tcx, F>( if let Some(ref layout) = body.generator_layout { writeln!(file, "// generator_layout = {:?}", layout)?; } - writeln!(file, "")?; + writeln!(file)?; extra_data(PassWhere::BeforeCFG, &mut file)?; write_user_type_annotations(body, &mut file)?; write_mir_fn(tcx, source, body, &mut extra_data, &mut file)?; @@ -242,13 +242,13 @@ pub fn write_mir_pretty<'tcx>( first = false; } else { // Put empty lines between all items - writeln!(w, "")?; + writeln!(w)?; } write_mir_fn(tcx, MirSource::item(def_id), body, &mut |_, _| Ok(()), w)?; for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() { - writeln!(w, "")?; + writeln!(w)?; let src = MirSource { instance: ty::InstanceDef::Item(def_id), promoted: Some(i) }; write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?; } @@ -271,7 +271,7 @@ where extra_data(PassWhere::BeforeBlock(block), w)?; write_basic_block(tcx, block, body, extra_data, w)?; if block.index() + 1 != body.basic_blocks().len() { - writeln!(w, "")?; + writeln!(w)?; } } @@ -529,7 +529,7 @@ pub fn write_mir_intro<'tcx>( write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?; // Add an empty line before the first block is printed. - writeln!(w, "")?; + writeln!(w)?; Ok(()) } diff --git a/src/libtest/console.rs b/src/libtest/console.rs index 149c9202e6e2d..ff741e3bd53be 100644 --- a/src/libtest/console.rs +++ b/src/libtest/console.rs @@ -169,7 +169,7 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Res if !quiet { if ntest != 0 || nbench != 0 { - writeln!(output, "")?; + writeln!(output)?; } writeln!(output, "{}, {}", plural(ntest, "test"), plural(nbench, "benchmark"))?; From 3f87f8cfee8e8a79ebc1f94ba5114ce51baf447d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 00:48:31 +0100 Subject: [PATCH 12/31] Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::write_with_newline) --- src/libstd/sys_common/backtrace.rs | 2 +- src/libtest/formatters/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 289ee07babfcf..2c7ba8f8ea1fd 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -70,7 +70,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| { output_filename(fmt, bows, print_fmt, cwd.as_ref()) }; - write!(fmt, "stack backtrace:\n")?; + writeln!(fmt, "stack backtrace:")?; let mut bt_fmt = BacktraceFmt::new(fmt, print_fmt, &mut print_path); bt_fmt.add_context()?; let mut idx = 0; diff --git a/src/libtest/formatters/mod.rs b/src/libtest/formatters/mod.rs index a64c0fc263d80..1fb840520a656 100644 --- a/src/libtest/formatters/mod.rs +++ b/src/libtest/formatters/mod.rs @@ -36,5 +36,5 @@ pub(crate) fn write_stderr_delimiter(test_output: &mut Vec, test_name: &Test Some(_) => test_output.push(b'\n'), None => (), } - write!(test_output, "---- {} stderr ----\n", test_name).unwrap(); + writeln!(test_output, "---- {} stderr ----", test_name).unwrap(); } From 83511383706e069bc7c6b3a7d957846ad51e818f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 10:57:02 +0100 Subject: [PATCH 13/31] reduce references on match patterns (clippy::match_ref_pats) --- src/libstd/sys_common/process.rs | 2 +- src/libstd/sys_common/wtf8.rs | 8 ++++---- src/libtest/types.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs index 042641852b3e9..f3a2962098b4d 100644 --- a/src/libstd/sys_common/process.rs +++ b/src/libstd/sys_common/process.rs @@ -47,7 +47,7 @@ impl CommandEnv { } } for (key, maybe_val) in self.vars.iter() { - if let &Some(ref val) = maybe_val { + if let Some(ref val) = maybe_val { env::set_var(key, val); } else { env::remove_var(key); diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 1d96cdfe46042..7509e1ee35dee 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -603,8 +603,8 @@ impl Wtf8 { if len < 3 { return None; } - match &self.bytes[(len - 3)..] { - &[0xED, b2 @ 0xA0..=0xAF, b3] => Some(decode_surrogate(b2, b3)), + match self.bytes[(len - 3)..] { + [0xED, b2 @ 0xA0..=0xAF, b3] => Some(decode_surrogate(b2, b3)), _ => None, } } @@ -615,8 +615,8 @@ impl Wtf8 { if len < 3 { return None; } - match &self.bytes[..3] { - &[0xED, b2 @ 0xB0..=0xBF, b3] => Some(decode_surrogate(b2, b3)), + match self.bytes[..3] { + [0xED, b2 @ 0xB0..=0xBF, b3] => Some(decode_surrogate(b2, b3)), _ => None, } } diff --git a/src/libtest/types.rs b/src/libtest/types.rs index 2619f99592aa9..5b75d2f367fff 100644 --- a/src/libtest/types.rs +++ b/src/libtest/types.rs @@ -59,10 +59,10 @@ impl TestName { } pub fn with_padding(&self, padding: NamePadding) -> TestName { - let name = match self { - &TestName::StaticTestName(name) => Cow::Borrowed(name), - &TestName::DynTestName(ref name) => Cow::Owned(name.clone()), - &TestName::AlignedTestName(ref name, _) => name.clone(), + let name = match *self { + TestName::StaticTestName(name) => Cow::Borrowed(name), + TestName::DynTestName(ref name) => Cow::Owned(name.clone()), + TestName::AlignedTestName(ref name, _) => name.clone(), }; TestName::AlignedTestName(name, padding) From 611cfd5f150101164b42de9532a94b922954d5da Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 12 Mar 2020 13:11:07 +0100 Subject: [PATCH 14/31] Clean up E0423 explanation --- src/librustc_error_codes/error_codes/E0423.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0423.md b/src/librustc_error_codes/error_codes/E0423.md index 6a7c31f5e0d43..a98ada17a469c 100644 --- a/src/librustc_error_codes/error_codes/E0423.md +++ b/src/librustc_error_codes/error_codes/E0423.md @@ -1,8 +1,7 @@ An identifier was used like a function name or a value was expected and the identifier exists but it belongs to a different namespace. -For (an erroneous) example, here a `struct` variant name were used as a -function: +Erroneous code example: ```compile_fail,E0423 struct Foo { a: bool }; From 118003d2dce98965e4ce1332101c7afb821c6113 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 12 Mar 2020 16:22:12 +0100 Subject: [PATCH 15/31] triagebot.toml: add ping aliases --- triagebot.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index a174dd1e7f3fe..848650a8546b7 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -11,6 +11,7 @@ allow-unauthenticated = [ [assign] [ping.icebreakers-llvm] +alias = ["llvm"] message = """\ Hey LLVM ICE-breakers! This bug has been identified as a good "LLVM ICE-breaking candidate". In case it's useful, here are some @@ -22,6 +23,7 @@ Thanks! <3 label = "ICEBreaker-LLVM" [ping.icebreakers-cleanup-crew] +alias = ["cleanup", "shrink", "reduce", "bisect"] message = """\ Hey Cleanup Crew ICE-breakers! This bug has been identified as a good "Cleanup ICE-breaking candidate". In case it's useful, here are some From 7326e530f2e146e38de8eaab4e66d2710732a0f6 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 12 Mar 2020 16:58:34 +0100 Subject: [PATCH 16/31] Move some const-eval `build-pass` tests to `check-pass` --- src/test/ui/consts/const-eval/const_prop_errors.rs | 2 +- src/test/ui/consts/const-eval/const_signed_pat.rs | 2 +- src/test/ui/consts/const-eval/double_check.rs | 2 +- src/test/ui/consts/const-eval/double_promotion.rs | 2 +- src/test/ui/consts/const-eval/duration_conversion.rs | 2 +- src/test/ui/consts/const-eval/extern_fat_pointer.rs | 2 +- src/test/ui/consts/const-eval/ice-generic-assoc-const.rs | 2 +- src/test/ui/consts/const-eval/ice-packed.rs | 2 +- src/test/ui/consts/const-eval/issue-47971.rs | 2 +- src/test/ui/consts/const-eval/issue-50706.rs | 2 +- src/test/ui/consts/const-eval/issue-51300.rs | 2 +- src/test/ui/consts/const-eval/issue-53157.rs | 2 +- src/test/ui/consts/const-eval/issue-53401.rs | 2 +- src/test/ui/consts/const-eval/issue-55541.rs | 2 +- .../ui/consts/const-eval/no_lint_for_statically_known_error.rs | 2 +- .../ui/consts/const-eval/promote_mutable_zst_mir_borrowck.rs | 2 +- src/test/ui/consts/const-eval/pub_const_err.rs | 2 +- src/test/ui/consts/const-eval/pub_const_err_bin.rs | 2 +- src/test/ui/consts/const-eval/simple_with_undef.rs | 2 +- src/test/ui/consts/const-eval/zst_operand_eval.rs | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/ui/consts/const-eval/const_prop_errors.rs b/src/test/ui/consts/const-eval/const_prop_errors.rs index 48cfea82bd65e..f9a36d37943f3 100644 --- a/src/test/ui/consts/const-eval/const_prop_errors.rs +++ b/src/test/ui/consts/const-eval/const_prop_errors.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass pub trait Foo { fn foo(self) -> u32; diff --git a/src/test/ui/consts/const-eval/const_signed_pat.rs b/src/test/ui/consts/const-eval/const_signed_pat.rs index d209e60448687..c61239bb677e8 100644 --- a/src/test/ui/consts/const-eval/const_signed_pat.rs +++ b/src/test/ui/consts/const-eval/const_signed_pat.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass fn main() { const MIN: i8 = -5; diff --git a/src/test/ui/consts/const-eval/double_check.rs b/src/test/ui/consts/const-eval/double_check.rs index ff2fff7fb790e..f156d259abb20 100644 --- a/src/test/ui/consts/const-eval/double_check.rs +++ b/src/test/ui/consts/const-eval/double_check.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass enum Foo { A = 5, diff --git a/src/test/ui/consts/const-eval/double_promotion.rs b/src/test/ui/consts/const-eval/double_promotion.rs index a9a3f071bf89f..542fb36eb1eb4 100644 --- a/src/test/ui/consts/const-eval/double_promotion.rs +++ b/src/test/ui/consts/const-eval/double_promotion.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// build-pass #![feature(const_fn, rustc_attrs)] diff --git a/src/test/ui/consts/const-eval/duration_conversion.rs b/src/test/ui/consts/const-eval/duration_conversion.rs index 029d4e5e3732e..87b12937dd4f2 100644 --- a/src/test/ui/consts/const-eval/duration_conversion.rs +++ b/src/test/ui/consts/const-eval/duration_conversion.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass use std::time::Duration; diff --git a/src/test/ui/consts/const-eval/extern_fat_pointer.rs b/src/test/ui/consts/const-eval/extern_fat_pointer.rs index e2b3bc83c3f01..f210d1a0a90c5 100644 --- a/src/test/ui/consts/const-eval/extern_fat_pointer.rs +++ b/src/test/ui/consts/const-eval/extern_fat_pointer.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(extern_types)] diff --git a/src/test/ui/consts/const-eval/ice-generic-assoc-const.rs b/src/test/ui/consts/const-eval/ice-generic-assoc-const.rs index ce0e11f29f442..4444cdfcda9c7 100644 --- a/src/test/ui/consts/const-eval/ice-generic-assoc-const.rs +++ b/src/test/ui/consts/const-eval/ice-generic-assoc-const.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass pub trait Nullable { const NULL: Self; diff --git a/src/test/ui/consts/const-eval/ice-packed.rs b/src/test/ui/consts/const-eval/ice-packed.rs index 250bf954e9ac2..08f244c3860b5 100644 --- a/src/test/ui/consts/const-eval/ice-packed.rs +++ b/src/test/ui/consts/const-eval/ice-packed.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// build-pass #[derive(Copy, Clone, PartialEq, Eq)] #[repr(packed)] pub struct Num(u64); diff --git a/src/test/ui/consts/const-eval/issue-47971.rs b/src/test/ui/consts/const-eval/issue-47971.rs index 9de150bd0528d..b98e76031d4f3 100644 --- a/src/test/ui/consts/const-eval/issue-47971.rs +++ b/src/test/ui/consts/const-eval/issue-47971.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass struct S(pub &'static u32, pub u32); diff --git a/src/test/ui/consts/const-eval/issue-50706.rs b/src/test/ui/consts/const-eval/issue-50706.rs index bf69bc28da41a..a13c27f2e7802 100644 --- a/src/test/ui/consts/const-eval/issue-50706.rs +++ b/src/test/ui/consts/const-eval/issue-50706.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass pub struct Stats; diff --git a/src/test/ui/consts/const-eval/issue-51300.rs b/src/test/ui/consts/const-eval/issue-51300.rs index 4753bf0f7b174..94cc471bffe56 100644 --- a/src/test/ui/consts/const-eval/issue-51300.rs +++ b/src/test/ui/consts/const-eval/issue-51300.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// build-pass // https://github.com/rust-lang/rust/issues/51300 #[derive(PartialEq, Eq, Clone, Copy)] diff --git a/src/test/ui/consts/const-eval/issue-53157.rs b/src/test/ui/consts/const-eval/issue-53157.rs index ac0940b33e47a..850338625bc01 100644 --- a/src/test/ui/consts/const-eval/issue-53157.rs +++ b/src/test/ui/consts/const-eval/issue-53157.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass macro_rules! m { () => {{ diff --git a/src/test/ui/consts/const-eval/issue-53401.rs b/src/test/ui/consts/const-eval/issue-53401.rs index d300e0b5125da..31c946c3cb761 100644 --- a/src/test/ui/consts/const-eval/issue-53401.rs +++ b/src/test/ui/consts/const-eval/issue-53401.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass pub const STATIC_TRAIT: &dyn Test = &(); diff --git a/src/test/ui/consts/const-eval/issue-55541.rs b/src/test/ui/consts/const-eval/issue-55541.rs index d04570c67ff2e..4c9e10d9cbe16 100644 --- a/src/test/ui/consts/const-eval/issue-55541.rs +++ b/src/test/ui/consts/const-eval/issue-55541.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // Test that we can handle newtypes wrapping extern types diff --git a/src/test/ui/consts/const-eval/no_lint_for_statically_known_error.rs b/src/test/ui/consts/const-eval/no_lint_for_statically_known_error.rs index cea367528c975..910ca3c4bcbb6 100644 --- a/src/test/ui/consts/const-eval/no_lint_for_statically_known_error.rs +++ b/src/test/ui/consts/const-eval/no_lint_for_statically_known_error.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // if `X` were used instead of `x`, `X - 10` would result in a lint. // This file should never produce a lint, no matter how the const diff --git a/src/test/ui/consts/const-eval/promote_mutable_zst_mir_borrowck.rs b/src/test/ui/consts/const-eval/promote_mutable_zst_mir_borrowck.rs index ca75d65a39a92..edda10e6e82e9 100644 --- a/src/test/ui/consts/const-eval/promote_mutable_zst_mir_borrowck.rs +++ b/src/test/ui/consts/const-eval/promote_mutable_zst_mir_borrowck.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass pub fn main() { let y: &'static mut [u8; 0] = &mut []; diff --git a/src/test/ui/consts/const-eval/pub_const_err.rs b/src/test/ui/consts/const-eval/pub_const_err.rs index 4ff140fee7a71..ad165d40a76f2 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.rs +++ b/src/test/ui/consts/const-eval/pub_const_err.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![warn(const_err)] #![crate_type = "lib"] diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.rs b/src/test/ui/consts/const-eval/pub_const_err_bin.rs index 7f1586336e721..078e4c896df80 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.rs +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![warn(const_err)] pub const Z: u32 = 0 - 1; diff --git a/src/test/ui/consts/const-eval/simple_with_undef.rs b/src/test/ui/consts/const-eval/simple_with_undef.rs index 8a9f3fe974d91..1a416dd460d68 100644 --- a/src/test/ui/consts/const-eval/simple_with_undef.rs +++ b/src/test/ui/consts/const-eval/simple_with_undef.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass const PARSE_BOOL: Option<&'static str> = None; static FOO: (Option<&str>, u32) = (PARSE_BOOL, 42); diff --git a/src/test/ui/consts/const-eval/zst_operand_eval.rs b/src/test/ui/consts/const-eval/zst_operand_eval.rs index 7edb6bd03dabf..5f7ddf7f758e0 100644 --- a/src/test/ui/consts/const-eval/zst_operand_eval.rs +++ b/src/test/ui/consts/const-eval/zst_operand_eval.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass static ASSERT: () = [()][!(std::mem::size_of::() == 4) as usize]; From 8f0fa24d7bb6d3b51430e49e84a469c9aeeecd56 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 12 Mar 2020 17:22:44 +0100 Subject: [PATCH 17/31] Move some more tests to `check-pass` --- src/test/ui/consts/const-eval/double_promotion.rs | 2 +- src/test/ui/consts/const-eval/ice-packed.rs | 5 ++++- src/test/ui/consts/const-eval/issue-51300.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/ui/consts/const-eval/double_promotion.rs b/src/test/ui/consts/const-eval/double_promotion.rs index 542fb36eb1eb4..48f4426d9cff4 100644 --- a/src/test/ui/consts/const-eval/double_promotion.rs +++ b/src/test/ui/consts/const-eval/double_promotion.rs @@ -1,4 +1,4 @@ -// build-pass +// check-pass #![feature(const_fn, rustc_attrs)] diff --git a/src/test/ui/consts/const-eval/ice-packed.rs b/src/test/ui/consts/const-eval/ice-packed.rs index 08f244c3860b5..4758a5a9d561c 100644 --- a/src/test/ui/consts/const-eval/ice-packed.rs +++ b/src/test/ui/consts/const-eval/ice-packed.rs @@ -1,4 +1,7 @@ -// build-pass +// Regression test for #50356: Compiler panic when using repr(packed) +// associated constant in a match arm + +// check-pass #[derive(Copy, Clone, PartialEq, Eq)] #[repr(packed)] pub struct Num(u64); diff --git a/src/test/ui/consts/const-eval/issue-51300.rs b/src/test/ui/consts/const-eval/issue-51300.rs index 94cc471bffe56..8e68e8c911785 100644 --- a/src/test/ui/consts/const-eval/issue-51300.rs +++ b/src/test/ui/consts/const-eval/issue-51300.rs @@ -1,4 +1,4 @@ -// build-pass +// check-pass // https://github.com/rust-lang/rust/issues/51300 #[derive(PartialEq, Eq, Clone, Copy)] From 90e8058716337c78a84e97a8a8885838fd8b6f67 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 12 Mar 2020 18:06:40 +0100 Subject: [PATCH 18/31] triagebot.toml: add typo aliases --- triagebot.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 848650a8546b7..18a942699d3ec 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -11,7 +11,7 @@ allow-unauthenticated = [ [assign] [ping.icebreakers-llvm] -alias = ["llvm"] +alias = ["llvm", "llvms"] message = """\ Hey LLVM ICE-breakers! This bug has been identified as a good "LLVM ICE-breaking candidate". In case it's useful, here are some @@ -23,7 +23,7 @@ Thanks! <3 label = "ICEBreaker-LLVM" [ping.icebreakers-cleanup-crew] -alias = ["cleanup", "shrink", "reduce", "bisect"] +alias = ["cleanup", "cleanups", "shrink", "reduce", "bisect"] message = """\ Hey Cleanup Crew ICE-breakers! This bug has been identified as a good "Cleanup ICE-breaking candidate". In case it's useful, here are some From f32cccc05e8c47ed799a99d06dbfb1571fa6908c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 12 Mar 2020 19:38:09 +0100 Subject: [PATCH 19/31] rename panic_if_ intrinsics to assert_ --- src/libcore/intrinsics.rs | 10 ++++++++-- src/libcore/mem/maybe_uninit.rs | 12 ++++++++++++ src/libcore/mem/mod.rs | 4 ++-- src/librustc_codegen_ssa/mir/block.rs | 8 ++++---- src/librustc_typeck/check/intrinsic.rs | 2 +- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 3c060cc6e840b..953b7a986514d 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1005,17 +1005,23 @@ extern "rust-intrinsic" { /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: /// This will statically either panic, or do nothing. + #[cfg(bootstrap)] pub fn panic_if_uninhabited(); + /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: + /// This will statically either panic, or do nothing. + #[cfg(not(bootstrap))] + pub fn assert_inhabited(); + /// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// zero-initialization: This will statically either panic, or do nothing. #[cfg(not(bootstrap))] - pub fn panic_if_zero_invalid(); + pub fn assert_zero_valid(); /// A guard for unsafe functions that cannot ever be executed if `T` has invalid /// bit patterns: This will statically either panic, or do nothing. #[cfg(not(bootstrap))] - pub fn panic_if_any_invalid(); + pub fn assert_uninit_valid(); /// Gets a reference to a static `Location` indicating where it was called. #[rustc_const_unstable(feature = "const_caller_location", issue = "47809")] diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 58aaac21ad751..bf39d56fc115c 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -495,7 +495,10 @@ impl MaybeUninit { #[inline(always)] #[rustc_diagnostic_item = "assume_init"] pub unsafe fn assume_init(self) -> T { + #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); + #[cfg(not(bootstrap))] + intrinsics::assert_inhabited::(); ManuallyDrop::into_inner(self.value) } @@ -559,7 +562,10 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_extra", issue = "63567")] #[inline(always)] pub unsafe fn read(&self) -> T { + #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); + #[cfg(not(bootstrap))] + intrinsics::assert_inhabited::(); self.as_ptr().read() } @@ -621,7 +627,10 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[inline(always)] pub unsafe fn get_ref(&self) -> &T { + #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); + #[cfg(not(bootstrap))] + intrinsics::assert_inhabited::(); &*self.value } @@ -739,7 +748,10 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[inline(always)] pub unsafe fn get_mut(&mut self) -> &mut T { + #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); + #[cfg(not(bootstrap))] + intrinsics::assert_inhabited::(); &mut *self.value } diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 7d9a8bcd05b1c..e65150af59f81 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -497,7 +497,7 @@ pub const fn needs_drop() -> bool { #[rustc_diagnostic_item = "mem_zeroed"] pub unsafe fn zeroed() -> T { #[cfg(not(bootstrap))] - intrinsics::panic_if_zero_invalid::(); + intrinsics::assert_zero_valid::(); #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); intrinsics::init() @@ -533,7 +533,7 @@ pub unsafe fn zeroed() -> T { #[rustc_diagnostic_item = "mem_uninitialized"] pub unsafe fn uninitialized() -> T { #[cfg(not(bootstrap))] - intrinsics::panic_if_any_invalid::(); + intrinsics::assert_uninit_valid::(); #[cfg(bootstrap)] intrinsics::panic_if_uninhabited::(); intrinsics::uninit() diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 9ce23ff5f3fc8..eef06c3579477 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -449,7 +449,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>, cleanup: Option, ) -> bool { - // Emit a panic or a no-op for `panic_if_uninhabited`. + // Emit a panic or a no-op for `assert_*` intrinsics. // These are intrinsics that compile to panics so that we can get a message // which mentions the offending type, even from a const context. #[derive(Debug, PartialEq)] @@ -460,9 +460,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; let panic_intrinsic = intrinsic.and_then(|i| match i { // FIXME: Move to symbols instead of strings. - "panic_if_uninhabited" => Some(PanicIntrinsic::IfUninhabited), - "panic_if_zero_invalid" => Some(PanicIntrinsic::IfZeroInvalid), - "panic_if_any_invalid" => Some(PanicIntrinsic::IfAnyInvalid), + "assert_inhabited" => Some(PanicIntrinsic::IfUninhabited), + "assert_zero_valid" => Some(PanicIntrinsic::IfZeroInvalid), + "assert_uninit_valid" => Some(PanicIntrinsic::IfAnyInvalid), _ => None, }); if let Some(intrinsic) = panic_intrinsic { diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index d2a358c3e09b8..dac67c2f5a27d 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -147,7 +147,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { ), "rustc_peek" => (1, vec![param(0)], param(0)), "caller_location" => (0, vec![], tcx.caller_location_ty()), - "panic_if_uninhabited" | "panic_if_zero_invalid" | "panic_if_any_invalid" => { + "assert_inhabited" | "assert_zero_valid" | "assert_uninit_valid" => { (1, Vec::new(), tcx.mk_unit()) } "init" => (1, Vec::new(), param(0)), From 7b1b08cfee6881705eed931e24b8abd4e68ef328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 7 Mar 2020 00:56:32 +0100 Subject: [PATCH 20/31] remove lifetimes that can be elided (clippy::needless_lifetimes) --- src/liballoc/collections/linked_list.rs | 2 +- src/librustc/dep_graph/dep_node.rs | 2 +- src/librustc/hir/map/collector.rs | 2 +- src/librustc/hir/map/hir_id_validator.rs | 2 +- src/librustc/mir/mod.rs | 4 ++-- src/librustc_codegen_llvm/common.rs | 4 ++-- src/librustc_codegen_llvm/llvm/mod.rs | 6 ++--- src/librustc_codegen_llvm/type_.rs | 2 +- src/librustc_data_structures/graph/scc/mod.rs | 2 +- .../graph/vec_graph/mod.rs | 2 +- src/librustc_driver/pretty.rs | 22 +++++++++---------- src/librustc_hir/intravisit.rs | 2 +- src/librustc_incremental/assert_dep_graph.rs | 2 +- .../persist/dirty_clean.rs | 2 +- .../infer/error_reporting/need_type_info.rs | 2 +- .../nice_region_error/find_anon_type.rs | 2 +- src/librustc_infer/traits/coherence.rs | 2 +- src/librustc_lint/late.rs | 4 ++-- src/librustc_lint/levels.rs | 2 +- src/librustc_mir/const_eval/mod.rs | 2 +- src/librustc_mir/transform/add_retag.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- src/librustc_mir/transform/mod.rs | 2 +- src/librustc_parse/lib.rs | 6 ++--- src/librustc_passes/check_attr.rs | 2 +- src/librustc_passes/lang_items.rs | 2 +- src/librustc_passes/upvars.rs | 4 ++-- src/librustc_traits/lowering/mod.rs | 2 +- src/librustc_ty/ty.rs | 2 +- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/op.rs | 2 +- src/librustc_typeck/coherence/builtin.rs | 2 +- 32 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 73ae267ddab7f..53d4f7239b76e 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -1427,7 +1427,7 @@ impl<'a, T> CursorMut<'a, T> { /// `CursorMut`, which means it cannot outlive the `CursorMut` and that the /// `CursorMut` is frozen for the lifetime of the `Cursor`. #[unstable(feature = "linked_list_cursors", issue = "58533")] - pub fn as_cursor<'cm>(&'cm self) -> Cursor<'cm, T> { + pub fn as_cursor(&self) -> Cursor<'_, T> { Cursor { list: self.list, current: self.current, index: self.index } } } diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 5cbaa5a42f678..03218920ef1aa 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -179,7 +179,7 @@ macro_rules! define_dep_nodes { $( #[inline(always)] #[allow(unreachable_code, non_snake_case)] - pub fn $variant<'tcx>(_tcx: TyCtxt<'tcx>, $(arg: $tuple_arg_ty)*) -> DepNode { + pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode { // tuple args $({ erase!($tuple_arg_ty); diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index ebd335ab35504..ca5f9ba5ad62d 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -340,7 +340,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { /// deep walking so that we walk nested items in the context of /// their outer items. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { panic!("`visit_nested_xxx` must be manually implemented in this visitor"); } diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index a4f9193c0eb64..f176f92434372 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -135,7 +135,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> { impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { type Map = Map<'hir>; - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::OnlyBodies(self.hir_map) } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index b2413f5a2c83f..ec882e02c603b 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -403,7 +403,7 @@ pub enum ClearCrossCrate { } impl ClearCrossCrate { - pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> { + pub fn as_ref(&self) -> ClearCrossCrate<&T> { match self { ClearCrossCrate::Clear => ClearCrossCrate::Clear, ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v), @@ -2503,7 +2503,7 @@ impl UserTypeProjection { pub(crate) fn variant( mut self, - adt_def: &'tcx AdtDef, + adt_def: &AdtDef, variant_index: VariantIdx, field: Field, ) -> Self { diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index df38eeec00fce..6293d5ddd3bc0 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -320,7 +320,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { } } -pub fn val_ty(v: &'ll Value) -> &'ll Type { +pub fn val_ty(v: &Value) -> &Type { unsafe { llvm::LLVMTypeOf(v) } } @@ -342,6 +342,6 @@ fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 { ((hi as u128) << 64) | (lo as u128) } -fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> { +fn try_as_const_integral(v: &Value) -> Option<&ConstantInt> { unsafe { llvm::LLVMIsAConstantInt(v) } } diff --git a/src/librustc_codegen_llvm/llvm/mod.rs b/src/librustc_codegen_llvm/llvm/mod.rs index 96014cbee5da1..a083e14979c0b 100644 --- a/src/librustc_codegen_llvm/llvm/mod.rs +++ b/src/librustc_codegen_llvm/llvm/mod.rs @@ -185,12 +185,12 @@ impl Drop for SectionIter<'a> { } } -pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> { +pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter<'_> { unsafe { SectionIter { llsi: LLVMGetSections(llof) } } } /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun. -pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value { +pub fn get_param(llfn: &Value, index: c_uint) -> &Value { unsafe { assert!( index < LLVMCountParams(llfn), @@ -203,7 +203,7 @@ pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value { } /// Safe wrapper for `LLVMGetValueName2` into a byte slice -pub fn get_value_name(value: &'a Value) -> &'a [u8] { +pub fn get_value_name(value: &Value) -> &[u8] { unsafe { let mut len = 0; let data = LLVMGetValueName2(value, &mut len); diff --git a/src/librustc_codegen_llvm/type_.rs b/src/librustc_codegen_llvm/type_.rs index aacaf130f9aa9..5bc1475df23a7 100644 --- a/src/librustc_codegen_llvm/type_.rs +++ b/src/librustc_codegen_llvm/type_.rs @@ -240,7 +240,7 @@ impl Type { unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) } } - pub fn i8p_llcx(llcx: &'ll llvm::Context) -> &'ll Type { + pub fn i8p_llcx(llcx: &llvm::Context) -> &Type { Type::i8_llcx(llcx).ptr_to() } diff --git a/src/librustc_data_structures/graph/scc/mod.rs b/src/librustc_data_structures/graph/scc/mod.rs index 70fc2d7dad9ee..7ecf3e3cb8d5d 100644 --- a/src/librustc_data_structures/graph/scc/mod.rs +++ b/src/librustc_data_structures/graph/scc/mod.rs @@ -97,7 +97,7 @@ impl GraphSuccessors<'graph> for Sccs { } impl WithSuccessors for Sccs { - fn successors<'graph>(&'graph self, node: S) -> >::Iter { + fn successors(&self, node: S) -> >::Iter { self.successors(node).iter().cloned() } } diff --git a/src/librustc_data_structures/graph/vec_graph/mod.rs b/src/librustc_data_structures/graph/vec_graph/mod.rs index 22c50afe6d0b4..064467174cae2 100644 --- a/src/librustc_data_structures/graph/vec_graph/mod.rs +++ b/src/librustc_data_structures/graph/vec_graph/mod.rs @@ -101,7 +101,7 @@ impl GraphSuccessors<'graph> for VecGraph { } impl WithSuccessors for VecGraph { - fn successors<'graph>(&'graph self, node: N) -> >::Iter { + fn successors(&self, node: N) -> >::Iter { self.successors(node).iter().cloned() } } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index ca129ac59849a..65fe1fec52643 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -96,7 +96,7 @@ trait PrinterSupport: pprust::PpAnn { /// /// (Rust does not yet support upcasting from a trait object to /// an object for one of its super-traits.) - fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn; + fn pp_ann(&self) -> &dyn pprust::PpAnn; } trait HirPrinterSupport<'hir>: pprust_hir::PpAnn { @@ -106,13 +106,13 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn { /// Provides a uniform interface for re-extracting a reference to an /// `hir_map::Map` from a value that now owns it. - fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>; + fn hir_map(&self) -> Option<&hir_map::Map<'hir>>; /// Produces the pretty-print annotation object. /// /// (Rust does not yet support upcasting from a trait object to /// an object for one of its super-traits.) - fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn; + fn pp_ann(&self) -> &dyn pprust_hir::PpAnn; /// Computes an user-readable representation of a path, if possible. fn node_path(&self, id: hir::HirId) -> Option { @@ -132,7 +132,7 @@ impl<'hir> PrinterSupport for NoAnn<'hir> { self.sess } - fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn { + fn pp_ann(&self) -> &dyn pprust::PpAnn { self } } @@ -142,11 +142,11 @@ impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> { self.sess } - fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { + fn hir_map(&self) -> Option<&hir_map::Map<'hir>> { self.tcx.map(|tcx| *tcx.hir()) } - fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { + fn pp_ann(&self) -> &dyn pprust_hir::PpAnn { self } } @@ -170,7 +170,7 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> { self.sess } - fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn { + fn pp_ann(&self) -> &dyn pprust::PpAnn { self } } @@ -216,11 +216,11 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> { self.sess } - fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { + fn hir_map(&self) -> Option<&hir_map::Map<'hir>> { self.tcx.map(|tcx| *tcx.hir()) } - fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { + fn pp_ann(&self) -> &dyn pprust_hir::PpAnn { self } } @@ -315,11 +315,11 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { &self.tcx.sess } - fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { + fn hir_map(&self) -> Option<&hir_map::Map<'tcx>> { Some(&self.tcx.hir()) } - fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { + fn pp_ann(&self) -> &dyn pprust_hir::PpAnn { self } diff --git a/src/librustc_hir/intravisit.rs b/src/librustc_hir/intravisit.rs index 45257b04d7907..6191a5137ccaf 100644 --- a/src/librustc_hir/intravisit.rs +++ b/src/librustc_hir/intravisit.rs @@ -284,7 +284,7 @@ pub trait Visitor<'v>: Sized { /// If you use this, you probably don't want to process the /// contents of nested item-like things, since the outer loop will /// visit them as well. - fn as_deep_visitor<'s>(&'s mut self) -> DeepVisitor<'s, Self> { + fn as_deep_visitor(&mut self) -> DeepVisitor<'_, Self> { DeepVisitor::new(self) } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index c82ed0c2c4970..c2b62f9670c8b 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -162,7 +162,7 @@ impl IfThisChanged<'tcx> { impl Visitor<'tcx> for IfThisChanged<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index e212dc81070ac..d22417980cdb2 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -548,7 +548,7 @@ impl FindAllAttrs<'tcx> { impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index 285f0c9cf51a9..94976266467b0 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -69,7 +69,7 @@ impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.hir_map) } diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs index 2ae7f4cc04f98..14cf35932c494 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -93,7 +93,7 @@ struct FindNestedTypeVisitor<'tcx> { impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_infer/traits/coherence.rs b/src/librustc_infer/traits/coherence.rs index 15c5f4d402ac3..2096c93e10694 100644 --- a/src/librustc_infer/traits/coherence.rs +++ b/src/librustc_infer/traits/coherence.rs @@ -451,7 +451,7 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool { } } -fn ty_is_non_local_constructor<'tcx>(ty: Ty<'tcx>, in_crate: InCrate) -> Option> { +fn ty_is_non_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> Option> { debug!("ty_is_non_local_constructor({:?})", ty); match ty.kind { diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index ee03232a0ce4c..0964dfa28998e 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -33,7 +33,7 @@ use std::slice; /// Extract the `LintStore` from the query context. /// This function exists because we've erased `LintStore` as `dyn Any` in the context. -crate fn unerased_lint_store<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx LintStore { +crate fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore { let store: &dyn Any = &*tcx.lint_store; store.downcast_ref().unwrap() } @@ -99,7 +99,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> /// Because lints are scoped lexically, we want to walk nested /// items in the context of the outer item, so enable /// deep-walking. - fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<'_, Self::Map> { hir_visit::NestedVisitorMap::All(&self.context.tcx.hir()) } diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index e0db2ae64ff21..0e85b8d2a39ed 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -438,7 +438,7 @@ impl LintLevelMapBuilder<'_, '_> { impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_mir/const_eval/mod.rs b/src/librustc_mir/const_eval/mod.rs index cb6583976258b..605091d6c7d41 100644 --- a/src/librustc_mir/const_eval/mod.rs +++ b/src/librustc_mir/const_eval/mod.rs @@ -43,7 +43,7 @@ pub(crate) fn const_field<'tcx>( op_to_const(&ecx, field) } -pub(crate) fn const_caller_location<'tcx>( +pub(crate) fn const_caller_location( tcx: TyCtxt<'tcx>, (file, line, col): (Symbol, u32, u32), ) -> ConstValue<'tcx> { diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index 2306177c14b8a..aa9cad7ffc19f 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -34,7 +34,7 @@ fn is_stable(place: PlaceRef<'_>) -> bool { } /// Determine whether this type may be a reference (or box), and thus needs retagging. -fn may_be_reference<'tcx>(ty: Ty<'tcx>) -> bool { +fn may_be_reference(ty: Ty<'tcx>) -> bool { match ty.kind { // Primitive types that are not references ty::Bool diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 4dcbcdcbae4a6..152a98c0c1aa2 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -453,7 +453,7 @@ struct UnusedUnsafeVisitor<'a> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::None } diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 57e002bf3f3d6..95e2db7508099 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -87,7 +87,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet { intravisit::walk_struct_def(self, v) } type Map = Map<'tcx>; - fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } } diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs index fe75062ee503c..884499ff2dd48 100644 --- a/src/librustc_parse/lib.rs +++ b/src/librustc_parse/lib.rs @@ -271,11 +271,11 @@ pub fn stream_to_parser<'a>( /// The main usage of this function is outside of rustc, for those who uses /// librustc_ast as a library. Please do not remove this function while refactoring /// just because it is not used in rustc codebase! -pub fn stream_to_parser_with_base_dir<'a>( - sess: &'a ParseSess, +pub fn stream_to_parser_with_base_dir( + sess: &ParseSess, stream: TokenStream, base_dir: Directory, -) -> Parser<'a> { +) -> Parser<'_> { Parser::new(sess, stream, Some(base_dir), true, false, None) } diff --git a/src/librustc_passes/check_attr.rs b/src/librustc_passes/check_attr.rs index f1ed074d6ab77..7ee16de52beab 100644 --- a/src/librustc_passes/check_attr.rs +++ b/src/librustc_passes/check_attr.rs @@ -418,7 +418,7 @@ impl CheckAttrVisitor<'tcx> { impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_passes/lang_items.rs b/src/librustc_passes/lang_items.rs index 5f5acc7fdf815..88e92bbdba1aa 100644 --- a/src/librustc_passes/lang_items.rs +++ b/src/librustc_passes/lang_items.rs @@ -143,7 +143,7 @@ impl LanguageItemCollector<'tcx> { } /// Traverses and collects all the lang items in all crates. -fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems { +fn collect(tcx: TyCtxt<'_>) -> LanguageItems { // Initialize the collector. let mut collector = LanguageItemCollector::new(tcx); diff --git a/src/librustc_passes/upvars.rs b/src/librustc_passes/upvars.rs index a2397f273385a..6be4f130c1f96 100644 --- a/src/librustc_passes/upvars.rs +++ b/src/librustc_passes/upvars.rs @@ -46,7 +46,7 @@ struct LocalCollector { impl Visitor<'tcx> for LocalCollector { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -75,7 +75,7 @@ impl CaptureCollector<'_, '_> { impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 97b81c224d593..1c816decffa6d 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -603,7 +603,7 @@ impl ClauseDumper<'tcx> { impl Visitor<'tcx> for ClauseDumper<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index 6bc29d0493e68..5a87cf4c10d0d 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -210,7 +210,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] { } } -fn associated_items<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AssociatedItems { +fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AssociatedItems { let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did)); tcx.arena.alloc(ty::AssociatedItems::new(items)) } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 3720b74d92e07..022b2e82964e0 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -111,7 +111,7 @@ fn identity(_: Ty<'_>) -> Vec> { vec![] } -fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { +fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { move |target| vec![Adjustment { kind, target }] } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index bf3511a26143c..f7bbde35aa72e 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -860,7 +860,7 @@ enum Op { } /// Dereferences a single level of immutable referencing. -fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { +fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> { match ty.kind { ty::Ref(_, ty, hir::Mutability::Not) => ty, _ => ty, diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index aa39a191b3df6..7d7d34e45a634 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -322,7 +322,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: DefId) { } } -pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { +pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap(); From e9c96570d6a0dde7c14c56c1dafe828e69f18c28 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 12 Mar 2020 21:22:22 +0100 Subject: [PATCH 21/31] miri engine: fix treatment of abort intrinsic --- src/librustc_mir/interpret/intrinsics.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 869eb1227f23b..37a60bcc8368d 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -84,14 +84,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let substs = instance.substs; let intrinsic_name = self.tcx.item_name(instance.def_id()); - // We currently do not handle any intrinsics that are *allowed* to diverge, - // but `transmute` could lack a return place in case of UB. + // First handle intrinsics without return place. let (dest, ret) = match ret { - Some(p) => p, None => match intrinsic_name { - sym::transmute => throw_ub!(Unreachable), + sym::transmute => throw_ub_format!("transmuting to uninhabited type"), + sym::abort => M::abort(self)?, + // Unsupported diverging intrinsic. _ => return Ok(false), }, + Some(p) => p, }; // Keep the patterns in this match ordered the same as the list in @@ -103,10 +104,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.write_scalar(location.ptr, dest)?; } - sym::abort => { - M::abort(self)?; - } - sym::min_align_of | sym::pref_align_of | sym::needs_drop From 081e32baba731377ed85ecb146977c51421e299b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 09:03:30 +0900 Subject: [PATCH 22/31] Add test for issue-58490 --- src/test/ui/macros/issue-58490.rs | 26 ++++++++++++++++++++++++++ src/test/ui/macros/issue-58490.stderr | 14 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/ui/macros/issue-58490.rs create mode 100644 src/test/ui/macros/issue-58490.stderr diff --git a/src/test/ui/macros/issue-58490.rs b/src/test/ui/macros/issue-58490.rs new file mode 100644 index 0000000000000..97e71c9a1ce40 --- /dev/null +++ b/src/test/ui/macros/issue-58490.rs @@ -0,0 +1,26 @@ +// Regression test for #58490 + +macro_rules! a { + ( @1 $i:item ) => { + a! { @2 $i } + }; + ( @2 $i:item ) => { + $i + }; +} +mod b { + a! { + @1 + #[macro_export] + macro_rules! b { () => () } + } + #[macro_export] + macro_rules! b { () => () } + //~^ ERROR: the name `b` is defined multiple times +} +mod c { + #[allow(unused_imports)] + use crate::b; +} + +fn main() {} diff --git a/src/test/ui/macros/issue-58490.stderr b/src/test/ui/macros/issue-58490.stderr new file mode 100644 index 0000000000000..b1f0896f3b65c --- /dev/null +++ b/src/test/ui/macros/issue-58490.stderr @@ -0,0 +1,14 @@ +error[E0428]: the name `b` is defined multiple times + --> $DIR/issue-58490.rs:18:5 + | +LL | macro_rules! b { () => () } + | -------------- previous definition of the macro `b` here +... +LL | macro_rules! b { () => () } + | ^^^^^^^^^^^^^^ `b` redefined here + | + = note: `b` must be defined only once in the macro namespace of this module + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0428`. From 0efc2cf5472cd884df68918daf4f9861c1b808b1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 09:03:44 +0900 Subject: [PATCH 23/31] Add test for issue-60390 --- src/test/ui/mir/issue-60390.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/test/ui/mir/issue-60390.rs diff --git a/src/test/ui/mir/issue-60390.rs b/src/test/ui/mir/issue-60390.rs new file mode 100644 index 0000000000000..fd9d6b46dd444 --- /dev/null +++ b/src/test/ui/mir/issue-60390.rs @@ -0,0 +1,8 @@ +// check-pass +// compile-flags: --emit=mir,link +// Regression test for #60390, this ICE requires `--emit=mir` flag. + +fn main() { + enum Inner { Member(u32) }; + Inner::Member(0); +} From a2c41e9cdc5b92535326d764b94536f00e5eb3bd Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 09:03:58 +0900 Subject: [PATCH 24/31] Add test for issue-62504 --- .../ui/const-generics/issues/issue-62504.rs | 25 +++++++++++++++++++ .../const-generics/issues/issue-62504.stderr | 8 ++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-62504.rs create mode 100644 src/test/ui/const-generics/issues/issue-62504.stderr diff --git a/src/test/ui/const-generics/issues/issue-62504.rs b/src/test/ui/const-generics/issues/issue-62504.rs new file mode 100644 index 0000000000000..74ed3d354fc74 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62504.rs @@ -0,0 +1,25 @@ +// Regression test for #62504 + +#![feature(const_generics)] +#![allow(incomplete_features)] + +trait HasSize { + const SIZE: usize; +} + +impl HasSize for ArrayHolder<{ X }> { + const SIZE: usize = X; +} + +struct ArrayHolder([u32; X]); + +impl ArrayHolder<{ X }> { + pub const fn new() -> Self { + ArrayHolder([0; Self::SIZE]) + //~^ ERROR: array lengths can't depend on generic parameters + } +} + +fn main() { + let mut array = ArrayHolder::new(); +} diff --git a/src/test/ui/const-generics/issues/issue-62504.stderr b/src/test/ui/const-generics/issues/issue-62504.stderr new file mode 100644 index 0000000000000..c2a752ec1715f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62504.stderr @@ -0,0 +1,8 @@ +error: array lengths can't depend on generic parameters + --> $DIR/issue-62504.rs:18:25 + | +LL | ArrayHolder([0; Self::SIZE]) + | ^^^^^^^^^^ + +error: aborting due to previous error + From 3609bac340f6e5350a4d0c214d810e6f27fba2ba Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 09:04:14 +0900 Subject: [PATCH 25/31] Add test for issue-67739 --- .../ui/const-generics/issues/issue-67739.rs | 18 ++++++++++++++++++ .../const-generics/issues/issue-67739.stderr | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-67739.rs create mode 100644 src/test/ui/const-generics/issues/issue-67739.stderr diff --git a/src/test/ui/const-generics/issues/issue-67739.rs b/src/test/ui/const-generics/issues/issue-67739.rs new file mode 100644 index 0000000000000..79c5ac9dd187e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67739.rs @@ -0,0 +1,18 @@ +// Regression test for #67739 + +#![allow(incomplete_features)] +#![feature(const_generics)] + +use std::mem; + +pub trait Trait { + type Associated: Sized; + + fn associated_size(&self) -> usize { + [0u8; mem::size_of::()]; + //~^ ERROR: array lengths can't depend on generic parameters + 0 + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67739.stderr b/src/test/ui/const-generics/issues/issue-67739.stderr new file mode 100644 index 0000000000000..a31b556c086f8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67739.stderr @@ -0,0 +1,8 @@ +error: array lengths can't depend on generic parameters + --> $DIR/issue-67739.rs:12:15 + | +LL | [0u8; mem::size_of::()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 7c987eb02091c01763c5fb688f093f8974e733b1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 09:04:27 +0900 Subject: [PATCH 26/31] Add test for issue-69092 --- src/test/ui/asm/issue-69092.rs | 10 ++++++++++ src/test/ui/asm/issue-69092.stderr | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/test/ui/asm/issue-69092.rs create mode 100644 src/test/ui/asm/issue-69092.stderr diff --git a/src/test/ui/asm/issue-69092.rs b/src/test/ui/asm/issue-69092.rs new file mode 100644 index 0000000000000..caa5c2e0b9f96 --- /dev/null +++ b/src/test/ui/asm/issue-69092.rs @@ -0,0 +1,10 @@ +// build-fail +// ignore-emscripten no asm! support +// Regression test for #69092 + +#![feature(asm)] + +fn main() { + unsafe { asm!(".ascii \"Xen\0\""); } + //~^ ERROR: :1:9: error: expected string in '.ascii' directive +} diff --git a/src/test/ui/asm/issue-69092.stderr b/src/test/ui/asm/issue-69092.stderr new file mode 100644 index 0000000000000..5661097cb8b80 --- /dev/null +++ b/src/test/ui/asm/issue-69092.stderr @@ -0,0 +1,11 @@ +error: :1:9: error: expected string in '.ascii' directive + .ascii "Xen + ^ + + --> $DIR/issue-69092.rs:8:14 + | +LL | unsafe { asm!(".ascii \"Xen\0\""); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From f61fb53af40daf55764f2f2644604fd22498cb13 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 13 Mar 2020 08:43:27 +0100 Subject: [PATCH 27/31] adjust enum naming --- src/librustc_codegen_ssa/mir/block.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index eef06c3579477..798d22ccd764c 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -453,34 +453,34 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // These are intrinsics that compile to panics so that we can get a message // which mentions the offending type, even from a const context. #[derive(Debug, PartialEq)] - enum PanicIntrinsic { - IfUninhabited, - IfZeroInvalid, - IfAnyInvalid, + enum AssertIntrinsic { + Inhabited, + ZeroValid, + UninitValid, }; let panic_intrinsic = intrinsic.and_then(|i| match i { // FIXME: Move to symbols instead of strings. - "assert_inhabited" => Some(PanicIntrinsic::IfUninhabited), - "assert_zero_valid" => Some(PanicIntrinsic::IfZeroInvalid), - "assert_uninit_valid" => Some(PanicIntrinsic::IfAnyInvalid), + "assert_inhabited" => Some(AssertIntrinsic::Inhabited), + "assert_zero_valid" => Some(AssertIntrinsic::ZeroValid), + "assert_uninit_valid" => Some(AssertIntrinsic::UninitValid), _ => None, }); if let Some(intrinsic) = panic_intrinsic { - use PanicIntrinsic::*; + use AssertIntrinsic::*; let ty = instance.unwrap().substs.type_at(0); let layout = bx.layout_of(ty); let do_panic = match intrinsic { - IfUninhabited => layout.abi.is_uninhabited(), + Inhabited => layout.abi.is_uninhabited(), // We unwrap as the error type is `!`. - IfZeroInvalid => !layout.might_permit_raw_init(bx, /*zero:*/ true).unwrap(), + ZeroValid => !layout.might_permit_raw_init(bx, /*zero:*/ true).unwrap(), // We unwrap as the error type is `!`. - IfAnyInvalid => !layout.might_permit_raw_init(bx, /*zero:*/ false).unwrap(), + UninitValid => !layout.might_permit_raw_init(bx, /*zero:*/ false).unwrap(), }; if do_panic { let msg_str = if layout.abi.is_uninhabited() { // Use this error even for the other intrinsics as it is more precise. format!("attempted to instantiate uninhabited type `{}`", ty) - } else if intrinsic == IfZeroInvalid { + } else if intrinsic == ZeroValid { format!("attempted to zero-initialize type `{}`, which is invalid", ty) } else { format!("attempted to leave type `{}` uninitialized, which is invalid", ty) From 13ea774513131b8102f35cb105cc17f39eb1b947 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 13 Mar 2020 08:52:04 +0100 Subject: [PATCH 28/31] bless tests --- src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr index d0e35615dab42..cede356a6b8a1 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -4,7 +4,7 @@ warning: any use of this value will cause an error LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ | | - | entering unreachable code + | transmuting to uninhabited type | inside call to `foo` at $DIR/validate_uninhabited_zsts.rs:14:26 ... LL | const FOO: [Empty; 3] = [foo(); 3]; From 08a7fa6dd8418ce6876bdd83fb3dd605950d56fa Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Fri, 13 Mar 2020 14:25:35 +0100 Subject: [PATCH 29/31] update stable-since version for const_int_conversion --- src/libcore/num/mod.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index caffa6c509aaa..853092dd85ee9 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2154,7 +2154,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes(); assert_eq!(bytes, ", $be_bytes, "); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { self.to_be().to_ne_bytes() @@ -2174,7 +2174,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes(); assert_eq!(bytes, ", $le_bytes, "); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { self.to_le().to_ne_bytes() @@ -2209,7 +2209,7 @@ assert_eq!( ); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] // SAFETY: const sound because integers are plain old datatypes so we can always // transmute them to arrays of bytes #[allow_internal_unstable(const_fn_union)] @@ -2251,7 +2251,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) @@ -2284,7 +2284,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) @@ -2327,7 +2327,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] // SAFETY: const sound because integers are plain old datatypes so we can always // transmute to them #[allow_internal_unstable(const_fn_union)] @@ -4115,7 +4115,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes(); assert_eq!(bytes, ", $be_bytes, "); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { self.to_be().to_ne_bytes() @@ -4135,7 +4135,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes(); assert_eq!(bytes, ", $le_bytes, "); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { self.to_le().to_ne_bytes() @@ -4170,7 +4170,7 @@ assert_eq!( ); ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] // SAFETY: const sound because integers are plain old datatypes so we can always // transmute them to arrays of bytes #[allow_internal_unstable(const_fn_union)] @@ -4212,7 +4212,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) @@ -4245,7 +4245,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] #[inline] pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) @@ -4288,7 +4288,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), } ```"), #[stable(feature = "int_to_from_bytes", since = "1.32.0")] - #[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] + #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")] // SAFETY: const sound because integers are plain old datatypes so we can always // transmute to them #[allow_internal_unstable(const_fn_union)] From a36bf9c1b87897beb5936bc67c01d121e8f366ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 13 Mar 2020 14:36:14 +0100 Subject: [PATCH 30/31] Clean up E0434 explanation --- src/librustc_error_codes/error_codes/E0434.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0434.md b/src/librustc_error_codes/error_codes/E0434.md index e093f0796da5e..8fd60412baf01 100644 --- a/src/librustc_error_codes/error_codes/E0434.md +++ b/src/librustc_error_codes/error_codes/E0434.md @@ -1,6 +1,4 @@ -This error indicates that a variable usage inside an inner function is invalid -because the variable comes from a dynamic environment. Inner functions do not -have access to their containing environment. +A variable used inside an inner function comes from a dynamic environment. Erroneous code example: @@ -14,8 +12,8 @@ fn foo() { } ``` -Functions do not capture local variables. To fix this error, you can replace the -function with a closure: +Inner functions do not have access to their containing environment. To fix this +error, you can replace the function with a closure: ``` fn foo() { @@ -26,7 +24,7 @@ fn foo() { } ``` -or replace the captured variable with a constant or a static item: +Or replace the captured variable with a constant or a static item: ``` fn foo() { From 87f8ee675e7fa07c34dfdf933300a934e040d2fa Mon Sep 17 00:00:00 2001 From: sjud Date: Wed, 4 Mar 2020 19:14:27 -0500 Subject: [PATCH 31/31] Add documentation for pub keyword --- src/libstd/keyword_docs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 3c69c1160d5b5..2702de15b858a 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -925,9 +925,15 @@ mod mut_keyword {} // /// Make an item visible to others. /// -/// The documentation for this keyword is [not yet complete]. Pull requests welcome! +/// The keyword `pub` makes any module, function, or data structure accessible from inside +/// of external modules. The `pub` keyword may also be used in a `use` declaration to re-export +/// an identifier from a namespace. /// -/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 +/// For more information on the `pub` keyword, please see the visibility section +/// of the [reference] and for some examples, see [Rust by Example]. +/// +/// [reference]:../reference/visibility-and-privacy.html?highlight=pub#visibility-and-privacy +/// [Rust by Example]:../rust-by-example/mod/visibility.html mod pub_keyword {} #[doc(keyword = "ref")]