Skip to content

Commit 5f3656c

Browse files
committed
Auto merge of #61735 - eddyb:must-use-life, r=oli-obk
Add deny(unused_lifetimes) to all the crates that have deny(internal). @Zoxc brought up, regarding #61722, that we don't force the removal of unused lifetimes. Turns out that it's not that bad to enable for compiler crates (I wonder why it's not `warn` by default?). I would've liked to enable `single_use_lifetimes` as well, but #53738 makes it unusable for now. For the `rustfmt` commit, I used rust-lang/rustfmt#1324 (comment), and manually filtered out some noise. r? @oli-obk cc @rust-lang/compiler
2 parents 8e948df + 1d720ec commit 5f3656c

File tree

79 files changed

+159
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+159
-151
lines changed

src/libarena/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#![deny(rust_2018_idioms)]
1515
#![deny(internal)]
16+
#![deny(unused_lifetimes)]
1617

1718
#![feature(core_intrinsics)]
1819
#![feature(dropck_eyepatch)]

src/libfmt_macros/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![deny(rust_2018_idioms)]
1212
#![deny(internal)]
13+
#![deny(unused_lifetimes)]
1314

1415
#![feature(nll)]
1516
#![feature(rustc_private)]

src/librustc/hir/map/collector.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,9 @@ struct HirItemLike<T> {
589589
hash_bodies: bool,
590590
}
591591

592-
impl<'a, 'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
593-
where T: HashStable<StableHashingContext<'hir>>
592+
impl<'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
593+
where
594+
T: HashStable<StableHashingContext<'hir>>,
594595
{
595596
fn hash_stable<W: StableHasherResult>(&self,
596597
hcx: &mut StableHashingContext<'hir>,

src/librustc/ich/hcx.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for DelimSpan {
393393
}
394394
}
395395

396-
pub fn hash_stable_trait_impls<'a, 'gcx, W>(
396+
pub fn hash_stable_trait_impls<'a, W>(
397397
hcx: &mut StableHashingContext<'a>,
398398
hasher: &mut StableHasher<W>,
399399
blanket_impls: &[DefId],
400-
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>)
401-
where W: StableHasherResult
400+
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>,
401+
) where
402+
W: StableHasherResult,
402403
{
403404
{
404405
let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls

src/librustc/ich/impls_ty.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
135135
}
136136
}
137137

