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

+1
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

+1
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

+3-2
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

+4-3
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

+9-14
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

+1-1
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

+1
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

+3-3
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

+9-9
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

+1-1
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: () }

src/librustc/mir/interpret/value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<Tag> From<Double> for Scalar<Tag> {
146146
}
147147
}
148148

149-
impl<'tcx> Scalar<()> {
149+
impl Scalar<()> {
150150
#[inline(always)]
151151
fn check_data(data: u128, size: u8) {
152152
debug_assert_eq!(truncate(data, Size::from_bytes(size as u64)), data,

src/librustc/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ pub enum PlaceContext {
967967
NonUse(NonUseContext),
968968
}
969969

970-
impl<'tcx> PlaceContext {
970+
impl PlaceContext {
971971
/// Returns `true` if this place context represents a drop.
972972
pub fn is_drop(&self) -> bool {
973973
match *self {

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ macro_rules! options {
785785
return op;
786786
}
787787

788-
impl<'a> dep_tracking::DepTrackingHash for $struct_name {
788+
impl dep_tracking::DepTrackingHash for $struct_name {
789789
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
790790
let mut sub_hashes = BTreeMap::new();
791791
$({

src/librustc/traits/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
270270
// the final synthesized generics: we don't want our generated docs page to contain something
271271
// like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
272272
// 'user_env', which only holds the predicates that will actually be displayed to the user.
273-
fn evaluate_predicates<'b, 'gcx, 'c>(
273+
fn evaluate_predicates<'b, 'c>(
274274
&self,
275275
infcx: &InferCtxt<'b, 'tcx, 'c>,
276276
trait_did: DefId,

src/librustc/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ where
11911191
folder: &mut F,
11921192
) -> chalk_engine::ExClause<Self>;
11931193

1194-
fn visit_ex_clause_with<'gcx: 'tcx, V: TypeVisitor<'tcx>>(
1194+
fn visit_ex_clause_with<V: TypeVisitor<'tcx>>(
11951195
ex_clause: &chalk_engine::ExClause<Self>,
11961196
visitor: &mut V,
11971197
) -> bool;

src/librustc/traits/query/type_op/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ BraceStructLiftImpl! {
145145
}
146146

147147
impl_stable_hash_for! {
148-
impl<'tcx, T> for struct Normalize<T> {
148+
impl<T> for struct Normalize<T> {
149149
value
150150
}
151151
}

src/librustc/traits/select.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ pub enum IntercrateAmbiguityCause {
104104
impl IntercrateAmbiguityCause {
105105
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
106106
/// See #23980 for details.
107-
pub fn add_intercrate_ambiguity_hint<'a, 'tcx>(
108-
&self,
109-
err: &mut errors::DiagnosticBuilder<'_>,
110-
) {
107+
pub fn add_intercrate_ambiguity_hint(&self, err: &mut errors::DiagnosticBuilder<'_>) {
111108
err.note(&self.intercrate_ambiguity_hint());
112109
}
113110

@@ -2299,7 +2296,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22992296
/// candidates and prefer where-clause candidates.
23002297
///
23012298
/// See the comment for "SelectionCandidate" for more details.
2302-
fn candidate_should_be_dropped_in_favor_of<'o>(
2299+
fn candidate_should_be_dropped_in_favor_of(
23032300
&mut self,
23042301
victim: &EvaluatedCandidate<'tcx>,
23052302
other: &EvaluatedCandidate<'tcx>,
@@ -2423,7 +2420,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24232420
// These cover the traits that are built-in to the language
24242421
// itself: `Copy`, `Clone` and `Sized`.
24252422

2426-
fn assemble_builtin_bound_candidates<'o>(
2423+
fn assemble_builtin_bound_candidates(
24272424
&mut self,
24282425
conditions: BuiltinImplConditions<'tcx>,
24292426
candidates: &mut SelectionCandidateSet<'tcx>,

src/librustc/traits/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
9090
}
9191
}
9292

93-
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
93+
impl<N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
9494
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9595
write!(f, "VtableBuiltinData(nested={:?})", self.nested)
9696
}
9797
}
9898

99-
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
99+
impl<N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
100100
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
101101
write!(
102102
f,

src/librustc/ty/fast_reject.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ impl<D: Copy + Debug + Ord + Eq + Hash> SimplifiedTypeGen<D> {
154154
}
155155
}
156156

157-
impl<'a, 'gcx, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
158-
where D: Copy + Debug + Ord + Eq + Hash +
159-
HashStable<StableHashingContext<'a>>,
157+
impl<'a, D> HashStable<StableHashingContext<'a>> for SimplifiedTypeGen<D>
158+
where
159+
D: Copy + Debug + Ord + Eq + Hash + HashStable<StableHashingContext<'a>>,
160160
{
161161
fn hash_stable<W: StableHasherResult>(&self,
162162
hcx: &mut StableHashingContext<'a>,

src/librustc/ty/instance.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,10 @@ fn resolve_associated_item<'a, 'tcx>(
442442
}
443443
}
444444

445-
fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind,
446-
trait_closure_kind: ty::ClosureKind)
447-
-> Result<bool, ()>
448-
{
445+
fn needs_fn_once_adapter_shim(
446+
actual_closure_kind: ty::ClosureKind,
447+
trait_closure_kind: ty::ClosureKind,
448+
) -> Result<bool, ()> {
449449
match (actual_closure_kind, trait_closure_kind) {
450450
(ty::ClosureKind::Fn, ty::ClosureKind::Fn) |
451451
(ty::ClosureKind::FnMut, ty::ClosureKind::FnMut) |

src/librustc/ty/layout.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1678,10 +1678,11 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
16781678
}
16791679
}
16801680

1681-
impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
1682-
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
1683-
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
1684-
C: HasParamEnv<'tcx>
1681+
impl<'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
1682+
where
1683+
C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
1684+
C::TyLayout: MaybeResult<TyLayout<'tcx>>,
1685+
C: HasParamEnv<'tcx>,
16851686
{
16861687
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
16871688
let details = match this.variants {

src/librustc/ty/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl AssocItem {
203203

204204
/// Tests whether the associated item admits a non-trivial implementation
205205
/// for !
206-
pub fn relevant_for_never<'tcx>(&self) -> bool {
206+
pub fn relevant_for_never(&self) -> bool {
207207
match self.kind {
208208
AssocKind::Existential |
209209
AssocKind::Const |
@@ -1614,8 +1614,9 @@ pub struct Placeholder<T> {
16141614
pub name: T,
16151615
}
16161616

1617-
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
1618-
where T: HashStable<StableHashingContext<'a>>
1617+
impl<'a, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
1618+
where
1619+
T: HashStable<StableHashingContext<'a>>,
16191620
{
16201621
fn hash_stable<W: StableHasherResult>(
16211622
&self,

src/librustc/ty/print/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub use self::pretty::*;
1111

1212
pub mod obsolete;
1313

14+
// FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`.
15+
#[allow(unused_lifetimes)]
1416
pub trait Print<'gcx, 'tcx, P> {
1517
type Output;
1618
type Error;

src/librustc/ty/query/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use crate::ich::StableHashingContext;
1717

1818
// Query configuration and description traits.
1919

20+
// FIXME(eddyb) false positive, the lifetime parameter is used for `Key`/`Value`.
21+
#[allow(unused_lifetimes)]
2022
pub trait QueryConfig<'tcx> {
2123
const NAME: QueryName;
2224
const CATEGORY: ProfileCategory;

0 commit comments

Comments
 (0)