rustc: deny(unused_lifetimes).

This commit is contained in:
Eduard-Mihai Burtescu 2019-06-11 12:21:38 +03:00
parent ce0ba38921
commit 774724be3c
24 changed files with 46 additions and 39 deletions

View file

@ -589,7 +589,7 @@ struct HirItemLike<T> {
hash_bodies: bool,
}
impl<'a, 'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
impl<'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
where T: HashStable<StableHashingContext<'hir>>
{
fn hash_stable<W: StableHasherResult>(&self,

View file

@ -393,7 +393,7 @@ impl<'a> HashStable<StableHashingContext<'a>> 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<W>,
blanket_impls: &[DefId],

View file

@ -135,7 +135,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
}
}
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
where T: HashStable<StableHashingContext<'a>>
{
fn hash_stable<W: StableHasherResult>(&self,
@ -192,7 +192,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {
}
}
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
impl<'a> HashStable<StableHashingContext<'a>>
for ty::TyVid
{
fn hash_stable<W: StableHasherResult>(&self,
@ -204,7 +204,7 @@ for ty::TyVid
}
}
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
impl<'a> HashStable<StableHashingContext<'a>>
for ty::IntVid
{
fn hash_stable<W: StableHasherResult>(&self,
@ -216,7 +216,7 @@ for ty::IntVid
}
}
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
impl<'a> HashStable<StableHashingContext<'a>>
for ty::FloatVid
{
fn hash_stable<W: StableHasherResult>(&self,
@ -228,7 +228,7 @@ for ty::FloatVid
}
}
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
impl<'a, T> HashStable<StableHashingContext<'a>>
for ty::steal::Steal<T>
where T: HashStable<StableHashingContext<'a>>
{

View file

@ -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,

View file

@ -30,6 +30,7 @@
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![allow(explicit_outlives_requirements)]
#![feature(arbitrary_self_types)]

View file

@ -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.

View file

@ -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<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
impl HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
{
#[inline]
fn hash_stable<W: StableHasherResult>(&self,

View file

@ -105,7 +105,7 @@ impl From<AllocId> for Pointer {
}
}
impl<'tcx> Pointer<()> {
impl Pointer<()> {
#[inline(always)]
pub fn new(alloc_id: AllocId, offset: Size) -> Self {
Pointer { alloc_id, offset, tag: () }

View file

@ -146,7 +146,7 @@ impl<Tag> From<Double> for Scalar<Tag> {
}
}
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,

View file

@ -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 {

View file

@ -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();
$({

View file

@ -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,

View file

@ -1191,7 +1191,7 @@ where
folder: &mut F,
) -> chalk_engine::ExClause<Self>;
fn visit_ex_clause_with<'gcx: 'tcx, V: TypeVisitor<'tcx>>(
fn visit_ex_clause_with<V: TypeVisitor<'tcx>>(
ex_clause: &chalk_engine::ExClause<Self>,
visitor: &mut V,
) -> bool;

View file

@ -145,7 +145,7 @@ BraceStructLiftImpl! {
}
impl_stable_hash_for! {
impl<'tcx, T> for struct Normalize<T> {
impl<T> for struct Normalize<T> {
value
}
}

View file

@ -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>,

View file

@ -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<N> {
impl<N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
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<N> {
impl<N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,

View file

@ -154,7 +154,7 @@ impl<D: Copy + Debug + Ord + Eq + Hash> SimplifiedTypeGen<D> {
}
}
impl<'a, 'gcx, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
impl<'a, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
where D: Copy + Debug + Ord + Eq + Hash +
HashStable<StableHashingContext<'a>>,
{

View file

@ -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<bool, ()>
{

View file

@ -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<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
C: HasParamEnv<'tcx>

View file

@ -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<T> {
pub name: T,
}
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
impl<'a, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
where T: HashStable<StableHashingContext<'a>>
{
fn hash_stable<W: StableHasherResult>(

View file

@ -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;

View file

@ -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;

View file

@ -886,7 +886,7 @@ impl<T> Binder<T> {
}
/// Wraps `value` in a binder, binding higher-ranked vars (if any).
pub fn bind<'tcx>(value: T) -> Binder<T> {
pub fn bind(value: T) -> Binder<T> {
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(

View file

@ -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 { }