diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index e66fa13f4fca..532e61721ca4 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 8be610e8bf7a..8454eb75b55c 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 563948a63514..c2c0ced07e69 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 ca766ea724f3..b6fe57636e90 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 920f97805439..e2f2799d9634 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 c5c6c4b94470..b51257c52060 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 f8d7a5e29f6f..b4088201f3bf 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 a6c47ff5ca0f..26002a411d4b 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 23c37676f365..f7b3385668f7 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 b4acc076f3e4..babce812d4a3 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 003fdd501a35..6a03aa64d26d 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 7505b3c1be84..9ce35d15d3c3 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 c135b0b759c6..fd2d8fd0661a 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 e3d7a4d57a56..594f55e52f8e 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 7810d65e88cc..c637fc27cc0c 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 4d382d6c45a7..f6108f2a2869 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 59ab4561f2c8..3ac76c384e60 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 f0251917074d..cee1359eb366 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 8e2c3dd3d8ad..879d03352e65 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 69bf05c66f39..aafc510f5b6e 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 a7cb7bd3956f..d6bc4e537581 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 0eda92ea8b82..286894c82b7e 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 5cc46b21fca1..abde4d6de2ae 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 09d576b23c0f..dee9a7c3f4a7 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 { }