From 4d426bb1c031867254611b37904695d3b98077a8 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:20:56 +0300 Subject: [PATCH 01/12] rustc_target: deny(unused_lifetimes). --- src/librustc_target/abi/mod.rs | 2 +- src/librustc_target/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 8fc5e6aae34d4..77493fbc5dfc7 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -583,7 +583,7 @@ pub enum Primitive { Pointer } -impl<'a, 'tcx> Primitive { +impl Primitive { pub fn size(self, cx: &C) -> Size { let dl = cx.data_layout(); diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 3fcf08adb5c8e..1bebe420251fd 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -17,6 +17,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[macro_use] extern crate log; From ce0ba38921efe3ac36208cb1ced888795cd12759 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:21:12 +0300 Subject: [PATCH 02/12] syntax_ext: deny(unused_lifetimes). --- src/libsyntax_ext/cfg.rs | 2 +- src/libsyntax_ext/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 090d730289d26..3b49f218811ad 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -12,7 +12,7 @@ use syntax::tokenstream; use syntax::parse::token; use syntax_pos::Span; -pub fn expand_cfg<'cx>(cx: &mut ExtCtxt<'_>, +pub fn expand_cfg(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::TokenTree]) -> Box { diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index fc00154427501..1627f99f616ff 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -4,6 +4,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(in_band_lifetimes)] #![feature(proc_macro_diagnostic)] From 774724be3ca3ce7580fadf9bd171df0255023e40 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:21:38 +0300 Subject: [PATCH 03/12] rustc: deny(unused_lifetimes). --- src/librustc/hir/map/collector.rs | 2 +- src/librustc/ich/hcx.rs | 2 +- src/librustc/ich/impls_ty.rs | 10 +++++----- src/librustc/infer/region_constraints/mod.rs | 2 +- src/librustc/lib.rs | 1 + src/librustc/lint/context.rs | 6 +++--- src/librustc/macros.rs | 18 +++++++++--------- src/librustc/mir/interpret/pointer.rs | 2 +- src/librustc/mir/interpret/value.rs | 2 +- src/librustc/mir/visit.rs | 2 +- src/librustc/session/config.rs | 2 +- src/librustc/traits/auto_trait.rs | 2 +- src/librustc/traits/mod.rs | 2 +- src/librustc/traits/query/type_op/normalize.rs | 2 +- src/librustc/traits/select.rs | 6 +++--- src/librustc/traits/structural_impls.rs | 4 ++-- src/librustc/ty/fast_reject.rs | 2 +- src/librustc/ty/instance.rs | 2 +- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/mod.rs | 4 ++-- src/librustc/ty/print/mod.rs | 2 ++ src/librustc/ty/query/config.rs | 2 ++ src/librustc/ty/sty.rs | 4 ++-- src/librustc/util/captures.rs | 2 ++ 24 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index e66fa13f4fca2..532e61721ca45 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -589,7 +589,7 @@ struct HirItemLike { hash_bodies: bool, } -impl<'a, 'hir, T> HashStable> for HirItemLike +impl<'hir, T> HashStable> for HirItemLike where T: HashStable> { fn hash_stable(&self, diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 8be610e8bf7af..8454eb75b55c7 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -393,7 +393,7 @@ impl<'a> HashStable> for DelimSpan { } } -pub fn hash_stable_trait_impls<'a, 'gcx, W>( +pub fn hash_stable_trait_impls<'a, W>( hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher, blanket_impls: &[DefId], diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 563948a63514b..c2c0ced07e695 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -135,7 +135,7 @@ impl<'gcx> HashStable> for ty::BoundVar { } } -impl<'a, 'gcx, T> HashStable> for ty::Binder +impl<'a, T> HashStable> for ty::Binder where T: HashStable> { fn hash_stable(&self, @@ -192,7 +192,7 @@ impl<'a> ToStableHashKey> for region::Scope { } } -impl<'a, 'gcx> HashStable> +impl<'a> HashStable> for ty::TyVid { fn hash_stable(&self, @@ -204,7 +204,7 @@ for ty::TyVid } } -impl<'a, 'gcx> HashStable> +impl<'a> HashStable> for ty::IntVid { fn hash_stable(&self, @@ -216,7 +216,7 @@ for ty::IntVid } } -impl<'a, 'gcx> HashStable> +impl<'a> HashStable> for ty::FloatVid { fn hash_stable(&self, @@ -228,7 +228,7 @@ for ty::FloatVid } } -impl<'a, 'gcx, T> HashStable> +impl<'a, T> HashStable> for ty::steal::Steal where T: HashStable> { diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index ca766ea724f3d..b6fe57636e904 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -858,7 +858,7 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> { } } -impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> { +impl<'tcx> VerifyBound<'tcx> { pub fn must_hold(&self) -> bool { match self { VerifyBound::IfEq(..) => false, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 920f978054396..e2f2799d9634d 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -30,6 +30,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(explicit_outlives_requirements)] #![feature(arbitrary_self_types)] diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index c5c6c4b944700..b51257c520601 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -566,7 +566,7 @@ impl LintPassObject for EarlyLintPassObject {} impl LintPassObject for LateLintPassObject {} -pub trait LintContext<'tcx>: Sized { +pub trait LintContext: Sized { type PassObject: LintPassObject; fn sess(&self) -> &Session; @@ -700,7 +700,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> { } } -impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> { +impl LintContext for LateContext<'_, '_> { type PassObject = LateLintPassObject; /// Gets the overall compiler `Session` object. @@ -728,7 +728,7 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> { } } -impl<'a> LintContext<'a> for EarlyContext<'a> { +impl LintContext for EarlyContext<'_> { type PassObject = EarlyLintPassObject; /// Gets the overall compiler `Session` object. diff --git a/src/librustc/macros.rs b/src/librustc/macros.rs index f8d7a5e29f6f6..b4088201f3bf1 100644 --- a/src/librustc/macros.rs +++ b/src/librustc/macros.rs @@ -80,7 +80,7 @@ macro_rules! impl_stable_hash_for { // We want to use the enum name both in the `impl ... for $enum_name` as well as for // importing all the variants. Unfortunately it seems we have to take the name // twice for this purpose - (impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?> + (impl<$($T:ident),* $(,)?> for enum $enum_name:path [ $enum_path:path ] { @@ -91,7 +91,7 @@ macro_rules! impl_stable_hash_for { $( { $($named_field:ident $(-> $named_delegate:tt)?),* } )? ),* $(,)? }) => { - impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*> + impl<$($T,)*> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $enum_name where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),* @@ -117,13 +117,13 @@ macro_rules! impl_stable_hash_for { // Structs (struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => { impl_stable_hash_for!( - impl<'tcx> for struct $struct_name { $($field $(-> $delegate)?),* } + impl<> for struct $struct_name { $($field $(-> $delegate)?),* } ); }; - (impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?> for struct $struct_name:path { + (impl<$($T:ident),* $(,)?> for struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => { - impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*> + impl<$($T,)*> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),* { @@ -143,12 +143,12 @@ macro_rules! impl_stable_hash_for { // We cannot use normal parentheses here, the parser won't allow it (tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => { impl_stable_hash_for!( - impl<'tcx> for tuple_struct $struct_name { $($field $(-> $delegate)?),* } + impl<> for tuple_struct $struct_name { $($field $(-> $delegate)?),* } ); }; - (impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?> + (impl<$($T:ident),* $(,)?> for tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => { - impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*> + impl<$($T,)*> ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),* { @@ -170,7 +170,7 @@ macro_rules! impl_stable_hash_for { macro_rules! impl_stable_hash_for_spanned { ($T:path) => ( - impl<'a, 'tcx> HashStable> for ::syntax::source_map::Spanned<$T> + impl HashStable> for ::syntax::source_map::Spanned<$T> { #[inline] fn hash_stable(&self, diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index a6c47ff5ca0f7..26002a411d4b6 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -105,7 +105,7 @@ impl From for Pointer { } } -impl<'tcx> Pointer<()> { +impl Pointer<()> { #[inline(always)] pub fn new(alloc_id: AllocId, offset: Size) -> Self { Pointer { alloc_id, offset, tag: () } diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 23c37676f3659..f7b3385668f7b 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -146,7 +146,7 @@ impl From for Scalar { } } -impl<'tcx> Scalar<()> { +impl Scalar<()> { #[inline(always)] fn check_data(data: u128, size: u8) { debug_assert_eq!(truncate(data, Size::from_bytes(size as u64)), data, diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index b4acc076f3e4e..babce812d4a39 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -967,7 +967,7 @@ pub enum PlaceContext { NonUse(NonUseContext), } -impl<'tcx> PlaceContext { +impl PlaceContext { /// Returns `true` if this place context represents a drop. pub fn is_drop(&self) -> bool { match *self { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 003fdd501a35a..6a03aa64d26d1 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -785,7 +785,7 @@ macro_rules! options { return op; } - impl<'a> dep_tracking::DepTrackingHash for $struct_name { + impl dep_tracking::DepTrackingHash for $struct_name { fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) { let mut sub_hashes = BTreeMap::new(); $({ diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 7505b3c1be844..9ce35d15d3c33 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -270,7 +270,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // the final synthesized generics: we don't want our generated docs page to contain something // like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate // 'user_env', which only holds the predicates that will actually be displayed to the user. - fn evaluate_predicates<'b, 'gcx, 'c>( + fn evaluate_predicates<'b, 'c>( &self, infcx: &InferCtxt<'b, 'tcx, 'c>, trait_did: DefId, diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index c135b0b759c6f..fd2d8fd0661a5 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -1191,7 +1191,7 @@ where folder: &mut F, ) -> chalk_engine::ExClause; - fn visit_ex_clause_with<'gcx: 'tcx, V: TypeVisitor<'tcx>>( + fn visit_ex_clause_with>( ex_clause: &chalk_engine::ExClause, visitor: &mut V, ) -> bool; diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs index e3d7a4d57a564..594f55e52f8e6 100644 --- a/src/librustc/traits/query/type_op/normalize.rs +++ b/src/librustc/traits/query/type_op/normalize.rs @@ -145,7 +145,7 @@ BraceStructLiftImpl! { } impl_stable_hash_for! { - impl<'tcx, T> for struct Normalize { + impl for struct Normalize { value } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 7810d65e88cc1..c637fc27cc0ca 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -104,7 +104,7 @@ pub enum IntercrateAmbiguityCause { impl IntercrateAmbiguityCause { /// Emits notes when the overlap is caused by complex intercrate ambiguities. /// See #23980 for details. - pub fn add_intercrate_ambiguity_hint<'a, 'tcx>( + pub fn add_intercrate_ambiguity_hint( &self, err: &mut errors::DiagnosticBuilder<'_>, ) { @@ -2299,7 +2299,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { /// candidates and prefer where-clause candidates. /// /// See the comment for "SelectionCandidate" for more details. - fn candidate_should_be_dropped_in_favor_of<'o>( + fn candidate_should_be_dropped_in_favor_of( &mut self, victim: &EvaluatedCandidate<'tcx>, other: &EvaluatedCandidate<'tcx>, @@ -2423,7 +2423,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // These cover the traits that are built-in to the language // itself: `Copy`, `Clone` and `Sized`. - fn assemble_builtin_bound_candidates<'o>( + fn assemble_builtin_bound_candidates( &mut self, conditions: BuiltinImplConditions<'tcx>, candidates: &mut SelectionCandidateSet<'tcx>, diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 4d382d6c45a76..f6108f2a28699 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -90,13 +90,13 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> { } } -impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData { +impl fmt::Debug for traits::VtableBuiltinData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "VtableBuiltinData(nested={:?})", self.nested) } } -impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData { +impl fmt::Debug for traits::VtableAutoImplData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 59ab4561f2c87..3ac76c384e605 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -154,7 +154,7 @@ impl SimplifiedTypeGen { } } -impl<'a, 'gcx, D> HashStable> for SimplifiedTypeGen +impl<'a, D> HashStable> for SimplifiedTypeGen where D: Copy + Debug + Ord + Eq + Hash + HashStable>, { diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index f0251917074d4..cee1359eb366b 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -442,7 +442,7 @@ fn resolve_associated_item<'a, 'tcx>( } } -fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind, +fn needs_fn_once_adapter_shim(actual_closure_kind: ty::ClosureKind, trait_closure_kind: ty::ClosureKind) -> Result { diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 8e2c3dd3d8ad9..879d03352e654 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1678,7 +1678,7 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> { } } -impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> +impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> where C: LayoutOf> + HasTyCtxt<'tcx>, C::TyLayout: MaybeResult>, C: HasParamEnv<'tcx> diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 69bf05c66f394..aafc510f5b6ed 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -203,7 +203,7 @@ impl AssocItem { /// Tests whether the associated item admits a non-trivial implementation /// for ! - pub fn relevant_for_never<'tcx>(&self) -> bool { + pub fn relevant_for_never(&self) -> bool { match self.kind { AssocKind::Existential | AssocKind::Const | @@ -1614,7 +1614,7 @@ pub struct Placeholder { pub name: T, } -impl<'a, 'gcx, T> HashStable> for Placeholder +impl<'a, T> HashStable> for Placeholder where T: HashStable> { fn hash_stable( diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index a7cb7bd3956f0..d6bc4e537581b 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -11,6 +11,8 @@ pub use self::pretty::*; pub mod obsolete; +// FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`. +#[allow(unused_lifetimes)] pub trait Print<'gcx, 'tcx, P> { type Output; type Error; diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 0eda92ea8b822..286894c82b7e2 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -17,6 +17,8 @@ use crate::ich::StableHashingContext; // Query configuration and description traits. +// FIXME(eddyb) false positive, the lifetime parameter is used for `Key`/`Value`. +#[allow(unused_lifetimes)] pub trait QueryConfig<'tcx> { const NAME: QueryName; const CATEGORY: ProfileCategory; diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 5cc46b21fca1f..abde4d6de2aed 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -886,7 +886,7 @@ impl Binder { } /// Wraps `value` in a binder, binding higher-ranked vars (if any). - pub fn bind<'tcx>(value: T) -> Binder { + pub fn bind(value: T) -> Binder { Binder(value) } @@ -988,7 +988,7 @@ pub struct ProjectionTy<'tcx> { pub item_def_id: DefId, } -impl<'a, 'tcx> ProjectionTy<'tcx> { +impl<'tcx> ProjectionTy<'tcx> { /// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the /// associated item named `item_name`. pub fn from_ref_and_name( diff --git a/src/librustc/util/captures.rs b/src/librustc/util/captures.rs index 09d576b23c0f5..dee9a7c3f4a78 100644 --- a/src/librustc/util/captures.rs +++ b/src/librustc/util/captures.rs @@ -3,6 +3,8 @@ /// Basically a workaround; see [this comment] for details. /// /// [this comment]: https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999 +// FIXME(eddyb) false positive, the lifetime parameter is "phantom" but needed. +#[allow(unused_lifetimes)] pub trait Captures<'a> { } impl<'a, T: ?Sized> Captures<'a> for T { } From 26a03405a57f3859508b527f072f49df8d02cba6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:46:49 +0300 Subject: [PATCH 04/12] rustc_incremental: deny(unused_lifetimes). --- src/librustc_incremental/assert_dep_graph.rs | 4 ++-- src/librustc_incremental/lib.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index c964f4cb19b8b..ea89d2ca76d9f 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -258,7 +258,7 @@ fn dump_graph(tcx: TyCtxt<'_, '_, '_>) { pub struct GraphvizDepGraph<'q>(FxHashSet<&'q DepNode>, Vec<(&'q DepNode, &'q DepNode)>); -impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> { +impl<'a, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> { type Node = &'q DepNode; type Edge = (&'q DepNode, &'q DepNode); fn nodes(&self) -> dot::Nodes<'_, &'q DepNode> { @@ -276,7 +276,7 @@ impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> { } } -impl<'a, 'tcx, 'q> dot::Labeller<'a> for GraphvizDepGraph<'q> { +impl<'a, 'q> dot::Labeller<'a> for GraphvizDepGraph<'q> { type Node = &'q DepNode; type Edge = (&'q DepNode, &'q DepNode); fn graph_id(&self) -> dot::Id<'_> { diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index eb82885abee06..50780ba4e7bb3 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -9,6 +9,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[macro_use] extern crate rustc; #[allow(unused_extern_crates)] From 7dc34945e4f67b24fb310ec0e3195ef58544438f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:47:08 +0300 Subject: [PATCH 05/12] rustc_lint: deny(unused_lifetimes). --- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/lib.rs | 1 + src/librustc_lint/types.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6e4d0e881f76b..f3b9408569397 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -96,7 +96,7 @@ declare_lint! { declare_lint_pass!(BoxPointers => [BOX_POINTERS]); impl BoxPointers { - fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext<'_, '_>, span: Span, ty: Ty<'_>) { + fn check_heap_type(&self, cx: &LateContext<'_, '_>, span: Span, ty: Ty<'_>) { for leaf_ty in ty.walk() { if leaf_ty.is_box() { let m = format!("type uses owned (Box type) pointers: {}", ty); diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ba72beecc1a18..87d46a08d9aa6 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -21,6 +21,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[macro_use] extern crate rustc; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index ac18e131c4a3d..7c185ba7423ad 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -202,7 +202,7 @@ fn report_bin_hex_error( // - `uX` => `uY` // // No suggestion for: `isize`, `usize`. -fn get_type_suggestion<'a>( +fn get_type_suggestion( t: Ty<'_>, val: u128, negative: bool, From d110d309b64828142a2a9f4649e3e4647b54cb0f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:47:30 +0300 Subject: [PATCH 06/12] rustc_mir: deny(unused_lifetimes). --- .../borrow_check/nll/invalidation.rs | 2 +- src/librustc_mir/borrow_check/path_utils.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 2 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/interpret/snapshot.rs | 4 +-- src/librustc_mir/interpret/validity.rs | 2 +- src/librustc_mir/lib.rs | 1 + src/librustc_mir/monomorphize/collector.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- src/librustc_mir/transform/generator.rs | 4 +-- src/librustc_mir/transform/simplify.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 26 +++++++++---------- src/librustc_mir/util/liveness.rs | 2 +- 13 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 8fa3bb1847212..516eb6d2941e5 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -258,7 +258,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { } } -impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { +impl<'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { /// Simulates mutation of a place. fn mutate_place( &mut self, diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index dc4235ea6d093..a11e5d9a55687 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -10,7 +10,7 @@ use rustc_data_structures::graph::dominators::Dominators; /// Returns `true` if the borrow represented by `kind` is /// allowed to be split into separate Reservation and /// Activation phases. -pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>(kind: BorrowKind) -> bool { +pub(super) fn allow_two_phase_borrow(kind: BorrowKind) -> bool { kind.allows_two_phase_borrow() } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 20d1423f8a8b6..fbb6161e8fe5b 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1575,7 +1575,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// Append `AscribeUserType` statements onto the end of `block` /// for each ascription - fn ascribe_types<'pat>( + fn ascribe_types( &mut self, block: BasicBlock, ascriptions: &[Ascription<'tcx>], diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 0995a2f7fdf49..c767fff925322 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -463,7 +463,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// that it *doesn't* apply. For now, we return false, indicate that the /// test does not apply to this candidate, but it might be we can get /// tighter match code if we do something a bit different. - pub fn sort_candidate<'pat, 'cand>( + pub fn sort_candidate<'pat>( &mut self, test_place: &Place<'tcx>, test: &Test<'tcx>, diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index d806caf441513..4e13291c787da 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -315,7 +315,7 @@ struct FrameSnapshot<'a, 'tcx: 'a> { stmt: usize, } -impl_stable_hash_for!(impl<'mir, 'tcx: 'mir> for struct Frame<'mir, 'tcx> { +impl_stable_hash_for!(impl<> for struct Frame<'mir, 'tcx> { body, instance, span, @@ -422,7 +422,7 @@ impl<'a, 'mir, 'tcx> Hash for InterpSnapshot<'a, 'mir, 'tcx> } } -impl_stable_hash_for!(impl<'tcx, 'b, 'mir> for struct InterpSnapshot<'b, 'mir, 'tcx> { +impl_stable_hash_for!(impl<> for struct InterpSnapshot<'_, 'mir, 'tcx> { // Not hashing memory: Avoid hashing memory all the time during execution memory -> _, stack, diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 21704bf66e8d2..6768d9ec6bc19 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -81,7 +81,7 @@ pub struct RefTracking { pub todo: Vec<(T, Vec)>, } -impl<'tcx, T: Copy + Eq + Hash> RefTracking { +impl RefTracking { pub fn new(op: T) -> Self { let mut ref_tracking = RefTracking { seen: FxHashSet::default(), diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 53302810b4052..a7cbe84330d89 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -29,6 +29,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(explicit_outlives_requirements)] #[macro_use] extern crate log; diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index f084919ac057c..706ace0c1f1bc 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -907,7 +907,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -fn create_fn_mono_item<'a, 'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> { +fn create_fn_mono_item<'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> { debug!("create_fn_mono_item(instance={})", instance); MonoItem::Fn(instance) } diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 87581c530b9d7..b8077d224e4ef 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -32,7 +32,7 @@ pub struct UnsafetyChecker<'a, 'tcx: 'a> { inherited_blocks: Vec<(hir::HirId, bool)>, } -impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> { +impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { fn new( const_context: bool, min_const_fn: bool, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index d2c75ebe8d6aa..5ac8a41ffeeaf 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -829,14 +829,14 @@ fn create_generator_resume_function<'a, 'tcx>( dump_mir(tcx, None, "generator_resume", &0, source, body, |_, _| Ok(()) ); } -fn source_info<'a, 'tcx>(body: &Body<'tcx>) -> SourceInfo { +fn source_info<'tcx>(body: &Body<'tcx>) -> SourceInfo { SourceInfo { span: body.span, scope: OUTERMOST_SOURCE_SCOPE, } } -fn insert_clean_drop<'a, 'tcx>(body: &mut Body<'tcx>) -> BasicBlock { +fn insert_clean_drop<'tcx>(body: &mut Body<'tcx>) -> BasicBlock { let return_block = insert_term_block(body, TerminatorKind::Return); // Create a block to destroy an unresumed generators. This can only destroy upvars. diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index f1ca93ec13ffa..4d1c90bc56d9e 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -323,7 +323,7 @@ impl MirPass for SimplifyLocals { } /// Construct the mapping while swapping out unused stuff out from the `vec`. -fn make_local_map<'tcx, V>( +fn make_local_map( vec: &mut IndexVec, mask: BitSet, ) -> IndexVec> { diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 6d761525639bd..0fbf8bb3e273a 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -147,7 +147,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> // // FIXME: I think we should just control the flags externally, // and then we do not need this machinery. - pub fn elaborate_drop<'a>(&mut self, bb: BasicBlock) { + pub fn elaborate_drop(&mut self, bb: BasicBlock) { debug!("elaborate_drop({:?})", self); let style = self.elaborator.drop_style(self.path, DropFlagMode::Deep); debug!("elaborate_drop({:?}): live - {:?}", self, style); @@ -285,7 +285,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> /// /// NOTE: this does not clear the master drop flag, so you need /// to point succ/unwind on a `drop_ladder_bottom`. - fn drop_ladder<'a>(&mut self, + fn drop_ladder(&mut self, fields: Vec<(Place<'tcx>, Option)>, succ: BasicBlock, unwind: Unwind) @@ -314,7 +314,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> (*normal_ladder.last().unwrap(), *unwind_ladder.last().unwrap()) } - fn open_drop_for_tuple<'a>(&mut self, tys: &[Ty<'tcx>]) + fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock { debug!("open_drop_for_tuple({:?}, {:?})", self, tys); @@ -328,7 +328,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_ladder(fields, succ, unwind).0 } - fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) + fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs); @@ -346,7 +346,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_subpath(&interior, interior_path, succ, unwind_succ) } - fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) + fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs); if adt.variants.len() == 0 { @@ -505,7 +505,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_flag_test_block(switch_block, succ, unwind) } - fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind)) + fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock { debug!("destructor_call_block({:?}, {:?})", self, succ); @@ -787,7 +787,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> /// /// This creates a "drop ladder" that drops the needed fields of the /// ADT, both in the success case or if one of the destructors fail. - fn open_drop<'a>(&mut self) -> BasicBlock { + fn open_drop(&mut self) -> BasicBlock { let ty = self.place_ty(self.place); match ty.sty { ty::Closure(def_id, substs) => { @@ -837,7 +837,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> /// if FLAG(self.path) /// if let Some(mode) = mode: FLAG(self.path)[mode] = false /// drop(self.place) - fn complete_drop<'a>(&mut self, + fn complete_drop(&mut self, drop_mode: Option, succ: BasicBlock, unwind: Unwind) -> BasicBlock @@ -867,7 +867,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> block } - fn elaborated_drop_block<'a>(&mut self) -> BasicBlock { + fn elaborated_drop_block(&mut self) -> BasicBlock { debug!("elaborated_drop_block({:?})", self); let unwind = self.unwind; // FIXME(#43234) let succ = self.succ; @@ -876,7 +876,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> blk } - fn box_free_block<'a>( + fn box_free_block( &mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, @@ -887,7 +887,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_flag_test_block(block, target, unwind) } - fn unelaborated_free_block<'a>( + fn unelaborated_free_block( &mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, @@ -917,7 +917,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> free_block } - fn drop_block<'a>(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { + fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { let block = TerminatorKind::Drop { location: self.place.clone(), target, @@ -947,7 +947,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } } - fn new_block<'a>(&mut self, + fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 8bc43b6107461..82ec5ab5f8a6a 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -109,7 +109,7 @@ pub enum DefUse { Drop, } -pub fn categorize<'tcx>(context: PlaceContext) -> Option { +pub fn categorize(context: PlaceContext) -> Option { match context { /////////////////////////////////////////////////////////////////////////// // DEFS From 8dddfde6e3971437ff43e5f9fb6c424951c1fca2 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:47:56 +0300 Subject: [PATCH 07/12] rustc_traits: deny(unused_lifetimes). --- src/librustc_traits/chalk_context/mod.rs | 2 +- src/librustc_traits/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 96c647ca31e6f..bf61a558a46f6 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -575,7 +575,7 @@ impl ExClauseFold<'tcx> for ChalkArenas<'tcx> { } } - fn visit_ex_clause_with<'gcx: 'tcx, V: TypeVisitor<'tcx>>( + fn visit_ex_clause_with>( ex_clause: &ExClause, visitor: &mut V, ) -> bool { diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index 959130f1cf228..7311fd96dadc7 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -3,6 +3,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] From 7b353f215f75309d2ce28449efa9654ffe33df8c Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:48:58 +0300 Subject: [PATCH 08/12] rustc_borrowck: deny(unused_lifetimes). --- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_borrowck/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 7dca47485bb92..669fb9103aaaa 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1487,7 +1487,7 @@ impl DataFlowOperator for LoanDataFlowOperator { } } -impl<'tcx> fmt::Debug for InteriorKind { +impl fmt::Debug for InteriorKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { InteriorField(mc::FieldIndex(_, info)) => write!(f, "{}", info), diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 14bc77f380acc..5d8b0cd14dd27 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -3,6 +3,7 @@ #![allow(non_camel_case_types)] #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(nll)] From 8ee1814062b4acfe11abb312c55a092ca694aef9 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:49:10 +0300 Subject: [PATCH 09/12] rustc_codegen_*: deny(unused_lifetimes). --- src/librustc_codegen_llvm/asm.rs | 2 +- src/librustc_codegen_llvm/builder.rs | 4 ++-- src/librustc_codegen_ssa/lib.rs | 1 + src/librustc_codegen_ssa/mir/analyze.rs | 2 +- src/librustc_codegen_ssa/mir/block.rs | 2 +- src/librustc_codegen_ssa/traits/asm.rs | 2 +- src/librustc_codegen_ssa/traits/builder.rs | 2 +- src/librustc_codegen_ssa/traits/mod.rs | 4 ++-- src/librustc_codegen_ssa/traits/statics.rs | 2 +- src/librustc_codegen_ssa/traits/type_.rs | 2 +- src/librustc_codegen_utils/lib.rs | 1 + 11 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 100a896ea0c7d..81acc16b7abec 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -112,7 +112,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { } } -impl AsmMethods<'tcx> for CodegenCx<'ll, 'tcx> { +impl AsmMethods for CodegenCx<'ll, 'tcx> { fn codegen_global_asm(&self, ga: &hir::GlobalAsm) { let asm = CString::new(ga.asm.as_str().as_bytes()).unwrap(); unsafe { diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 102e9e38612e0..982156321aa15 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -1074,8 +1074,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { } } -impl StaticBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { -fn get_static(&mut self, def_id: DefId) -> &'ll Value { +impl StaticBuilderMethods for Builder<'a, 'll, 'tcx> { + fn get_static(&mut self, def_id: DefId) -> &'ll Value { // Forward to the `get_static` method of `CodegenCx` self.cx().get_static(def_id) } diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 97de0d823b322..71393e224e42d 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -14,6 +14,7 @@ #![allow(dead_code)] #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(explicit_outlives_requirements)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index bb6a13ed15a52..e2fd1c2bc38e7 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -272,7 +272,7 @@ impl CleanupKind { } } -pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Body<'tcx>) -> IndexVec { +pub fn cleanup_kinds<'tcx>(mir: &mir::Body<'tcx>) -> IndexVec { fn discover_masters<'tcx>(result: &mut IndexVec, mir: &mir::Body<'tcx>) { for (bb, data) in mir.basic_blocks().iter_enumerated() { diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 7e5ee25d8ef78..07bfd5653ce15 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -223,7 +223,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - fn codegen_return_terminator<'b>( + fn codegen_return_terminator( &mut self, mut bx: Bx, ) { diff --git a/src/librustc_codegen_ssa/traits/asm.rs b/src/librustc_codegen_ssa/traits/asm.rs index a95bf3af5bf27..fd3c868bbc507 100644 --- a/src/librustc_codegen_ssa/traits/asm.rs +++ b/src/librustc_codegen_ssa/traits/asm.rs @@ -12,6 +12,6 @@ pub trait AsmBuilderMethods<'tcx>: BackendTypes { ) -> bool; } -pub trait AsmMethods<'tcx> { +pub trait AsmMethods { fn codegen_global_asm(&self, ga: &GlobalAsm); } diff --git a/src/librustc_codegen_ssa/traits/builder.rs b/src/librustc_codegen_ssa/traits/builder.rs index a11d1ba9231cc..2af57bcb064b7 100644 --- a/src/librustc_codegen_ssa/traits/builder.rs +++ b/src/librustc_codegen_ssa/traits/builder.rs @@ -29,7 +29,7 @@ pub trait BuilderMethods<'a, 'tcx: 'a>: + AbiBuilderMethods<'tcx> + IntrinsicCallMethods<'tcx> + AsmBuilderMethods<'tcx> - + StaticBuilderMethods<'tcx> + + StaticBuilderMethods + HasParamEnv<'tcx> + HasTargetSpec diff --git a/src/librustc_codegen_ssa/traits/mod.rs b/src/librustc_codegen_ssa/traits/mod.rs index 2bb619e79f5e0..efe4a25570104 100644 --- a/src/librustc_codegen_ssa/traits/mod.rs +++ b/src/librustc_codegen_ssa/traits/mod.rs @@ -58,7 +58,7 @@ pub trait CodegenMethods<'tcx>: + StaticMethods + DebugInfoMethods<'tcx> + DeclareMethods<'tcx> - + AsmMethods<'tcx> + + AsmMethods + PreDefineMethods<'tcx> + HasParamEnv<'tcx> + HasTyCtxt<'tcx> @@ -74,7 +74,7 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where + StaticMethods + DebugInfoMethods<'tcx> + DeclareMethods<'tcx> - + AsmMethods<'tcx> + + AsmMethods + PreDefineMethods<'tcx> + HasParamEnv<'tcx> + HasTyCtxt<'tcx> diff --git a/src/librustc_codegen_ssa/traits/statics.rs b/src/librustc_codegen_ssa/traits/statics.rs index d8992c159337d..6983311d797dc 100644 --- a/src/librustc_codegen_ssa/traits/statics.rs +++ b/src/librustc_codegen_ssa/traits/statics.rs @@ -8,7 +8,7 @@ pub trait StaticMethods: BackendTypes { fn codegen_static(&self, def_id: DefId, is_mutable: bool); } -pub trait StaticBuilderMethods<'tcx>: BackendTypes { +pub trait StaticBuilderMethods: BackendTypes { fn get_static(&mut self, def_id: DefId) -> Self::Value; fn static_panic_msg( &mut self, diff --git a/src/librustc_codegen_ssa/traits/type_.rs b/src/librustc_codegen_ssa/traits/type_.rs index efc18d401c082..aa38d8d51848d 100644 --- a/src/librustc_codegen_ssa/traits/type_.rs +++ b/src/librustc_codegen_ssa/traits/type_.rs @@ -101,7 +101,7 @@ pub trait LayoutTypeMethods<'tcx>: Backend<'tcx> { fn is_backend_immediate(&self, layout: TyLayout<'tcx>) -> bool; fn is_backend_scalar_pair(&self, layout: TyLayout<'tcx>) -> bool; fn backend_field_index(&self, layout: TyLayout<'tcx>, index: usize) -> u64; - fn scalar_pair_element_backend_type<'a>( + fn scalar_pair_element_backend_type( &self, layout: TyLayout<'tcx>, index: usize, diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 38d1719e7763e..3726e4f47b96b 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -18,6 +18,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[macro_use] extern crate rustc; From 4a219685ffd622421e5eb9609dda7a8508a478c6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:50:17 +0300 Subject: [PATCH 10/12] rustdoc: deny(unused_lifetimes). --- src/librustdoc/clean/auto_trait.rs | 2 +- src/librustdoc/clean/mod.rs | 10 +++++----- src/librustdoc/html/render.rs | 2 +- src/librustdoc/lib.rs | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 60d6c33f81afc..7b58312a5edef 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -341,7 +341,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .collect() } - fn make_final_bounds<'b, 'c, 'cx>( + fn make_final_bounds( &self, ty_to_bounds: FxHashMap>, ty_to_fn: FxHashMap, Option)>, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a717ef20a8444..e44c35b55ffad 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1298,7 +1298,7 @@ impl Clean for hir::ConstArg { } } -impl<'tcx> Clean for ty::GenericParamDef { +impl Clean for ty::GenericParamDef { fn clean(&self, _cx: &DocContext<'_>) -> Lifetime { Lifetime(self.name.to_string()) } @@ -2039,7 +2039,7 @@ impl<'a, A: Copy> Clean for (&'a hir::FnDecl, A) } } -impl<'a, 'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { +impl<'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { fn clean(&self, cx: &DocContext<'_>) -> FnDecl { let (did, sig) = *self; let mut names = if cx.tcx.hir().as_local_hir_id(did).is_some() { @@ -2276,7 +2276,7 @@ impl Clean for hir::ImplItem { } } -impl<'tcx> Clean for ty::AssocItem { +impl Clean for ty::AssocItem { fn clean(&self, cx: &DocContext<'_>) -> Item { let inner = match self.kind { ty::AssocKind::Const => { @@ -3174,7 +3174,7 @@ impl Clean for hir::StructField { } } -impl<'tcx> Clean for ty::FieldDef { +impl Clean for ty::FieldDef { fn clean(&self, cx: &DocContext<'_>) -> Item { Item { name: Some(self.ident.name).clean(cx), @@ -3342,7 +3342,7 @@ impl Clean for doctree::Variant { } } -impl<'tcx> Clean for ty::VariantDef { +impl Clean for ty::VariantDef { fn clean(&self, cx: &DocContext<'_>) -> Item { let kind = match self.ctor_kind { CtorKind::Const => VariantKind::CLike, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 3555e2e7498b8..362706820593e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1764,7 +1764,7 @@ impl DocFolder for Cache { } } -impl<'a> Cache { +impl Cache { fn generics(&mut self, generics: &clean::Generics) { for param in &generics.params { match param.kind { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ffe277ae50bdc..3b4d65352a34c 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,5 +1,6 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] From 630ec8880cc2941a3fd178a27934dff0d46b8155 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 12:50:47 +0300 Subject: [PATCH 11/12] Add deny(unused_lifetimes) to all the crates that have deny(internal). --- src/libarena/lib.rs | 1 + src/libfmt_macros/lib.rs | 1 + src/librustc_allocator/lib.rs | 1 + src/librustc_driver/lib.rs | 1 + src/librustc_errors/lib.rs | 1 + src/librustc_interface/lib.rs | 1 + src/librustc_metadata/lib.rs | 1 + src/librustc_passes/lib.rs | 1 + src/librustc_privacy/lib.rs | 1 + src/librustc_resolve/lib.rs | 1 + src/librustc_save_analysis/lib.rs | 1 + src/librustc_typeck/lib.rs | 1 + src/libsyntax/lib.rs | 1 + src/libsyntax_pos/lib.rs | 1 + 14 files changed, 14 insertions(+) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index d6bec816e4ee6..1739b2236e89d 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -13,6 +13,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 6fed83021609d..1000f237e8432 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -10,6 +10,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(nll)] #![feature(rustc_private)] diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index 3aef5a76a3a05..e7a70895a3023 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -3,6 +3,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] pub mod expand; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 02f8eee67b151..5fb6ed31b0693 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -18,6 +18,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] pub extern crate getopts; #[cfg(unix)] diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index cc3180c783bdf..27bd30e8afd89 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -6,6 +6,7 @@ #![feature(optin_builtin_traits)] #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs index d1e2a1a4ad506..7fc311d40c3d0 100644 --- a/src/librustc_interface/lib.rs +++ b/src/librustc_interface/lib.rs @@ -8,6 +8,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(unused_imports)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index e0b92341575cc..e49ca8acf6702 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -16,6 +16,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] extern crate libc; #[allow(unused_extern_crates)] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 7c48feecb2110..fbd6ddf84c33a 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -13,6 +13,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #[macro_use] extern crate rustc; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 6d01328cd16e6..42b70dd181b3c 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -2,6 +2,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(nll)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 18f3c0285c210..fec7bf3b273ee 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -12,6 +12,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] pub use rustc::hir::def::{Namespace, PerNS}; diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index cda6b60b76790..30b0250cec182 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -2,6 +2,7 @@ #![feature(nll)] #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(unused_attributes)] #![recursion_limit="256"] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 30993b86a385f..14dec423c57a9 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -72,6 +72,7 @@ This API is completely unstable and subject to change. #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![allow(explicit_outlives_requirements)] #[macro_use] extern crate log; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c69364d4e19bb..55db8da327673 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -9,6 +9,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(bind_by_move_pattern_guards)] #![feature(crate_visibility_modifier)] diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 8f5595968a738..649ab81198d2a 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -8,6 +8,7 @@ #![deny(rust_2018_idioms)] #![deny(internal)] +#![deny(unused_lifetimes)] #![feature(const_fn)] #![feature(crate_visibility_modifier)] From 1d720ec27c5bdbc377145b8a29c1d727fb7131d6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 11 Jun 2019 13:20:33 +0300 Subject: [PATCH 12/12] Run `rustfmt --file-lines ...` for changes from previous commits. --- src/librustc/hir/map/collector.rs | 3 +- src/librustc/ich/hcx.rs | 5 ++- src/librustc/ich/impls_ty.rs | 21 ++++------ src/librustc/traits/select.rs | 5 +-- src/librustc/ty/fast_reject.rs | 4 +- src/librustc/ty/instance.rs | 8 ++-- src/librustc/ty/layout.rs | 7 ++-- src/librustc/ty/mod.rs | 3 +- src/librustc_codegen_ssa/mir/block.rs | 5 +-- src/librustc_lint/types.rs | 6 +-- src/librustc_mir/build/matches/mod.rs | 6 +-- src/librustc_mir/util/elaborate_drops.rs | 49 ++++++++++-------------- src/libsyntax_ext/cfg.rs | 9 +++-- 13 files changed, 54 insertions(+), 77 deletions(-) diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 532e61721ca45..8a59f6b69bcd6 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -590,7 +590,8 @@ struct HirItemLike { } impl<'hir, T> HashStable> for HirItemLike - where T: HashStable> +where + T: HashStable>, { fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 8454eb75b55c7..eff42efa67b92 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -397,8 +397,9 @@ pub fn hash_stable_trait_impls<'a, W>( hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher, blanket_impls: &[DefId], - non_blanket_impls: &FxHashMap>) - where W: StableHasherResult + non_blanket_impls: &FxHashMap>, +) where + W: StableHasherResult, { { let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index c2c0ced07e695..89e79c56ca39d 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -136,7 +136,8 @@ impl<'gcx> HashStable> for ty::BoundVar { } impl<'a, T> HashStable> for ty::Binder - where T: HashStable> +where + T: HashStable>, { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, @@ -192,9 +193,7 @@ impl<'a> ToStableHashKey> for region::Scope { } } -impl<'a> HashStable> -for ty::TyVid -{ +impl<'a> HashStable> for ty::TyVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { @@ -204,9 +203,7 @@ for ty::TyVid } } -impl<'a> HashStable> -for ty::IntVid -{ +impl<'a> HashStable> for ty::IntVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { @@ -216,9 +213,7 @@ for ty::IntVid } } -impl<'a> HashStable> -for ty::FloatVid -{ +impl<'a> HashStable> for ty::FloatVid { fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { @@ -228,9 +223,9 @@ for ty::FloatVid } } -impl<'a, T> HashStable> -for ty::steal::Steal - where T: HashStable> +impl<'a, T> HashStable> for ty::steal::Steal +where + T: HashStable>, { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index c637fc27cc0ca..af0b51e637a36 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -104,10 +104,7 @@ pub enum IntercrateAmbiguityCause { impl IntercrateAmbiguityCause { /// Emits notes when the overlap is caused by complex intercrate ambiguities. /// See #23980 for details. - pub fn add_intercrate_ambiguity_hint( - &self, - err: &mut errors::DiagnosticBuilder<'_>, - ) { + pub fn add_intercrate_ambiguity_hint(&self, err: &mut errors::DiagnosticBuilder<'_>) { err.note(&self.intercrate_ambiguity_hint()); } diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 3ac76c384e605..908bbbcd1d77d 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -155,8 +155,8 @@ impl SimplifiedTypeGen { } impl<'a, D> HashStable> for SimplifiedTypeGen - where D: Copy + Debug + Ord + Eq + Hash + - HashStable>, +where + D: Copy + Debug + Ord + Eq + Hash + HashStable>, { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index cee1359eb366b..ba42cecbe5b83 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -442,10 +442,10 @@ fn resolve_associated_item<'a, 'tcx>( } } -fn needs_fn_once_adapter_shim(actual_closure_kind: ty::ClosureKind, - trait_closure_kind: ty::ClosureKind) - -> Result -{ +fn needs_fn_once_adapter_shim( + actual_closure_kind: ty::ClosureKind, + trait_closure_kind: ty::ClosureKind, +) -> Result { match (actual_closure_kind, trait_closure_kind) { (ty::ClosureKind::Fn, ty::ClosureKind::Fn) | (ty::ClosureKind::FnMut, ty::ClosureKind::FnMut) | diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 879d03352e654..4696325275292 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1679,9 +1679,10 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> { } impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> - where C: LayoutOf> + HasTyCtxt<'tcx>, - C::TyLayout: MaybeResult>, - C: HasParamEnv<'tcx> +where + C: LayoutOf> + HasTyCtxt<'tcx>, + C::TyLayout: MaybeResult>, + C: HasParamEnv<'tcx>, { fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> { let details = match this.variants { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index aafc510f5b6ed..c46e9c4be366c 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1615,7 +1615,8 @@ pub struct Placeholder { } impl<'a, T> HashStable> for Placeholder - where T: HashStable> +where + T: HashStable>, { fn hash_stable( &self, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 07bfd5653ce15..e4b82d8496669 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -223,10 +223,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - fn codegen_return_terminator( - &mut self, - mut bx: Bx, - ) { + fn codegen_return_terminator(&mut self, mut bx: Bx) { if self.fn_ty.c_variadic { match self.va_list_ref { Some(va_list) => { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 7c185ba7423ad..809586e246a35 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -202,11 +202,7 @@ fn report_bin_hex_error( // - `uX` => `uY` // // No suggestion for: `isize`, `usize`. -fn get_type_suggestion( - t: Ty<'_>, - val: u128, - negative: bool, -) -> Option { +fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option { use syntax::ast::IntTy::*; use syntax::ast::UintTy::*; macro_rules! find_fit { diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index fbb6161e8fe5b..0aabebcf9dc2c 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1575,11 +1575,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { /// Append `AscribeUserType` statements onto the end of `block` /// for each ascription - fn ascribe_types( - &mut self, - block: BasicBlock, - ascriptions: &[Ascription<'tcx>], - ) { + fn ascribe_types(&mut self, block: BasicBlock, ascriptions: &[Ascription<'tcx>]) { for ascription in ascriptions { let source_info = self.source_info(ascription.span); diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 0fbf8bb3e273a..b8ce31d0adfdc 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -119,7 +119,8 @@ pub fn elaborate_drop<'b, 'tcx, D>( } impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> - where D: DropElaborator<'b, 'tcx> +where + D: DropElaborator<'b, 'tcx>, { fn place_ty(&self, place: &Place<'tcx>) -> Ty<'tcx> { place.ty(self.elaborator.body(), self.tcx()).ty @@ -285,12 +286,12 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> /// /// NOTE: this does not clear the master drop flag, so you need /// to point succ/unwind on a `drop_ladder_bottom`. - fn drop_ladder(&mut self, - fields: Vec<(Place<'tcx>, Option)>, - succ: BasicBlock, - unwind: Unwind) - -> (BasicBlock, Unwind) - { + fn drop_ladder( + &mut self, + fields: Vec<(Place<'tcx>, Option)>, + succ: BasicBlock, + unwind: Unwind, + ) -> (BasicBlock, Unwind) { debug!("drop_ladder({:?}, {:?})", self, fields); let mut fields = fields; @@ -314,9 +315,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> (*normal_ladder.last().unwrap(), *unwind_ladder.last().unwrap()) } - fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) - -> BasicBlock - { + fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock { debug!("open_drop_for_tuple({:?}, {:?})", self, tys); let fields = tys.iter().enumerate().map(|(i, &ty)| { @@ -328,9 +327,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_ladder(fields, succ, unwind).0 } - fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) - -> BasicBlock - { + fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs); let interior = self.place.clone().deref(); @@ -346,8 +343,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_subpath(&interior, interior_path, succ, unwind_succ) } - fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) - -> BasicBlock { + fn open_drop_for_adt(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock { debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs); if adt.variants.len() == 0 { return self.elaborator.patch().new_block(BasicBlockData { @@ -505,9 +501,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.drop_flag_test_block(switch_block, succ, unwind) } - fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) - -> BasicBlock - { + fn destructor_call_block(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock { debug!("destructor_call_block({:?}, {:?})", self, succ); let tcx = self.tcx(); let drop_trait = tcx.lang_items().drop_trait().unwrap(); @@ -837,11 +831,12 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> /// if FLAG(self.path) /// if let Some(mode) = mode: FLAG(self.path)[mode] = false /// drop(self.place) - fn complete_drop(&mut self, - drop_mode: Option, - succ: BasicBlock, - unwind: Unwind) -> BasicBlock - { + fn complete_drop( + &mut self, + drop_mode: Option, + succ: BasicBlock, + unwind: Unwind, + ) -> BasicBlock { debug!("complete_drop({:?},{:?})", self, drop_mode); let drop_block = self.drop_block(succ, unwind); @@ -892,7 +887,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>, target: BasicBlock, - unwind: Unwind + unwind: Unwind, ) -> BasicBlock { let tcx = self.tcx(); let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit()))); @@ -947,11 +942,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } } - fn new_block(&mut self, - unwind: Unwind, - k: TerminatorKind<'tcx>) - -> BasicBlock - { + fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock { self.elaborator.patch().new_block(BasicBlockData { statements: vec![], terminator: Some(Terminator { diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 3b49f218811ad..e952515bfe0eb 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -12,10 +12,11 @@ use syntax::tokenstream; use syntax::parse::token; use syntax_pos::Span; -pub fn expand_cfg(cx: &mut ExtCtxt<'_>, - sp: Span, - tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_cfg( + cx: &mut ExtCtxt<'_>, + sp: Span, + tts: &[tokenstream::TokenTree], +) -> Box { let sp = sp.apply_mark(cx.current_expansion.mark); match parse_cfg(cx, sp, tts) {