138-
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
139-
where T: HashStable<StableHashingContext<'a>>
138+
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
139+
where
140+
T: HashStable<StableHashingContext<'a>>,
140141
{
141142
fn hash_stable<W: StableHasherResult>(&self,
142143
hcx: &mut StableHashingContext<'a>,
@@ -192,9 +193,7 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {
192193
}
193194
}
194195

195-
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
196-
for ty::TyVid
197-
{
196+
impl<'a> HashStable<StableHashingContext<'a>> for ty::TyVid {
198197
fn hash_stable<W: StableHasherResult>(&self,
199198
_hcx: &mut StableHashingContext<'a>,
200199
_hasher: &mut StableHasher<W>) {
@@ -204,9 +203,7 @@ for ty::TyVid
204203
}
205204
}
206205

207-
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
208-
for ty::IntVid
209-
{
206+
impl<'a> HashStable<StableHashingContext<'a>> for ty::IntVid {
210207
fn hash_stable<W: StableHasherResult>(&self,
211208
_hcx: &mut StableHashingContext<'a>,
212209
_hasher: &mut StableHasher<W>) {
@@ -216,9 +213,7 @@ for ty::IntVid
216213
}
217214
}
218215

219-
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
220-
for ty::FloatVid
221-
{
216+
impl<'a> HashStable<StableHashingContext<'a>> for ty::FloatVid {
222217
fn hash_stable<W: StableHasherResult>(&self,
223218
_hcx: &mut StableHashingContext<'a>,
224219
_hasher: &mut StableHasher<W>) {
@@ -228,9 +223,9 @@ for ty::FloatVid
228223
}
229224
}
230225

231-
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
232-
for ty::steal::Steal<T>
233-
where T: HashStable<StableHashingContext<'a>>
226+
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::steal::Steal<T>
227+
where
228+
T: HashStable<StableHashingContext<'a>>,
234229
{
235230
fn hash_stable<W: StableHasherResult>(&self,
236231
hcx: &mut StableHashingContext<'a>,

src/librustc/infer/region_constraints/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
858858
}
859859
}
860860

861-
impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
861+
impl<'tcx> VerifyBound<'tcx> {
862862
pub fn must_hold(&self) -> bool {
863863
match self {
864864
VerifyBound::IfEq(..) => false,

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#![deny(rust_2018_idioms)]
3232
#![deny(internal)]
33+
#![deny(unused_lifetimes)]
3334
#![allow(explicit_outlives_requirements)]
3435

3536
#![feature(arbitrary_self_types)]

src/librustc/lint/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl LintPassObject for EarlyLintPassObject {}
566566

567567
impl LintPassObject for LateLintPassObject {}
568568

569-
pub trait LintContext<'tcx>: Sized {
569+
pub trait LintContext: Sized {
570570
type PassObject: LintPassObject;
571571

572572
fn sess(&self) -> &Session;
@@ -700,7 +700,7 @@ impl<'a, T: EarlyLintPass> EarlyContextAndPass<'a, T> {
700700
}
701701
}
702702

703-
impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
703+
impl LintContext for LateContext<'_, '_> {
704704
type PassObject = LateLintPassObject;
705705

706706
/// Gets the overall compiler `Session` object.
@@ -728,7 +728,7 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
728728
}
729729
}
730730

731-
impl<'a> LintContext<'a> for EarlyContext<'a> {
731+
impl LintContext for EarlyContext<'_> {
732732
type PassObject = EarlyLintPassObject;
733733

734734
/// Gets the overall compiler `Session` object.

src/librustc/macros.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ macro_rules! impl_stable_hash_for {
8080
// We want to use the enum name both in the `impl ... for $enum_name` as well as for
8181
// importing all the variants. Unfortunately it seems we have to take the name
8282
// twice for this purpose
83-
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?>
83+
(impl<$($T:ident),* $(,)?>
8484
for enum $enum_name:path
8585
[ $enum_path:path ]
8686
{
@@ -91,7 +91,7 @@ macro_rules! impl_stable_hash_for {
9191
$( { $($named_field:ident $(-> $named_delegate:tt)?),* } )?
9292
),* $(,)?
9393
}) => {
94-
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
94+
impl<$($T,)*>
9595
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>
9696
for $enum_name
9797
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
@@ -117,13 +117,13 @@ macro_rules! impl_stable_hash_for {
117117
// Structs
118118
(struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
119119
impl_stable_hash_for!(
120-
impl<'tcx> for struct $struct_name { $($field $(-> $delegate)?),* }
120+
impl<> for struct $struct_name { $($field $(-> $delegate)?),* }
121121
);
122122
};
123-
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?> for struct $struct_name:path {
123+
(impl<$($T:ident),* $(,)?> for struct $struct_name:path {
124124
$($field:ident $(-> $delegate:tt)?),* $(,)?
125125
}) => {
126-
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
126+
impl<$($T,)*>
127127
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
128128
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
129129
{
@@ -143,12 +143,12 @@ macro_rules! impl_stable_hash_for {
143143
// We cannot use normal parentheses here, the parser won't allow it
144144
(tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
145145
impl_stable_hash_for!(
146-
impl<'tcx> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
146+
impl<> for tuple_struct $struct_name { $($field $(-> $delegate)?),* }
147147
);
148148
};
149-
(impl<$($lt:lifetime $(: $lt_bound:lifetime)? ),* $(,)? $($T:ident),* $(,)?>
149+
(impl<$($T:ident),* $(,)?>
150150
for tuple_struct $struct_name:path { $($field:ident $(-> $delegate:tt)?),* $(,)? }) => {
151-
impl<'a, $($lt $(: $lt_bound)?,)* $($T,)*>
151+
impl<$($T,)*>
152152
::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>> for $struct_name
153153
where $($T: ::rustc_data_structures::stable_hasher::HashStable<$crate::ich::StableHashingContext<'a>>),*
154154
{
@@ -170,7 +170,7 @@ macro_rules! impl_stable_hash_for {
170170
macro_rules! impl_stable_hash_for_spanned {
171171
($T:path) => (
172172

173-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
173+
impl HashStable<StableHashingContext<'a>> for ::syntax::source_map::Spanned<$T>
174174
{
175175
#[inline]
176176
fn hash_stable<W: StableHasherResult>(&self,

src/librustc/mir/interpret/pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl From<AllocId> for Pointer {
105105
}
106106
}
107107

108-
impl<'tcx> Pointer<()> {
108+
impl Pointer<()> {
109109
#[inline(always)]
110110
pub fn new(alloc_id: AllocId, offset: Size) -> Self {
111111
Pointer { alloc_id, offset, tag: () }

0 commit comments

Comments
 (0)