From 96863095bc2c548c716d4434e25db44cd9f4aec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 13 Jan 2020 05:30:42 +0100 Subject: [PATCH 01/17] Ensure all iterations in Rayon iterators run in the presence of panics --- src/librustc/hir/map/hir_id_validator.rs | 4 +- src/librustc/ty/mod.rs | 7 +- src/librustc_codegen_ssa/base.rs | 18 ++-- src/librustc_data_structures/sync.rs | 105 +++++++++++++-------- src/librustc_hir/hir.rs | 8 +- src/librustc_interface/passes.rs | 8 +- src/librustc_lint/late.rs | 4 +- src/librustc_mir/monomorphize/collector.rs | 4 +- 8 files changed, 94 insertions(+), 64 deletions(-) diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 76e42b8af2874..f347a5373c08e 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -1,6 +1,6 @@ use crate::hir::map::Map; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator}; +use rustc_data_structures::sync::{par_for_each, Lock}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; use rustc_hir::intravisit; @@ -12,7 +12,7 @@ pub fn check_crate(hir_map: &Map<'_>) { let errors = Lock::new(Vec::new()); - par_iter(&hir_map.krate().modules).for_each(|(module_id, _)| { + par_for_each(&hir_map.krate().modules, |(module_id, _)| { let local_def_id = hir_map.local_def_id(*module_id); hir_map.visit_item_likes_in_module( local_def_id, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index f417b907a3811..e3be699d6c4e6 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -31,7 +31,7 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator}; +use rustc_data_structures::sync::{self, par_for_each, Lrc}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; @@ -2699,8 +2699,9 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn par_body_owners(self, f: F) { - par_iter(&self.hir().krate().body_ids) - .for_each(|&body_id| f(self.hir().body_owner_def_id(body_id))); + par_for_each(&self.hir().krate().body_ids, |&body_id| { + f(self.hir().body_owner_def_id(body_id)) + }); } pub fn provided_trait_methods(self, id: DefId) -> Vec { diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 1f43a4027c5ff..c9af4b7864fb2 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -41,7 +41,7 @@ use rustc_attr as attr; use rustc_codegen_utils::{check_for_rustc_errors_attr, symbol_names_test}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::profiling::print_time_passes_entry; -use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator}; +use rustc_data_structures::sync::{par_map, Lock}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_index::vec::Idx; @@ -631,15 +631,13 @@ pub fn codegen_crate( .collect(); // Compile the found CGUs in parallel. - par_iter(cgus) - .map(|(i, _)| { - let start_time = Instant::now(); - let module = backend.compile_codegen_unit(tcx, codegen_units[i].name()); - let mut time = total_codegen_time.lock(); - *time += start_time.elapsed(); - (i, module) - }) - .collect() + par_map(cgus, |(i, _)| { + let start_time = Instant::now(); + let module = backend.compile_codegen_unit(tcx, codegen_units[i].name()); + let mut time = total_codegen_time.lock(); + *time += start_time.elapsed(); + (i, module) + }) }) } else { FxHashMap::default() diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index fa98b4d72dda2..7f09e00738d9b 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -18,14 +18,33 @@ //! depending on the value of cfg!(parallel_compiler). use crate::owning_ref::{Erased, OwningRef}; +use std::any::Any; use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; +use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; pub use std::sync::atomic::Ordering; pub use std::sync::atomic::Ordering::SeqCst; +pub fn catch( + store: &Lock>>, + f: impl FnOnce() -> R, +) -> Option { + catch_unwind(AssertUnwindSafe(f)) + .map_err(|err| { + *store.lock() = Some(err); + }) + .ok() +} + +pub fn resume(store: Lock>>) { + if let Some(panic) = store.into_inner() { + resume_unwind(panic); + } +} + cfg_if! { if #[cfg(not(parallel_compiler))] { pub auto trait Send {} @@ -42,7 +61,6 @@ cfg_if! { } use std::ops::Add; - use std::panic::{resume_unwind, catch_unwind, AssertUnwindSafe}; /// This is a single threaded variant of AtomicCell provided by crossbeam. /// Unlike `Atomic` this is intended for all `Copy` types, @@ -181,46 +199,40 @@ cfg_if! { ($($blocks:tt),*) => { // We catch panics here ensuring that all the blocks execute. // This makes behavior consistent with the parallel compiler. - let mut panic = None; + let panic = ::rustc_data_structures::sync::Lock::new(None); $( - if let Err(p) = ::std::panic::catch_unwind( - ::std::panic::AssertUnwindSafe(|| $blocks) - ) { - if panic.is_none() { - panic = Some(p); - } - } + ::rustc_data_structures::sync::catch(&panic, || $blocks); )* - if let Some(panic) = panic { - ::std::panic::resume_unwind(panic); - } + ::rustc_data_structures::sync::resume(panic); } } - pub use std::iter::Iterator as ParallelIterator; + use std::iter::{Iterator, IntoIterator, FromIterator}; - pub fn par_iter(t: T) -> T::IntoIter { - t.into_iter() - } - - pub fn par_for_each_in( + pub fn par_for_each( t: T, - for_each: - impl Fn(<::IntoIter as Iterator>::Item) + Sync + Send + mut for_each: impl FnMut(<::IntoIter as Iterator>::Item), ) { // We catch panics here ensuring that all the loop iterations execute. // This makes behavior consistent with the parallel compiler. - let mut panic = None; + let panic = Lock::new(None); t.into_iter().for_each(|i| { - if let Err(p) = catch_unwind(AssertUnwindSafe(|| for_each(i))) { - if panic.is_none() { - panic = Some(p); - } - } + catch(&panic, || for_each(i)); }); - if let Some(panic) = panic { - resume_unwind(panic); - } + resume(panic); + } + + pub fn par_map>( + t: T, + mut map: impl FnMut(<::IntoIter as Iterator>::Item) -> R, + ) -> C { + // We catch panics here ensuring that all the loop iterations execute. + let panic = Lock::new(None); + let r = t.into_iter().filter_map(|i| { + catch(&panic, || map(i)) + }).collect(); + resume(panic); + r } pub type MetadataRef = OwningRef, [u8]>; @@ -388,20 +400,39 @@ cfg_if! { pub use rayon_core::WorkerLocal; - pub use rayon::iter::ParallelIterator; - use rayon::iter::IntoParallelIterator; - - pub fn par_iter(t: T) -> T::Iter { - t.into_par_iter() - } + use rayon::iter::{ParallelIterator, FromParallelIterator, IntoParallelIterator}; - pub fn par_for_each_in( + pub fn par_for_each( t: T, for_each: impl Fn( <::Iter as ParallelIterator>::Item ) + Sync + Send ) { - t.into_par_iter().for_each(for_each) + // We catch panics here ensuring that all the loop iterations execute. + let panic = Lock::new(None); + t.into_par_iter().for_each(|i| { + catch(&panic, || for_each(i)); + }); + resume(panic); + } + + pub fn par_map< + T: IntoParallelIterator, + R: Send, + C: FromParallelIterator + >( + t: T, + map: impl Fn( + <::Iter as ParallelIterator>::Item + ) -> R + Sync + Send + ) -> C { + // We catch panics here ensuring that all the loop iterations execute. + let panic = Lock::new(None); + let r = t.into_par_iter().filter_map(|i| { + catch(&panic, || map(i)) + }).collect(); + resume(panic); + r } pub type MetadataRef = OwningRef, [u8]>; diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 0db75454aee38..85106bcfbe955 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -9,7 +9,7 @@ crate use FunctionRetTy::*; crate use UnsafeSource::*; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; +use rustc_data_structures::sync::{par_for_each, Send, Sync}; use rustc_errors::FatalError; use rustc_macros::HashStable_Generic; use rustc_span::source_map::{SourceMap, Spanned}; @@ -678,17 +678,17 @@ impl Crate<'_> { { parallel!( { - par_for_each_in(&self.items, |(_, item)| { + par_for_each(&self.items, |(_, item)| { visitor.visit_item(item); }); }, { - par_for_each_in(&self.trait_items, |(_, trait_item)| { + par_for_each(&self.trait_items, |(_, trait_item)| { visitor.visit_trait_item(trait_item); }); }, { - par_for_each_in(&self.impl_items, |(_, impl_item)| { + par_for_each(&self.impl_items, |(_, impl_item)| { visitor.visit_impl_item(impl_item); }); } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 0be73e55e9c1d..9d0d7f8c2b64e 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -21,7 +21,7 @@ use rustc_builtin_macros; use rustc_codegen_ssa::back::link::emit_metadata; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::filename_for_metadata; -use rustc_data_structures::sync::{par_iter, Lrc, Once, ParallelIterator, WorkerLocal}; +use rustc_data_structures::sync::{par_for_each, Lrc, Once, WorkerLocal}; use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel}; use rustc_errors::PResult; use rustc_expand::base::ExtCtxt; @@ -783,7 +783,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx)); }, { - par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { let local_def_id = tcx.hir().local_def_id(module); tcx.ensure().check_mod_loops(local_def_id); tcx.ensure().check_mod_attrs(local_def_id); @@ -808,7 +808,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { }, { sess.time("liveness_and_intrinsic_checking", || { - par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { // this must run before MIR dump, because // "not all control paths return a value" is reported here. // @@ -876,7 +876,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { }, { sess.time("privacy_checking_modules", || { - par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { tcx.ensure().check_mod_privacy(tcx.hir().local_def_id(module)); }); }); diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index 30a3788377508..b1467da1bf5e5 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -17,7 +17,7 @@ use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore}; use rustc::hir::map::Map; use rustc::ty::{self, TyCtxt}; -use rustc_data_structures::sync::{join, par_iter, ParallelIterator}; +use rustc_data_structures::sync::{join, par_for_each}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::intravisit as hir_visit; @@ -481,7 +481,7 @@ pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( || { tcx.sess.time("module_lints", || { // Run per-module lints - par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { tcx.ensure().lint_mod(tcx.hir().local_def_id(module)); }); }); diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index dd2071a6c596a..e806b9c58a309 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -189,7 +189,7 @@ use rustc::ty::print::obsolete::DefPathBasedNames; use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator}; +use rustc_data_structures::sync::{par_for_each, MTLock, MTRef}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::itemlikevisit::ItemLikeVisitor; @@ -291,7 +291,7 @@ pub fn collect_crate_mono_items( let inlining_map: MTRef<'_, _> = &mut inlining_map; tcx.sess.time("monomorphization_collector_graph_walk", || { - par_iter(roots).for_each(|root| { + par_for_each(roots, |root| { let mut recursion_depths = DefIdMap::default(); collect_items_rec(tcx, root, visited, &mut recursion_depths, inlining_map); }); From f948fd063ad919720191dc60a68486a0ae63071d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 13 Jan 2020 09:57:52 +0100 Subject: [PATCH 02/17] Update tests --- src/test/ui/privacy/privacy2.stderr | 8 +++++++- src/test/ui/privacy/privacy3.stderr | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/ui/privacy/privacy2.stderr b/src/test/ui/privacy/privacy2.stderr index 719dc27ccf4d6..9fdf4d5099430 100644 --- a/src/test/ui/privacy/privacy2.stderr +++ b/src/test/ui/privacy/privacy2.stderr @@ -18,7 +18,13 @@ LL | use foo; error: requires `sized` lang_item -error: aborting due to 3 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/privacy/privacy3.stderr b/src/test/ui/privacy/privacy3.stderr index 22c1e48b07d94..42ce456d962a1 100644 --- a/src/test/ui/privacy/privacy3.stderr +++ b/src/test/ui/privacy/privacy3.stderr @@ -6,6 +6,12 @@ LL | use bar::gpriv; error: requires `sized` lang_item -error: aborting due to 2 previous errors +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: requires `sized` lang_item + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. From 45d4695220a5a42ad502b546f6881ef610da906a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 16 Jan 2020 10:58:52 +0100 Subject: [PATCH 03/17] Use $crate --- src/librustc_data_structures/sync.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index 7f09e00738d9b..d51fd64e89113 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -199,11 +199,11 @@ cfg_if! { ($($blocks:tt),*) => { // We catch panics here ensuring that all the blocks execute. // This makes behavior consistent with the parallel compiler. - let panic = ::rustc_data_structures::sync::Lock::new(None); + let panic = $crate::sync::Lock::new(None); $( - ::rustc_data_structures::sync::catch(&panic, || $blocks); + $crate::sync::catch(&panic, || $blocks); )* - ::rustc_data_structures::sync::resume(panic); + $crate::sync::resume(panic); } } @@ -383,7 +383,7 @@ cfg_if! { parallel!(impl $fblock [$block, $($c,)*] [$($rest),*]) }; (impl $fblock:tt [$($blocks:tt,)*] []) => { - ::rustc_data_structures::sync::scope(|s| { + $crate::sync::scope(|s| { $( s.spawn(|_| $blocks); )* @@ -445,7 +445,7 @@ cfg_if! { macro_rules! rustc_erase_owner { ($v:expr) => {{ let v = $v; - ::rustc_data_structures::sync::assert_send_val(&v); + $crate::sync::assert_send_val(&v); v.erase_send_sync_owner() }} } From 27c98b82b5ae61a5dbefbd2ad9637da4657167ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 2 Jan 2020 15:35:38 +0100 Subject: [PATCH 04/17] Parallelize type collecting and item-types checking --- src/librustc/hir/map/mod.rs | 38 ++++++++++++++++++++++++++++- src/librustc_hir/intravisit.rs | 7 ++++++ src/librustc_typeck/check/mod.rs | 12 ++++----- src/librustc_typeck/collect.rs | 7 +++--- src/librustc_typeck/lib.rs | 13 +++++++--- src/test/ui/span/issue-35987.rs | 3 ++- src/test/ui/span/issue-35987.stderr | 11 +++++++-- 7 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 6d7f53133a666..9edaf68fc77c4 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -8,10 +8,12 @@ use crate::middle::cstore::CrateStoreDyn; use crate::ty::query::Providers; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::svh::Svh; + +use rustc_data_structures::sync::{self, par_for_each}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; use rustc_hir::intravisit; -use rustc_hir::itemlikevisit::ItemLikeVisitor; +use rustc_hir::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; use rustc_hir::print::Nested; use rustc_hir::*; use rustc_index::vec::IndexVec; @@ -582,6 +584,40 @@ impl<'hir> Map<'hir> { } } + /// A parallel version of `visit_item_likes_in_module`. + pub fn par_visit_item_likes_in_module(&self, module: DefId, visitor: &V) + where + V: ParItemLikeVisitor<'hir> + sync::Sync, + { + let hir_id = self.as_local_hir_id(module).unwrap(); + + // Read the module so we'll be re-executed if new items + // appear immediately under in the module. If some new item appears + // in some nested item in the module, we'll be re-executed due to reads + // in the expect_* calls the loops below + self.read(hir_id); + + let module = &self.forest.krate.modules[&hir_id]; + + parallel!( + { + par_for_each(&module.items, |id| { + visitor.visit_item(self.expect_item(*id)); + }); + }, + { + par_for_each(&module.trait_items, |id| { + visitor.visit_trait_item(self.expect_trait_item(id.hir_id)); + }); + }, + { + par_for_each(&module.impl_items, |id| { + visitor.visit_impl_item(self.expect_impl_item(id.hir_id)); + }); + } + ); + } + /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found. pub fn get(&self, id: HirId) -> Node<'hir> { // read recorded by `find` diff --git a/src/librustc_hir/intravisit.rs b/src/librustc_hir/intravisit.rs index 539a0eee0e312..83c4232d35a6c 100644 --- a/src/librustc_hir/intravisit.rs +++ b/src/librustc_hir/intravisit.rs @@ -70,6 +70,13 @@ pub trait IntoVisitor<'hir> { fn into_visitor(&self) -> Self::Visitor; } +impl<'hir, T: Clone + Visitor<'hir>> IntoVisitor<'hir> for T { + type Visitor = Self; + fn into_visitor(&self) -> Self::Visitor { + self.clone() + } +} + pub struct ParDeepVisitor(pub V); impl<'hir, V> ParItemLikeVisitor<'hir> for ParDeepVisitor diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0a917a1853eb5..5e1fc71e3fe0c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -123,7 +123,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::itemlikevisit::ItemLikeVisitor; +use rustc_hir::itemlikevisit::ParItemLikeVisitor; use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath}; use rustc_index::vec::Idx; use rustc_span::hygiene::DesugaringKind; @@ -729,12 +729,12 @@ struct CheckItemTypesVisitor<'tcx> { tcx: TyCtxt<'tcx>, } -impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { - fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) { +impl ParItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { + fn visit_item(&self, i: &'tcx hir::Item<'tcx>) { check_item_type(self.tcx, i); } - fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem<'tcx>) {} - fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem<'tcx>) {} + fn visit_trait_item(&self, _: &'tcx hir::TraitItem<'tcx>) {} + fn visit_impl_item(&self, _: &'tcx hir::ImplItem<'tcx>) {} } pub fn check_wf_new(tcx: TyCtxt<'_>) { @@ -743,7 +743,7 @@ pub fn check_wf_new(tcx: TyCtxt<'_>) { } fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: DefId) { - tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx }); + tcx.hir().par_visit_item_likes_in_module(module_def_id, &CheckItemTypesVisitor { tcx }); } fn typeck_item_bodies(tcx: TyCtxt<'_>, crate_num: CrateNum) { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 4d812d2621c61..980b12adf9515 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -40,7 +40,7 @@ use rustc_errors::{struct_span_err, Applicability, StashKey}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc_hir::intravisit::{self, NestedVisitorMap, ParDeepVisitor, Visitor}; use rustc_hir::{GenericParamKind, Node, Unsafety}; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; @@ -54,9 +54,9 @@ struct OnlySelfBounds(bool); // Main entry point fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: DefId) { - tcx.hir().visit_item_likes_in_module( + tcx.hir().par_visit_item_likes_in_module( module_def_id, - &mut CollectItemTypesVisitor { tcx }.as_deep_visitor(), + &ParDeepVisitor(CollectItemTypesVisitor { tcx }), ); } @@ -117,6 +117,7 @@ impl<'v> Visitor<'v> for PlaceholderHirTyCollector { } } +#[derive(Clone)] struct CollectItemTypesVisitor<'tcx> { tcx: TyCtxt<'tcx>, } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 3d27f9191dd39..098ab9ee281f8 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -102,6 +102,7 @@ use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util; use rustc::util::common::ErrorReported; +use rustc_data_structures::sync::par_for_each; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; @@ -308,9 +309,13 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> { // FIXME(matthewjasper) We shouldn't need to do this. tcx.sess.track_errors(|| { tcx.sess.time("type_collecting", || { - for &module in tcx.hir().krate().modules.keys() { + // Run dependencies of type collecting before entering the loop + tcx.inferred_outlives_crate(LOCAL_CRATE); + + let _prof_timer = tcx.sess.timer("type_collecting_loop"); + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { tcx.ensure().collect_mod_item_types(tcx.hir().local_def_id(module)); - } + }); }); })?; @@ -339,9 +344,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> { })?; tcx.sess.time("item_types_checking", || { - for &module in tcx.hir().krate().modules.keys() { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module)); - } + }); }); tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(LOCAL_CRATE)); diff --git a/src/test/ui/span/issue-35987.rs b/src/test/ui/span/issue-35987.rs index 3a6e6ffe24910..7fa1a33ac84c1 100644 --- a/src/test/ui/span/issue-35987.rs +++ b/src/test/ui/span/issue-35987.rs @@ -3,10 +3,11 @@ struct Foo(T); use std::ops::Add; impl Add for Foo { -//~^ ERROR expected trait, found type parameter + //~^ ERROR expected trait, found type parameter type Output = usize; fn add(self, rhs: Self) -> Self::Output { + //~^ ERROR ambiguous associated type unimplemented!(); } } diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index 3245d8655e87d..2ab2400fc7c00 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -9,6 +9,13 @@ help: possible better candidate is found in another module, you can import it in LL | use std::ops::Add; | -error: aborting due to previous error +error[E0223]: ambiguous associated type + --> $DIR/issue-35987.rs:9:32 + | +LL | fn add(self, rhs: Self) -> Self::Output { + | ^^^^^^^^^^^^ help: use fully-qualified syntax: ` as Trait>::Output` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0404`. +Some errors have detailed explanations: E0223, E0404. +For more information about an error, try `rustc --explain E0223`. From 011e97212c63bb4b6c0fbef5bcba67a9b4c2d6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 2 Jan 2020 21:46:11 +0100 Subject: [PATCH 05/17] Tweak misc checking 1 --- src/librustc_interface/passes.rs | 13 ++++++++++++- .../min_const_fn/allow_const_fn_ptr_feature_gate.rs | 1 + .../allow_const_fn_ptr_feature_gate.stderr | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 9d0d7f8c2b64e..cd6e4bf4815a9 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -783,13 +783,24 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx)); }, { + tcx.get_lang_items(LOCAL_CRATE); + + let _timer = tcx.sess.timer("misc_module_passes"); par_for_each(&tcx.hir().krate().modules, |(&module, _)| { let local_def_id = tcx.hir().local_def_id(module); tcx.ensure().check_mod_loops(local_def_id); tcx.ensure().check_mod_attrs(local_def_id); - tcx.ensure().check_mod_unstable_api_usage(local_def_id); tcx.ensure().check_mod_const_bodies(local_def_id); }); + }, + { + tcx.stability_index(LOCAL_CRATE); + + let _timer = tcx.sess.timer("check_unstable_api_usage"); + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { + let local_def_id = tcx.hir().local_def_id(module); + tcx.ensure().check_mod_unstable_api_usage(local_def_id); + }); } ); }); diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs index 0f9d37292958a..86c3b8477ade4 100644 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs +++ b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.rs @@ -7,5 +7,6 @@ const fn error(_: fn()) {} #[rustc_allow_const_fn_ptr] //~^ ERROR internal implementation detail const fn compiles(_: fn()) {} +//~^ ERROR rustc_promotable and rustc_allow_const_fn_ptr attributes must be paired fn main() {} diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr index 70a10d9a0c12a..4f93102f49fc6 100644 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr +++ b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_feature_gate.stderr @@ -7,6 +7,12 @@ LL | #[rustc_allow_const_fn_ptr] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error: aborting due to previous error +error[E0717]: rustc_promotable and rustc_allow_const_fn_ptr attributes must be paired with either a rustc_const_unstable or a rustc_const_stable attribute + --> $DIR/allow_const_fn_ptr_feature_gate.rs:9:1 + | +LL | const fn compiles(_: fn()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. From 93f7b249434d00f983f691b384fff9b518fcd82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 01:10:04 +0100 Subject: [PATCH 06/17] Run item-types checking and item-bodies checking in parallel --- src/librustc_typeck/lib.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 098ab9ee281f8..c2eee1fd29229 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -102,7 +102,7 @@ use rustc::ty::subst::SubstsRef; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util; use rustc::util::common::ErrorReported; -use rustc_data_structures::sync::par_for_each; +use rustc_data_structures::sync::{join, par_for_each}; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; @@ -343,14 +343,19 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> { tcx.sess.time("wf_checking", || check::check_wf_new(tcx)); })?; - tcx.sess.time("item_types_checking", || { - par_for_each(&tcx.hir().krate().modules, |(&module, _)| { - tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module)); - }); + tcx.sess.time("item_types_and_item_bodies_checking", || { + join( + || { + tcx.sess.time("item_types_checking", || { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { + tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module)); + }); + }) + }, + || tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(LOCAL_CRATE)), + ) }); - tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(LOCAL_CRATE)); - check_unused::check_crate(tcx); check_for_entry_fn(tcx); From e2ec0ebf9b9e92920f0bd3aea977b2567f9ce452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 01:51:30 +0100 Subject: [PATCH 07/17] Handle panics with `join` --- src/librustc_data_structures/sync.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index d51fd64e89113..3b0427e1d2869 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -175,7 +175,11 @@ cfg_if! { where A: FnOnce() -> RA, B: FnOnce() -> RB { - (oper_a(), oper_b()) + let panic = Lock::new(None); + let a = catch(&panic, oper_a); + let b = catch(&panic, oper_b); + resume(panic); + (a.unwrap(), b.unwrap()) } pub struct SerialScope; @@ -204,8 +208,8 @@ cfg_if! { $crate::sync::catch(&panic, || $blocks); )* $crate::sync::resume(panic); + } } - } use std::iter::{Iterator, IntoIterator, FromIterator}; @@ -220,7 +224,7 @@ cfg_if! { catch(&panic, || for_each(i)); }); resume(panic); - } + } pub fn par_map>( t: T, From ad6af116b3fdf353f910cc01aece1cb226bea346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 01:52:02 +0100 Subject: [PATCH 08/17] Make typeck_item_bodies eval_always --- src/librustc/query/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 37d5e23535b81..18addcf9ab54e 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -393,6 +393,7 @@ rustc_queries! { TypeChecking { query typeck_item_bodies(_: CrateNum) -> () { + eval_always desc { "type-checking all item bodies" } } From 2e1da951a3f4335e6967ef3430e1ca858585aa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 01:55:13 +0100 Subject: [PATCH 09/17] Make coherence checking parallel --- src/librustc_typeck/coherence/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 5583e3418b2a8..a09cca8a2decb 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -8,6 +8,7 @@ use rustc::traits; use rustc::ty::query::Providers; use rustc::ty::{self, TyCtxt, TypeFoldable}; +use rustc_data_structures::sync::par_for_each; use rustc_errors::struct_span_err; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::HirId; @@ -140,9 +141,9 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) { } pub fn check_coherence(tcx: TyCtxt<'_>) { - for &trait_def_id in tcx.hir().krate().trait_impls.keys() { + par_for_each(&tcx.hir().krate().trait_impls, |(&trait_def_id, _)| { tcx.ensure().coherent_trait(trait_def_id); - } + }); tcx.sess.time("unsafety_checking", || unsafety::check(tcx)); tcx.sess.time("orphan_checking", || orphan::check(tcx)); From 185a37e8826e87dc81f10922597813635701a7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 03:46:38 +0100 Subject: [PATCH 10/17] Move privacy_access_levels out of misc checking 3 and run it in parallel with MIR borrow checking --- src/librustc_interface/passes.rs | 49 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index cd6e4bf4815a9..f7406e3b3c3b3 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -834,9 +834,16 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { ); }); - sess.time("MIR_borrow_checking", || { - tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id)); - }); + parallel!( + { + tcx.ensure().privacy_access_levels(LOCAL_CRATE); + }, + { + sess.time("MIR_borrow_checking", || { + tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id)); + }); + } + ); sess.time("dumping_chalk_like_clauses", || { rustc_traits::lowering::dump_program_clauses(tcx); @@ -862,28 +869,20 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("misc_checking_3", || { parallel!( { - tcx.ensure().privacy_access_levels(LOCAL_CRATE); - - parallel!( - { - tcx.ensure().check_private_in_public(LOCAL_CRATE); - }, - { - sess.time("death_checking", || rustc_passes::dead::check_crate(tcx)); - }, - { - sess.time("unused_lib_feature_checking", || { - rustc_passes::stability::check_unused_or_stable_features(tcx) - }); - }, - { - sess.time("lint_checking", || { - rustc_lint::check_crate(tcx, || { - rustc_lint::BuiltinCombinedLateLintPass::new() - }); - }); - } - ); + tcx.ensure().check_private_in_public(LOCAL_CRATE); + }, + { + sess.time("death_checking", || rustc_passes::dead::check_crate(tcx)); + }, + { + sess.time("unused_lib_feature_checking", || { + rustc_passes::stability::check_unused_or_stable_features(tcx) + }); + }, + { + sess.time("lint_checking", || { + rustc_lint::check_crate(tcx, || rustc_lint::BuiltinCombinedLateLintPass::new()); + }); }, { sess.time("privacy_checking_modules", || { From dfaed3427f07830ef4f0242dd1ea037520c9cc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 04:04:52 +0100 Subject: [PATCH 11/17] Move some other passes into a parallel block --- src/librustc_interface/passes.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index f7406e3b3c3b3..df8695c7084b0 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -842,21 +842,24 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("MIR_borrow_checking", || { tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id)); }); + }, + { + sess.time("dumping_chalk_like_clauses", || { + rustc_traits::lowering::dump_program_clauses(tcx); + }); + }, + { + sess.time("MIR_effect_checking", || { + for def_id in tcx.body_owners() { + mir::transform::check_unsafety::check_unsafety(tcx, def_id) + } + }); + }, + { + sess.time("layout_testing", || layout_test::test_layout(tcx)); } ); - sess.time("dumping_chalk_like_clauses", || { - rustc_traits::lowering::dump_program_clauses(tcx); - }); - - sess.time("MIR_effect_checking", || { - for def_id in tcx.body_owners() { - mir::transform::check_unsafety::check_unsafety(tcx, def_id) - } - }); - - sess.time("layout_testing", || layout_test::test_layout(tcx)); - // Avoid overwhelming user with errors if borrow checking failed. // I'm not sure how helpful this is, to be honest, but it avoids a // lot of annoying errors in the compile-fail tests (basically, From f07d1b1d49d41d0bde4a8beeb2e3e5b6ca5ed8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 22:34:58 +0100 Subject: [PATCH 12/17] Make liveness checking more parallel --- src/librustc_interface/passes.rs | 21 ++++++---- src/librustc_passes/liveness.rs | 26 +++++++++++-- .../ui/lint/lint-uppercase-variables.stderr | 38 +++++++++---------- 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index df8695c7084b0..d4a06e135edf5 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -810,6 +810,19 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("misc_checking_2", || { parallel!( + { + sess.time("liveness_checking", || { + par_for_each(&tcx.hir().krate().modules, |(&module, _)| { + // this must run before MIR dump, because + // "not all control paths return a value" is reported here. + // + // maybe move the check to a MIR pass? + let local_def_id = tcx.hir().local_def_id(module); + + tcx.ensure().check_mod_liveness(local_def_id); + }); + }); + }, { sess.time("match_checking", || { tcx.par_body_owners(|def_id| { @@ -818,15 +831,9 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { }); }, { - sess.time("liveness_and_intrinsic_checking", || { + sess.time("intrinsic_checking", || { par_for_each(&tcx.hir().krate().modules, |(&module, _)| { - // this must run before MIR dump, because - // "not all control paths return a value" is reported here. - // - // maybe move the check to a MIR pass? let local_def_id = tcx.hir().local_def_id(module); - - tcx.ensure().check_mod_liveness(local_def_id); tcx.ensure().check_mod_intrinsics(local_def_id); }); }); diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 7718139f6e924..da344712ab2f4 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -106,6 +106,7 @@ use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, FnKind, NestedVisitorMap, Visitor}; +use rustc_hir::itemlikevisit::ParItemLikeVisitor; use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet, Node}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -182,11 +183,28 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } +struct LivenessVisitor<'tcx> { + tcx: TyCtxt<'tcx>, + module_def_id: DefId, +} + +impl<'tcx> ParItemLikeVisitor<'tcx> for LivenessVisitor<'tcx> { + fn visit_item(&self, item: &'tcx hir::Item<'tcx>) { + IrMaps::new(self.tcx, self.module_def_id).visit_item(item); + } + + fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) { + IrMaps::new(self.tcx, self.module_def_id).visit_trait_item(trait_item); + } + + fn visit_impl_item(&self, impl_item: &'tcx hir::ImplItem<'tcx>) { + IrMaps::new(self.tcx, self.module_def_id).visit_impl_item(impl_item); + } +} + fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: DefId) { - tcx.hir().visit_item_likes_in_module( - module_def_id, - &mut IrMaps::new(tcx, module_def_id).as_deep_visitor(), - ); + tcx.hir() + .par_visit_item_likes_in_module(module_def_id, &LivenessVisitor { tcx, module_def_id }); } pub fn provide(providers: &mut Providers<'_>) { diff --git a/src/test/ui/lint/lint-uppercase-variables.stderr b/src/test/ui/lint/lint-uppercase-variables.stderr index 7c2497758d955..d172a9735dd48 100644 --- a/src/test/ui/lint/lint-uppercase-variables.stderr +++ b/src/test/ui/lint/lint-uppercase-variables.stderr @@ -1,47 +1,47 @@ -warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` +warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:22:9 | LL | Foo => {} - | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + | ^^^ help: consider prefixing with an underscore: `_Foo` | - = note: `#[warn(bindings_with_variant_name)]` on by default +note: the lint level is defined here + --> $DIR/lint-uppercase-variables.rs:1:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` -warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` +warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:28:9 | LL | let Foo = foo::Foo::Foo; - | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + | ^^^ help: consider prefixing with an underscore: `_Foo` -warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` +warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:33:17 | LL | fn in_param(Foo: foo::Foo) {} - | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + | ^^^ help: consider prefixing with an underscore: `_Foo` -warning: unused variable: `Foo` +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` --> $DIR/lint-uppercase-variables.rs:22:9 | LL | Foo => {} - | ^^^ help: consider prefixing with an underscore: `_Foo` - | -note: the lint level is defined here - --> $DIR/lint-uppercase-variables.rs:1:9 + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` | -LL | #![warn(unused)] - | ^^^^^^ - = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` + = note: `#[warn(bindings_with_variant_name)]` on by default -warning: unused variable: `Foo` +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` --> $DIR/lint-uppercase-variables.rs:28:9 | LL | let Foo = foo::Foo::Foo; - | ^^^ help: consider prefixing with an underscore: `_Foo` + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` -warning: unused variable: `Foo` +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` --> $DIR/lint-uppercase-variables.rs:33:17 | LL | fn in_param(Foo: foo::Foo) {} - | ^^^ help: consider prefixing with an underscore: `_Foo` + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` error: structure field `X` should have a snake case name --> $DIR/lint-uppercase-variables.rs:10:5 From 3241d765fb700603d9616d4ee867327466de8a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 3 Jan 2020 23:30:03 +0100 Subject: [PATCH 13/17] Prefetch upstream_monomorphizations --- src/librustc_mir/monomorphize/collector.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index e806b9c58a309..b25a627d8479c 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -189,7 +189,7 @@ use rustc::ty::print::obsolete::DefPathBasedNames; use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::{self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_data_structures::sync::{par_for_each, MTLock, MTRef}; +use rustc_data_structures::sync::{join, par_for_each, MTLock, MTRef}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::itemlikevisit::ItemLikeVisitor; @@ -278,8 +278,16 @@ pub fn collect_crate_mono_items( ) -> (FxHashSet>, InliningMap<'_>) { let _prof_timer = tcx.prof.generic_activity("monomorphization_collector"); - let roots = - tcx.sess.time("monomorphization_collector_root_collections", || collect_roots(tcx, mode)); + let (roots, _) = join( + || { + tcx.sess + .time("monomorphization_collector_root_collections", || collect_roots(tcx, mode)) + }, + || { + // Prefetch upstream_monomorphizations + tcx.upstream_monomorphizations(LOCAL_CRATE); + }, + ); debug!("building mono item graph, beginning at roots"); From bfa09edfe537235763d96d68d52495cd6e31443f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 4 Jan 2020 00:16:37 +0100 Subject: [PATCH 14/17] Add a new misc checking 3 block --- src/librustc_interface/passes.rs | 54 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index d4a06e135edf5..31d07e67dbcc6 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -841,31 +841,33 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { ); }); - parallel!( - { - tcx.ensure().privacy_access_levels(LOCAL_CRATE); - }, - { - sess.time("MIR_borrow_checking", || { - tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id)); - }); - }, - { - sess.time("dumping_chalk_like_clauses", || { - rustc_traits::lowering::dump_program_clauses(tcx); - }); - }, - { - sess.time("MIR_effect_checking", || { - for def_id in tcx.body_owners() { - mir::transform::check_unsafety::check_unsafety(tcx, def_id) - } - }); - }, - { - sess.time("layout_testing", || layout_test::test_layout(tcx)); - } - ); + sess.time("misc_checking_3", || { + parallel!( + { + tcx.ensure().privacy_access_levels(LOCAL_CRATE); + }, + { + sess.time("MIR_borrow_checking", || { + tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id)); + }); + }, + { + sess.time("dumping_chalk_like_clauses", || { + rustc_traits::lowering::dump_program_clauses(tcx); + }); + }, + { + sess.time("MIR_effect_checking", || { + for def_id in tcx.body_owners() { + mir::transform::check_unsafety::check_unsafety(tcx, def_id) + } + }); + }, + { + sess.time("layout_testing", || layout_test::test_layout(tcx)); + } + ); + }); // Avoid overwhelming user with errors if borrow checking failed. // I'm not sure how helpful this is, to be honest, but it avoids a @@ -876,7 +878,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { return Err(ErrorReported); } - sess.time("misc_checking_3", || { + sess.time("misc_checking_4", || { parallel!( { tcx.ensure().check_private_in_public(LOCAL_CRATE); From 4332e35ef7f16de350e740a9ab0153c329649a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 4 Jan 2020 02:52:21 +0100 Subject: [PATCH 15/17] Prefetch lint_levels and visible_parent_map --- src/librustc_interface/passes.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 31d07e67dbcc6..b6913c5d23442 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -793,6 +793,14 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { tcx.ensure().check_mod_const_bodies(local_def_id); }); }, + { + // Prefetch in case lints are emitted. + tcx.lint_levels(LOCAL_CRATE); + }, + { + // Prefetch in case something needs printing. + tcx.visible_parent_map(LOCAL_CRATE); + }, { tcx.stability_index(LOCAL_CRATE); From 3f044338f2db8af7a8c66dabc7b956621f03ac57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 11 Jan 2020 07:28:20 +0100 Subject: [PATCH 16/17] Fix duplicate test fallout --- .../ui-fulldeps/lint-plugin-forbid-attrs.rs | 1 + .../lint-plugin-forbid-attrs.stderr | 11 +- .../ui-fulldeps/lint-plugin-forbid-cmdline.rs | 1 + .../lint-plugin-forbid-cmdline.stderr | 10 +- src/test/ui-fulldeps/lint-tool-test.rs | 3 + src/test/ui-fulldeps/lint-tool-test.stderr | 40 ++++-- .../deduplicate-diagnostics.duplicate.stderr | 8 +- src/test/ui/deduplicate-diagnostics.rs | 1 + src/test/ui/error-codes/E0452.rs | 2 + src/test/ui/error-codes/E0452.stderr | 14 ++- src/test/ui/error-codes/E0453.rs | 1 + src/test/ui/error-codes/E0453.stderr | 11 +- src/test/ui/error-codes/E0602.stderr | 6 +- .../feature-gate-lint-reasons.rs | 1 + .../feature-gate-lint-reasons.stderr | 11 +- src/test/ui/lint/lint-forbid-attr.rs | 1 + src/test/ui/lint/lint-forbid-attr.stderr | 11 +- src/test/ui/lint/lint-forbid-cmdline.rs | 1 + src/test/ui/lint/lint-forbid-cmdline.stderr | 10 +- src/test/ui/lint/lint-malformed.rs | 2 + src/test/ui/lint/lint-malformed.stderr | 14 ++- .../ui/lint/lint-unknown-lint-cmdline.stderr | 11 +- src/test/ui/lint/outer-forbid.rs | 3 + src/test/ui/lint/outer-forbid.stderr | 41 ++++-- src/test/ui/lint/reasons-erroneous.rs | 20 +++ src/test/ui/lint/reasons-erroneous.stderr | 118 +++++++++++++----- src/test/ui/lint/reasons-forbidden.rs | 4 + src/test/ui/lint/reasons-forbidden.stderr | 19 ++- src/test/ui/tool_lints.rs | 1 + src/test/ui/tool_lints.stderr | 8 +- src/test/ui/unknown-lint-tool-name.rs | 2 + src/test/ui/unknown-lint-tool-name.stderr | 20 ++- 32 files changed, 340 insertions(+), 67 deletions(-) diff --git a/src/test/ui-fulldeps/lint-plugin-forbid-attrs.rs b/src/test/ui-fulldeps/lint-plugin-forbid-attrs.rs index 35ddab95831db..353fe7205d4fe 100644 --- a/src/test/ui-fulldeps/lint-plugin-forbid-attrs.rs +++ b/src/test/ui-fulldeps/lint-plugin-forbid-attrs.rs @@ -12,6 +12,7 @@ fn lintme() { } //~ ERROR item is named 'lintme' //~^ ERROR allow(test_lint) overruled by outer forbid(test_lint) //~| ERROR allow(test_lint) overruled by outer forbid(test_lint) //~| ERROR allow(test_lint) overruled by outer forbid(test_lint) +//~| ERROR allow(test_lint) overruled by outer forbid(test_lint) pub fn main() { lintme(); } diff --git a/src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr b/src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr index df92bc70a7971..4c37c44c1d074 100644 --- a/src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr +++ b/src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr @@ -45,6 +45,15 @@ LL | #![forbid(test_lint)] LL | #[allow(test_lint)] | ^^^^^^^^^ overruled by previous forbid -error: aborting due to 4 previous errors +error[E0453]: allow(test_lint) overruled by outer forbid(test_lint) + --> $DIR/lint-plugin-forbid-attrs.rs:11:9 + | +LL | #![forbid(test_lint)] + | --------- `forbid` level set here +... +LL | #[allow(test_lint)] + | ^^^^^^^^^ overruled by previous forbid + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.rs b/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.rs index 695d3aef16905..daa7eedf0f23f 100644 --- a/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.rs +++ b/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.rs @@ -10,6 +10,7 @@ fn lintme() { } //~ ERROR item is named 'lintme' #[allow(test_lint)] //~ ERROR allow(test_lint) overruled by outer forbid(test_lint) //~| ERROR allow(test_lint) overruled by outer forbid(test_lint) //~| ERROR allow(test_lint) overruled by outer forbid(test_lint) + //~| ERROR allow(test_lint) overruled by outer forbid(test_lint) pub fn main() { lintme(); } diff --git a/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr b/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr index 0302ec84d5620..7a8dbd5976b30 100644 --- a/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr +++ b/src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr @@ -38,6 +38,14 @@ LL | #[allow(test_lint)] | = note: `forbid` lint level was set on command line -error: aborting due to 4 previous errors +error[E0453]: allow(test_lint) overruled by outer forbid(test_lint) + --> $DIR/lint-plugin-forbid-cmdline.rs:10:9 + | +LL | #[allow(test_lint)] + | ^^^^^^^^^ overruled by previous forbid + | + = note: `forbid` lint level was set on command line + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui-fulldeps/lint-tool-test.rs b/src/test/ui-fulldeps/lint-tool-test.rs index f92bcd213b844..0d04eb6fcfa96 100644 --- a/src/test/ui-fulldeps/lint-tool-test.rs +++ b/src/test/ui-fulldeps/lint-tool-test.rs @@ -10,10 +10,12 @@ //~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future //~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future //~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future +//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future #![deny(clippy_group)] //~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future //~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future //~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future +//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future fn lintme() { } //~ ERROR item is named 'lintme' @@ -30,6 +32,7 @@ pub fn main() { //~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future //~| WARNING lint name `test_group` is deprecated and may not have an effect in the future //~| WARNING lint name `test_group` is deprecated and may not have an effect in the future +//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` fn hello() { fn lintmetoo() { } diff --git a/src/test/ui-fulldeps/lint-tool-test.stderr b/src/test/ui-fulldeps/lint-tool-test.stderr index 31d25652d5d39..8022b71852304 100644 --- a/src/test/ui-fulldeps/lint-tool-test.stderr +++ b/src/test/ui-fulldeps/lint-tool-test.stderr @@ -7,19 +7,19 @@ LL | #![cfg_attr(foo, warn(test_lint))] = note: `#[warn(renamed_and_removed_lints)]` on by default warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:13:9 + --> $DIR/lint-tool-test.rs:14:9 | LL | #![deny(clippy_group)] | ^^^^^^^^^^^^ help: change it to: `clippy::group` warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:29:9 + --> $DIR/lint-tool-test.rs:31:9 | LL | #[allow(test_group)] | ^^^^^^^^^^ help: change it to: `clippy::test_group` warning: unknown lint: `this_lint_does_not_exist` - --> $DIR/lint-tool-test.rs:33:8 + --> $DIR/lint-tool-test.rs:36:8 | LL | #[deny(this_lint_does_not_exist)] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,13 +33,13 @@ LL | #![cfg_attr(foo, warn(test_lint))] | ^^^^^^^^^ help: change it to: `clippy::test_lint` warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:13:9 + --> $DIR/lint-tool-test.rs:14:9 | LL | #![deny(clippy_group)] | ^^^^^^^^^^^^ help: change it to: `clippy::group` warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:29:9 + --> $DIR/lint-tool-test.rs:31:9 | LL | #[allow(test_group)] | ^^^^^^^^^^ help: change it to: `clippy::test_group` @@ -59,39 +59,57 @@ LL | #![cfg_attr(foo, warn(test_lint))] | ^^^^^^^^^ help: change it to: `clippy::test_lint` warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:13:9 + --> $DIR/lint-tool-test.rs:14:9 | LL | #![deny(clippy_group)] | ^^^^^^^^^^^^ help: change it to: `clippy::group` error: item is named 'lintme' - --> $DIR/lint-tool-test.rs:18:1 + --> $DIR/lint-tool-test.rs:20:1 | LL | fn lintme() { } | ^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-tool-test.rs:13:9 + --> $DIR/lint-tool-test.rs:14:9 | LL | #![deny(clippy_group)] | ^^^^^^^^^^^^ = note: `#[deny(clippy::test_lint)]` implied by `#[deny(clippy::group)]` error: item is named 'lintmetoo' - --> $DIR/lint-tool-test.rs:26:5 + --> $DIR/lint-tool-test.rs:28:5 | LL | fn lintmetoo() { } | ^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-tool-test.rs:13:9 + --> $DIR/lint-tool-test.rs:14:9 | LL | #![deny(clippy_group)] | ^^^^^^^^^^^^ = note: `#[deny(clippy::test_group)]` implied by `#[deny(clippy::group)]` warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint-tool-test.rs:29:9 + --> $DIR/lint-tool-test.rs:31:9 + | +LL | #[allow(test_group)] + | ^^^^^^^^^^ help: change it to: `clippy::test_group` + +warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint-tool-test.rs:9:23 + | +LL | #![cfg_attr(foo, warn(test_lint))] + | ^^^^^^^^^ help: change it to: `clippy::test_lint` + +warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint-tool-test.rs:14:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ help: change it to: `clippy::group` + +warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint-tool-test.rs:31:9 | LL | #[allow(test_group)] | ^^^^^^^^^^ help: change it to: `clippy::test_group` diff --git a/src/test/ui/deduplicate-diagnostics.duplicate.stderr b/src/test/ui/deduplicate-diagnostics.duplicate.stderr index 3b100b59995f0..49dd15f6a5e01 100644 --- a/src/test/ui/deduplicate-diagnostics.duplicate.stderr +++ b/src/test/ui/deduplicate-diagnostics.duplicate.stderr @@ -28,6 +28,12 @@ error[E0452]: malformed lint attribute input LL | #[deny("literal")] | ^^^^^^^^^ bad attribute argument -error: aborting due to 5 previous errors +error[E0452]: malformed lint attribute input + --> $DIR/deduplicate-diagnostics.rs:8:8 + | +LL | #[deny("literal")] + | ^^^^^^^^^ bad attribute argument + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0452`. diff --git a/src/test/ui/deduplicate-diagnostics.rs b/src/test/ui/deduplicate-diagnostics.rs index c5d41ff2fdac3..2f72c6e61b4b7 100644 --- a/src/test/ui/deduplicate-diagnostics.rs +++ b/src/test/ui/deduplicate-diagnostics.rs @@ -8,4 +8,5 @@ struct S; #[deny("literal")] //~ ERROR malformed lint attribute input //[duplicate]~| ERROR malformed lint attribute input //[duplicate]~| ERROR malformed lint attribute input + //[duplicate]~| ERROR malformed lint attribute input fn main() {} diff --git a/src/test/ui/error-codes/E0452.rs b/src/test/ui/error-codes/E0452.rs index 4e5a6c9301467..9355f9a41a0e6 100644 --- a/src/test/ui/error-codes/E0452.rs +++ b/src/test/ui/error-codes/E0452.rs @@ -4,5 +4,7 @@ //~| ERROR E0452 //~| ERROR E0452 //~| ERROR E0452 + //~| ERROR E0452 + //~| ERROR E0452 fn main() { } diff --git a/src/test/ui/error-codes/E0452.stderr b/src/test/ui/error-codes/E0452.stderr index 30c11e3274e1c..e37602f29f765 100644 --- a/src/test/ui/error-codes/E0452.stderr +++ b/src/test/ui/error-codes/E0452.stderr @@ -34,6 +34,18 @@ error[E0452]: malformed lint attribute input LL | #![allow(foo = "")] | ^^^^^^^^ bad attribute argument -error: aborting due to 6 previous errors +error[E0452]: malformed lint attribute input + --> $DIR/E0452.rs:1:10 + | +LL | #![allow(foo = "")] + | ^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/E0452.rs:1:10 + | +LL | #![allow(foo = "")] + | ^^^^^^^^ bad attribute argument + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0452`. diff --git a/src/test/ui/error-codes/E0453.rs b/src/test/ui/error-codes/E0453.rs index 69155b0688bc0..f4bc3e049a7da 100644 --- a/src/test/ui/error-codes/E0453.rs +++ b/src/test/ui/error-codes/E0453.rs @@ -4,5 +4,6 @@ //~^ ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case) //~| ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case) //~| ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case) +//~| ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case) fn main() { } diff --git a/src/test/ui/error-codes/E0453.stderr b/src/test/ui/error-codes/E0453.stderr index 138e8483461c9..3ff4f4aef57a7 100644 --- a/src/test/ui/error-codes/E0453.stderr +++ b/src/test/ui/error-codes/E0453.stderr @@ -25,6 +25,15 @@ LL | LL | #[allow(non_snake_case)] | ^^^^^^^^^^^^^^ overruled by previous forbid -error: aborting due to 3 previous errors +error[E0453]: allow(non_snake_case) overruled by outer forbid(non_snake_case) + --> $DIR/E0453.rs:3:9 + | +LL | #![forbid(non_snake_case)] + | -------------- `forbid` level set here +LL | +LL | #[allow(non_snake_case)] + | ^^^^^^^^^^^^^^ overruled by previous forbid + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/error-codes/E0602.stderr b/src/test/ui/error-codes/E0602.stderr index 70137cb166206..32138e63a4bfb 100644 --- a/src/test/ui/error-codes/E0602.stderr +++ b/src/test/ui/error-codes/E0602.stderr @@ -10,6 +10,10 @@ error[E0602]: unknown lint: `bogus` | = note: requested on the command line with `-D bogus` -error: aborting due to 3 previous errors +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0602`. diff --git a/src/test/ui/feature-gates/feature-gate-lint-reasons.rs b/src/test/ui/feature-gates/feature-gate-lint-reasons.rs index b124e9b2f4d71..2d15bf99613d8 100644 --- a/src/test/ui/feature-gates/feature-gate-lint-reasons.rs +++ b/src/test/ui/feature-gates/feature-gate-lint-reasons.rs @@ -2,5 +2,6 @@ //~^ ERROR lint reasons are experimental //~| ERROR lint reasons are experimental //~| ERROR lint reasons are experimental +//~| ERROR lint reasons are experimental fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-lint-reasons.stderr b/src/test/ui/feature-gates/feature-gate-lint-reasons.stderr index 08ba9d0d3a313..4843f7385042e 100644 --- a/src/test/ui/feature-gates/feature-gate-lint-reasons.stderr +++ b/src/test/ui/feature-gates/feature-gate-lint-reasons.stderr @@ -25,6 +25,15 @@ LL | #![warn(nonstandard_style, reason = "the standard should be respected")] = note: for more information, see https://github.com/rust-lang/rust/issues/54503 = help: add `#![feature(lint_reasons)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error[E0658]: lint reasons are experimental + --> $DIR/feature-gate-lint-reasons.rs:1:28 + | +LL | #![warn(nonstandard_style, reason = "the standard should be respected")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54503 + = help: add `#![feature(lint_reasons)]` to the crate attributes to enable + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/lint/lint-forbid-attr.rs b/src/test/ui/lint/lint-forbid-attr.rs index 13b28e8830b62..6d12215e99d6a 100644 --- a/src/test/ui/lint/lint-forbid-attr.rs +++ b/src/test/ui/lint/lint-forbid-attr.rs @@ -4,5 +4,6 @@ //~^ ERROR allow(deprecated) overruled by outer forbid(deprecated) //~| ERROR allow(deprecated) overruled by outer forbid(deprecated) //~| ERROR allow(deprecated) overruled by outer forbid(deprecated) +//~| ERROR allow(deprecated) overruled by outer forbid(deprecated) fn main() { } diff --git a/src/test/ui/lint/lint-forbid-attr.stderr b/src/test/ui/lint/lint-forbid-attr.stderr index bf138c317e93d..3b00a0144aa03 100644 --- a/src/test/ui/lint/lint-forbid-attr.stderr +++ b/src/test/ui/lint/lint-forbid-attr.stderr @@ -25,6 +25,15 @@ LL | LL | #[allow(deprecated)] | ^^^^^^^^^^ overruled by previous forbid -error: aborting due to 3 previous errors +error[E0453]: allow(deprecated) overruled by outer forbid(deprecated) + --> $DIR/lint-forbid-attr.rs:3:9 + | +LL | #![forbid(deprecated)] + | ---------- `forbid` level set here +LL | +LL | #[allow(deprecated)] + | ^^^^^^^^^^ overruled by previous forbid + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/lint/lint-forbid-cmdline.rs b/src/test/ui/lint/lint-forbid-cmdline.rs index 821470c86860a..69528c6f85135 100644 --- a/src/test/ui/lint/lint-forbid-cmdline.rs +++ b/src/test/ui/lint/lint-forbid-cmdline.rs @@ -3,5 +3,6 @@ #[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) //~| ERROR allow(deprecated) overruled by outer forbid(deprecated) //~| ERROR allow(deprecated) overruled by outer forbid(deprecated) + //~| ERROR allow(deprecated) overruled by outer forbid(deprecated) fn main() { } diff --git a/src/test/ui/lint/lint-forbid-cmdline.stderr b/src/test/ui/lint/lint-forbid-cmdline.stderr index 89a4445d80068..1d2eda5db0780 100644 --- a/src/test/ui/lint/lint-forbid-cmdline.stderr +++ b/src/test/ui/lint/lint-forbid-cmdline.stderr @@ -22,6 +22,14 @@ LL | #[allow(deprecated)] | = note: `forbid` lint level was set on command line -error: aborting due to 3 previous errors +error[E0453]: allow(deprecated) overruled by outer forbid(deprecated) + --> $DIR/lint-forbid-cmdline.rs:3:9 + | +LL | #[allow(deprecated)] + | ^^^^^^^^^^ overruled by previous forbid + | + = note: `forbid` lint level was set on command line + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/lint/lint-malformed.rs b/src/test/ui/lint/lint-malformed.rs index cf5570753d85d..57ec290cdfb34 100644 --- a/src/test/ui/lint/lint-malformed.rs +++ b/src/test/ui/lint/lint-malformed.rs @@ -5,4 +5,6 @@ //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute + //~| ERROR malformed lint attribute + //~| ERROR malformed lint attribute fn main() { } diff --git a/src/test/ui/lint/lint-malformed.stderr b/src/test/ui/lint/lint-malformed.stderr index 6dc8d4984445e..777197a4f4267 100644 --- a/src/test/ui/lint/lint-malformed.stderr +++ b/src/test/ui/lint/lint-malformed.stderr @@ -40,6 +40,18 @@ error[E0452]: malformed lint attribute input LL | #![allow(bar = "baz")] | ^^^^^^^^^^^ bad attribute argument -error: aborting due to 7 previous errors +error[E0452]: malformed lint attribute input + --> $DIR/lint-malformed.rs:2:10 + | +LL | #![allow(bar = "baz")] + | ^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/lint-malformed.rs:2:10 + | +LL | #![allow(bar = "baz")] + | ^^^^^^^^^^^ bad attribute argument + +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0452`. diff --git a/src/test/ui/lint/lint-unknown-lint-cmdline.stderr b/src/test/ui/lint/lint-unknown-lint-cmdline.stderr index 27e7ee7fc03bd..6bd98fa8f51ba 100644 --- a/src/test/ui/lint/lint-unknown-lint-cmdline.stderr +++ b/src/test/ui/lint/lint-unknown-lint-cmdline.stderr @@ -25,6 +25,15 @@ error[E0602]: unknown lint: `dead_cod` = help: did you mean: `dead_code` = note: requested on the command line with `-D dead_cod` -error: aborting due to 6 previous errors +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error[E0602]: unknown lint: `dead_cod` + | + = help: did you mean: `dead_code` + = note: requested on the command line with `-D dead_cod` + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0602`. diff --git a/src/test/ui/lint/outer-forbid.rs b/src/test/ui/lint/outer-forbid.rs index 2a38565f60364..c2e1f0cb4ba7a 100644 --- a/src/test/ui/lint/outer-forbid.rs +++ b/src/test/ui/lint/outer-forbid.rs @@ -9,16 +9,19 @@ #[allow(unused_variables)] //~ ERROR overruled //~| ERROR overruled //~| ERROR overruled + //~| ERROR overruled fn foo() {} #[allow(unused)] //~ ERROR overruled //~| ERROR overruled //~| ERROR overruled + //~| ERROR overruled fn bar() {} #[allow(nonstandard_style)] //~ ERROR overruled //~| ERROR overruled //~| ERROR overruled + //~| ERROR overruled fn main() { println!("hello forbidden world") } diff --git a/src/test/ui/lint/outer-forbid.stderr b/src/test/ui/lint/outer-forbid.stderr index b2e638e7af978..b8c3171ab3a4e 100644 --- a/src/test/ui/lint/outer-forbid.stderr +++ b/src/test/ui/lint/outer-forbid.stderr @@ -8,7 +8,7 @@ LL | #[allow(unused_variables)] | ^^^^^^^^^^^^^^^^ overruled by previous forbid error[E0453]: allow(unused) overruled by outer forbid(unused) - --> $DIR/outer-forbid.rs:14:9 + --> $DIR/outer-forbid.rs:15:9 | LL | #![forbid(unused, non_snake_case)] | ------ `forbid` level set here @@ -17,7 +17,7 @@ LL | #[allow(unused)] | ^^^^^^ overruled by previous forbid error[E0453]: allow(nonstandard_style) overruled by outer forbid(non_snake_case) - --> $DIR/outer-forbid.rs:19:9 + --> $DIR/outer-forbid.rs:21:9 | LL | #![forbid(unused, non_snake_case)] | -------------- `forbid` level set here @@ -35,7 +35,7 @@ LL | #[allow(unused_variables)] | ^^^^^^^^^^^^^^^^ overruled by previous forbid error[E0453]: allow(unused) overruled by outer forbid(unused) - --> $DIR/outer-forbid.rs:14:9 + --> $DIR/outer-forbid.rs:15:9 | LL | #![forbid(unused, non_snake_case)] | ------ `forbid` level set here @@ -44,7 +44,7 @@ LL | #[allow(unused)] | ^^^^^^ overruled by previous forbid error[E0453]: allow(nonstandard_style) overruled by outer forbid(non_snake_case) - --> $DIR/outer-forbid.rs:19:9 + --> $DIR/outer-forbid.rs:21:9 | LL | #![forbid(unused, non_snake_case)] | -------------- `forbid` level set here @@ -62,7 +62,7 @@ LL | #[allow(unused_variables)] | ^^^^^^^^^^^^^^^^ overruled by previous forbid error[E0453]: allow(unused) overruled by outer forbid(unused) - --> $DIR/outer-forbid.rs:14:9 + --> $DIR/outer-forbid.rs:15:9 | LL | #![forbid(unused, non_snake_case)] | ------ `forbid` level set here @@ -71,7 +71,7 @@ LL | #[allow(unused)] | ^^^^^^ overruled by previous forbid error[E0453]: allow(nonstandard_style) overruled by outer forbid(non_snake_case) - --> $DIR/outer-forbid.rs:19:9 + --> $DIR/outer-forbid.rs:21:9 | LL | #![forbid(unused, non_snake_case)] | -------------- `forbid` level set here @@ -79,6 +79,33 @@ LL | #![forbid(unused, non_snake_case)] LL | #[allow(nonstandard_style)] | ^^^^^^^^^^^^^^^^^ overruled by previous forbid -error: aborting due to 9 previous errors +error[E0453]: allow(unused_variables) overruled by outer forbid(unused) + --> $DIR/outer-forbid.rs:9:9 + | +LL | #![forbid(unused, non_snake_case)] + | ------ `forbid` level set here +LL | +LL | #[allow(unused_variables)] + | ^^^^^^^^^^^^^^^^ overruled by previous forbid + +error[E0453]: allow(unused) overruled by outer forbid(unused) + --> $DIR/outer-forbid.rs:15:9 + | +LL | #![forbid(unused, non_snake_case)] + | ------ `forbid` level set here +... +LL | #[allow(unused)] + | ^^^^^^ overruled by previous forbid + +error[E0453]: allow(nonstandard_style) overruled by outer forbid(non_snake_case) + --> $DIR/outer-forbid.rs:21:9 + | +LL | #![forbid(unused, non_snake_case)] + | -------------- `forbid` level set here +... +LL | #[allow(nonstandard_style)] + | ^^^^^^^^^^^^^^^^^ overruled by previous forbid + +error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/lint/reasons-erroneous.rs b/src/test/ui/lint/reasons-erroneous.rs index 03cf0679fce94..d9cebdc406c52 100644 --- a/src/test/ui/lint/reasons-erroneous.rs +++ b/src/test/ui/lint/reasons-erroneous.rs @@ -4,6 +4,8 @@ //~^ ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE reason must be a string literal //~| NOTE reason must be a string literal //~| NOTE reason must be a string literal //~| NOTE reason must be a string literal @@ -11,6 +13,8 @@ //~^ ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE reason must be a string literal //~| NOTE reason must be a string literal //~| NOTE reason must be a string literal //~| NOTE reason must be a string literal @@ -21,6 +25,10 @@ //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE bad attribute argument +//~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument @@ -34,6 +42,10 @@ //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE bad attribute argument +//~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument @@ -47,6 +59,10 @@ //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE bad attribute argument +//~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument //~| NOTE bad attribute argument @@ -57,6 +73,8 @@ //~^ ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last @@ -64,6 +82,8 @@ //~^ ERROR malformed lint attribute //~| ERROR malformed lint attribute //~| ERROR malformed lint attribute +//~| ERROR malformed lint attribute +//~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last //~| NOTE reason in lint attribute must come last diff --git a/src/test/ui/lint/reasons-erroneous.stderr b/src/test/ui/lint/reasons-erroneous.stderr index a84167fed12d0..3a32c2ecfce5f 100644 --- a/src/test/ui/lint/reasons-erroneous.stderr +++ b/src/test/ui/lint/reasons-erroneous.stderr @@ -5,61 +5,61 @@ LL | #![warn(absolute_paths_not_starting_with_crate, reason = 0)] | ^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:10:40 + --> $DIR/reasons-erroneous.rs:12:40 | LL | #![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:56:44 + --> $DIR/reasons-erroneous.rs:72:44 | LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] | ^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:63:25 + --> $DIR/reasons-erroneous.rs:81:25 | LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last warning: unknown lint: `reason` - --> $DIR/reasons-erroneous.rs:70:39 + --> $DIR/reasons-erroneous.rs:90:39 | LL | #![warn(missing_copy_implementations, reason)] | ^^^^^^ @@ -73,55 +73,55 @@ LL | #![warn(absolute_paths_not_starting_with_crate, reason = 0)] | ^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:10:40 + --> $DIR/reasons-erroneous.rs:12:40 | LL | #![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:56:44 + --> $DIR/reasons-erroneous.rs:72:44 | LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] | ^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:63:25 + --> $DIR/reasons-erroneous.rs:81:25 | LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last @@ -133,59 +133,119 @@ LL | #![warn(absolute_paths_not_starting_with_crate, reason = 0)] | ^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:10:40 + --> $DIR/reasons-erroneous.rs:12:40 | LL | #![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reason must be a string literal error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:17:29 + --> $DIR/reasons-erroneous.rs:21:29 | LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:30:23 + --> $DIR/reasons-erroneous.rs:38:23 | LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:43:36 + --> $DIR/reasons-erroneous.rs:55:36 | LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:56:44 + --> $DIR/reasons-erroneous.rs:72:44 | LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] | ^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last error[E0452]: malformed lint attribute input - --> $DIR/reasons-erroneous.rs:63:25 + --> $DIR/reasons-erroneous.rs:81:25 | LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last -error: aborting due to 30 previous errors +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:3:58 + | +LL | #![warn(absolute_paths_not_starting_with_crate, reason = 0)] + | ^ reason must be a string literal + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:12:40 + | +LL | #![warn(anonymous_parameters, reason = b"consider these, for we have condemned them")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reason must be a string literal + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:21:29 + | +LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:21:29 + | +LL | #![warn(bare_trait_objects, reasons = "leaders to no sure land, guides their bearings lost")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:38:23 + | +LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:38:23 + | +LL | #![warn(box_pointers, blerp = "or in league with robbers have reversed the signposts")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:55:36 + | +LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:55:36 + | +LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad attribute argument + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:72:44 + | +LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")] + | ^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last + +error[E0452]: malformed lint attribute input + --> $DIR/reasons-erroneous.rs:81:25 + | +LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last + +error: aborting due to 40 previous errors For more information about this error, try `rustc --explain E0452`. diff --git a/src/test/ui/lint/reasons-forbidden.rs b/src/test/ui/lint/reasons-forbidden.rs index 6a71176aabb15..7a4a739565a36 100644 --- a/src/test/ui/lint/reasons-forbidden.rs +++ b/src/test/ui/lint/reasons-forbidden.rs @@ -5,6 +5,7 @@ //~^ NOTE `forbid` level set here //~| NOTE `forbid` level set here //~| NOTE `forbid` level set here + //~| NOTE `forbid` level set here reason = "our errors & omissions insurance policy doesn't cover unsafe Rust" )] @@ -17,9 +18,12 @@ fn main() { //~^ ERROR allow(unsafe_code) overruled by outer forbid(unsafe_code) //~| ERROR allow(unsafe_code) overruled by outer forbid(unsafe_code) //~| ERROR allow(unsafe_code) overruled by outer forbid(unsafe_code) + //~| ERROR allow(unsafe_code) overruled by outer forbid(unsafe_code) //~| NOTE overruled by previous forbid //~| NOTE overruled by previous forbid //~| NOTE overruled by previous forbid + //~| NOTE overruled by previous forbid + //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust //~| NOTE our errors & omissions insurance policy doesn't cover unsafe Rust diff --git a/src/test/ui/lint/reasons-forbidden.stderr b/src/test/ui/lint/reasons-forbidden.stderr index 0954edea7378c..3ce1b332c369a 100644 --- a/src/test/ui/lint/reasons-forbidden.stderr +++ b/src/test/ui/lint/reasons-forbidden.stderr @@ -1,5 +1,5 @@ error[E0453]: allow(unsafe_code) overruled by outer forbid(unsafe_code) - --> $DIR/reasons-forbidden.rs:16:13 + --> $DIR/reasons-forbidden.rs:17:13 | LL | unsafe_code, | ----------- `forbid` level set here @@ -10,7 +10,7 @@ LL | #[allow(unsafe_code)] = note: our errors & omissions insurance policy doesn't cover unsafe Rust error[E0453]: allow(unsafe_code) overruled by outer forbid(unsafe_code) - --> $DIR/reasons-forbidden.rs:16:13 + --> $DIR/reasons-forbidden.rs:17:13 | LL | unsafe_code, | ----------- `forbid` level set here @@ -21,7 +21,7 @@ LL | #[allow(unsafe_code)] = note: our errors & omissions insurance policy doesn't cover unsafe Rust error[E0453]: allow(unsafe_code) overruled by outer forbid(unsafe_code) - --> $DIR/reasons-forbidden.rs:16:13 + --> $DIR/reasons-forbidden.rs:17:13 | LL | unsafe_code, | ----------- `forbid` level set here @@ -31,6 +31,17 @@ LL | #[allow(unsafe_code)] | = note: our errors & omissions insurance policy doesn't cover unsafe Rust -error: aborting due to 3 previous errors +error[E0453]: allow(unsafe_code) overruled by outer forbid(unsafe_code) + --> $DIR/reasons-forbidden.rs:17:13 + | +LL | unsafe_code, + | ----------- `forbid` level set here +... +LL | #[allow(unsafe_code)] + | ^^^^^^^^^^^ overruled by previous forbid + | + = note: our errors & omissions insurance policy doesn't cover unsafe Rust + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/tool_lints.rs b/src/test/ui/tool_lints.rs index 9c8540eede792..3f79f8c7b08ab 100644 --- a/src/test/ui/tool_lints.rs +++ b/src/test/ui/tool_lints.rs @@ -2,4 +2,5 @@ //~^ ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` +//~| ERROR an unknown tool name found in scoped lint: `foo::bar` fn main() {} diff --git a/src/test/ui/tool_lints.stderr b/src/test/ui/tool_lints.stderr index 86f87784eaf86..90f15d0ad7ee0 100644 --- a/src/test/ui/tool_lints.stderr +++ b/src/test/ui/tool_lints.stderr @@ -16,5 +16,11 @@ error[E0710]: an unknown tool name found in scoped lint: `foo::bar` LL | #[warn(foo::bar)] | ^^^ -error: aborting due to 3 previous errors +error[E0710]: an unknown tool name found in scoped lint: `foo::bar` + --> $DIR/tool_lints.rs:1:8 + | +LL | #[warn(foo::bar)] + | ^^^ + +error: aborting due to 4 previous errors diff --git a/src/test/ui/unknown-lint-tool-name.rs b/src/test/ui/unknown-lint-tool-name.rs index 182aec34b4781..fe67df6c4cc29 100644 --- a/src/test/ui/unknown-lint-tool-name.rs +++ b/src/test/ui/unknown-lint-tool-name.rs @@ -1,8 +1,10 @@ #![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` + //~| ERROR an unknown tool name found in scoped lint: `foo::bar` #[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` //~| ERROR an unknown tool name found in scoped lint: `foo::bar` + //~| ERROR an unknown tool name found in scoped lint: `foo::bar` fn main() {} diff --git a/src/test/ui/unknown-lint-tool-name.stderr b/src/test/ui/unknown-lint-tool-name.stderr index 1940f61a47b68..1f5f9b014a80f 100644 --- a/src/test/ui/unknown-lint-tool-name.stderr +++ b/src/test/ui/unknown-lint-tool-name.stderr @@ -5,7 +5,7 @@ LL | #![deny(foo::bar)] | ^^^ error[E0710]: an unknown tool name found in scoped lint: `foo::bar` - --> $DIR/unknown-lint-tool-name.rs:5:9 + --> $DIR/unknown-lint-tool-name.rs:6:9 | LL | #[allow(foo::bar)] | ^^^ @@ -17,7 +17,7 @@ LL | #![deny(foo::bar)] | ^^^ error[E0710]: an unknown tool name found in scoped lint: `foo::bar` - --> $DIR/unknown-lint-tool-name.rs:5:9 + --> $DIR/unknown-lint-tool-name.rs:6:9 | LL | #[allow(foo::bar)] | ^^^ @@ -29,10 +29,22 @@ LL | #![deny(foo::bar)] | ^^^ error[E0710]: an unknown tool name found in scoped lint: `foo::bar` - --> $DIR/unknown-lint-tool-name.rs:5:9 + --> $DIR/unknown-lint-tool-name.rs:6:9 | LL | #[allow(foo::bar)] | ^^^ -error: aborting due to 6 previous errors +error[E0710]: an unknown tool name found in scoped lint: `foo::bar` + --> $DIR/unknown-lint-tool-name.rs:1:9 + | +LL | #![deny(foo::bar)] + | ^^^ + +error[E0710]: an unknown tool name found in scoped lint: `foo::bar` + --> $DIR/unknown-lint-tool-name.rs:6:9 + | +LL | #[allow(foo::bar)] + | ^^^ + +error: aborting due to 8 previous errors From b9c97e936658738a93f17c1ad8db45f1c219e1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 13 Jan 2020 11:36:01 +0100 Subject: [PATCH 17/17] Drop `ensure` for privacy_access_levels. Add some comments. --- src/librustc_interface/passes.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index b6913c5d23442..8d36f64d1c7b1 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -783,6 +783,8 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx)); }, { + // This is used by the loop below. + // Make sure it is complete before we fan out. tcx.get_lang_items(LOCAL_CRATE); let _timer = tcx.sess.timer("misc_module_passes"); @@ -802,6 +804,8 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { tcx.visible_parent_map(LOCAL_CRATE); }, { + // This is used by `check_mod_unstable_api_usage`. + // Make sure it is complete before we fan out. tcx.stability_index(LOCAL_CRATE); let _timer = tcx.sess.timer("check_unstable_api_usage"); @@ -852,7 +856,8 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> { sess.time("misc_checking_3", || { parallel!( { - tcx.ensure().privacy_access_levels(LOCAL_CRATE); + // Prefetch this as it is used later by lint checking and privacy checking. + tcx.privacy_access_levels(LOCAL_CRATE); }, { sess.time("MIR_borrow_checking", || {