Skip to content

Commit 5b22d9b

Browse files
committed
don't elide lifetimes in paths in librustc/
This seemed like a good way to kick the tires on the elided-lifetimes-in-paths lint (#52069)—seems to work! This was also pretty tedious—it sure would be nice if `cargo fix` worked on this codebase (#53896)!
1 parent 6310be4 commit 5b22d9b

Some content is hidden

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

77 files changed

+557
-545
lines changed

src/librustc/dep_graph/dep_node.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ macro_rules! define_dep_nodes {
331331
/// refers to something from the previous compilation session that
332332
/// has been removed.
333333
#[inline]
334-
pub fn extract_def_id(&self, tcx: TyCtxt) -> Option<DefId> {
334+
pub fn extract_def_id(&self, tcx: TyCtxt<'_, '_, '_>) -> Option<DefId> {
335335
if self.kind.can_reconstruct_query_key() {
336336
let def_path_hash = DefPathHash(self.hash);
337337
tcx.def_path_hash_to_def_id.as_ref()?
@@ -386,7 +386,7 @@ macro_rules! define_dep_nodes {
386386
}
387387

388388
impl fmt::Debug for DepNode {
389-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
389+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
390390
write!(f, "{:?}", self.kind)?;
391391

392392
if !self.kind.has_params() && !self.kind.is_anon() {
@@ -424,7 +424,7 @@ impl DefPathHash {
424424

425425
impl DefId {
426426
#[inline]
427-
pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
427+
pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode {
428428
DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
429429
}
430430
}
@@ -714,7 +714,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
714714
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefId {
715715
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
716716

717-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
717+
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
718718
tcx.def_path_hash(*self).0
719719
}
720720

@@ -726,7 +726,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefId {
726726
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex {
727727
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
728728

729-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
729+
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
730730
tcx.hir.definitions().def_path_hash(*self).0
731731
}
732732

@@ -738,7 +738,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex {
738738
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for CrateNum {
739739
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
740740

741-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
741+
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
742742
let def_id = DefId {
743743
krate: *self,
744744
index: CRATE_DEF_INDEX,
@@ -757,7 +757,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, De
757757
// We actually would not need to specialize the implementation of this
758758
// method but it's faster to combine the hashes than to instantiate a full
759759
// hashing context and stable-hashing state.
760-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
760+
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
761761
let (def_id_0, def_id_1) = *self;
762762

763763
let def_path_hash_0 = tcx.def_path_hash(def_id_0);
@@ -781,7 +781,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for HirId {
781781
// We actually would not need to specialize the implementation of this
782782
// method but it's faster to combine the hashes than to instantiate a full
783783
// hashing context and stable-hashing state.
784-
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
784+
fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint {
785785
let HirId {
786786
owner,
787787
local_id: ItemLocalId(local_id),

src/librustc/hir/def_id.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum CrateNum {
3636
}
3737

3838
impl ::std::fmt::Debug for CrateNum {
39-
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
39+
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4040
match self {
4141
CrateNum::Index(id) => write!(fmt, "crate{}", id.private),
4242
CrateNum::Invalid => write!(fmt, "invalid crate"),
@@ -97,7 +97,7 @@ impl CrateNum {
9797
}
9898

9999
impl fmt::Display for CrateNum {
100-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
101101
match self {
102102
CrateNum::Index(id) => fmt::Display::fmt(&id.private, f),
103103
CrateNum::Invalid => write!(f, "invalid crate"),
@@ -132,7 +132,7 @@ pub struct DefIndex(u32);
132132
pub const CRATE_DEF_INDEX: DefIndex = DefIndex(0);
133133

134134
impl fmt::Debug for DefIndex {
135-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
135+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
136136
write!(f,
137137
"DefIndex({}:{})",
138138
self.address_space().index(),
@@ -224,7 +224,7 @@ pub struct DefId {
224224
}
225225

226226
impl fmt::Debug for DefId {
227-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
227+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
228228
write!(f, "DefId({:?}/{}:{}",
229229
self.krate.index(),
230230
self.index.address_space().index(),
@@ -288,7 +288,7 @@ impl LocalDefId {
288288
}
289289

290290
impl fmt::Debug for LocalDefId {
291-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
291+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
292292
self.to_def_id().fmt(f)
293293
}
294294
}

src/librustc/hir/lowering.rs

+28-27
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ impl<'a> LoweringContext<'a> {
686686
f: F,
687687
) -> (Vec<hir::GenericParam>, T)
688688
where
689-
F: FnOnce(&mut LoweringContext) -> (Vec<hir::GenericParam>, T),
689+
F: FnOnce(&mut LoweringContext<'_>) -> (Vec<hir::GenericParam>, T),
690690
{
691691
assert!(!self.is_collecting_in_band_lifetimes);
692692
assert!(self.lifetimes_to_define.is_empty());
@@ -788,7 +788,7 @@ impl<'a> LoweringContext<'a> {
788788
// for them.
789789
fn with_in_scope_lifetime_defs<T, F>(&mut self, params: &[GenericParam], f: F) -> T
790790
where
791-
F: FnOnce(&mut LoweringContext) -> T,
791+
F: FnOnce(&mut LoweringContext<'_>) -> T,
792792
{
793793
let old_len = self.in_scope_lifetimes.len();
794794
let lt_def_names = params.iter().filter_map(|param| match param.kind {
@@ -812,7 +812,7 @@ impl<'a> LoweringContext<'a> {
812812
params: &HirVec<hir::GenericParam>,
813813
f: F
814814
) -> T where
815-
F: FnOnce(&mut LoweringContext) -> T,
815+
F: FnOnce(&mut LoweringContext<'_>) -> T,
816816
{
817817
let old_len = self.in_scope_lifetimes.len();
818818
let lt_def_names = params.iter().filter_map(|param| match param.kind {
@@ -841,7 +841,7 @@ impl<'a> LoweringContext<'a> {
841841
f: F,
842842
) -> (hir::Generics, T)
843843
where
844-
F: FnOnce(&mut LoweringContext, &mut Vec<hir::GenericParam>) -> T,
844+
F: FnOnce(&mut LoweringContext<'_>, &mut Vec<hir::GenericParam>) -> T,
845845
{
846846
let (in_band_defs, (mut lowered_generics, res)) = self.with_in_scope_lifetime_defs(
847847
&generics.params,
@@ -870,7 +870,7 @@ impl<'a> LoweringContext<'a> {
870870

871871
fn with_catch_scope<T, F>(&mut self, catch_id: NodeId, f: F) -> T
872872
where
873-
F: FnOnce(&mut LoweringContext) -> T,
873+
F: FnOnce(&mut LoweringContext<'_>) -> T,
874874
{
875875
let len = self.catch_scopes.len();
876876
self.catch_scopes.push(catch_id);
@@ -892,7 +892,7 @@ impl<'a> LoweringContext<'a> {
892892
capture_clause: CaptureBy,
893893
closure_node_id: NodeId,
894894
ret_ty: Option<&Ty>,
895-
body: impl FnOnce(&mut LoweringContext) -> hir::Expr,
895+
body: impl FnOnce(&mut LoweringContext<'_>) -> hir::Expr,
896896
) -> hir::ExprKind {
897897
let prev_is_generator = mem::replace(&mut self.is_generator, true);
898898
let body_expr = body(self);
@@ -929,7 +929,7 @@ impl<'a> LoweringContext<'a> {
929929

930930
fn lower_body<F>(&mut self, decl: Option<&FnDecl>, f: F) -> hir::BodyId
931931
where
932-
F: FnOnce(&mut LoweringContext) -> hir::Expr,
932+
F: FnOnce(&mut LoweringContext<'_>) -> hir::Expr,
933933
{
934934
let prev = mem::replace(&mut self.is_generator, false);
935935
let result = f(self);
@@ -940,7 +940,7 @@ impl<'a> LoweringContext<'a> {
940940

941941
fn with_loop_scope<T, F>(&mut self, loop_id: NodeId, f: F) -> T
942942
where
943-
F: FnOnce(&mut LoweringContext) -> T,
943+
F: FnOnce(&mut LoweringContext<'_>) -> T,
944944
{
945945
// We're no longer in the base loop's condition; we're in another loop.
946946
let was_in_loop_condition = self.is_in_loop_condition;
@@ -965,7 +965,7 @@ impl<'a> LoweringContext<'a> {
965965

966966
fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
967967
where
968-
F: FnOnce(&mut LoweringContext) -> T,
968+
F: FnOnce(&mut LoweringContext<'_>) -> T,
969969
{
970970
let was_in_loop_condition = self.is_in_loop_condition;
971971
self.is_in_loop_condition = true;
@@ -979,7 +979,7 @@ impl<'a> LoweringContext<'a> {
979979

980980
fn with_new_scopes<T, F>(&mut self, f: F) -> T
981981
where
982-
F: FnOnce(&mut LoweringContext) -> T,
982+
F: FnOnce(&mut LoweringContext<'_>) -> T,
983983
{
984984
let was_in_loop_condition = self.is_in_loop_condition;
985985
self.is_in_loop_condition = false;
@@ -1094,7 +1094,8 @@ impl<'a> LoweringContext<'a> {
10941094
}
10951095
}
10961096

1097-
fn lower_ty_binding(&mut self, b: &TypeBinding, itctx: ImplTraitContext) -> hir::TypeBinding {
1097+
fn lower_ty_binding(&mut self, b: &TypeBinding,
1098+
itctx: ImplTraitContext<'_>) -> hir::TypeBinding {
10981099
hir::TypeBinding {
10991100
id: self.lower_node_id(b.id).node_id,
11001101
ident: b.ident,
@@ -1105,19 +1106,19 @@ impl<'a> LoweringContext<'a> {
11051106

11061107
fn lower_generic_arg(&mut self,
11071108
arg: &ast::GenericArg,
1108-
itctx: ImplTraitContext)
1109+
itctx: ImplTraitContext<'_>)
11091110
-> hir::GenericArg {
11101111
match arg {
11111112
ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(&lt)),
11121113
ast::GenericArg::Type(ty) => GenericArg::Type(self.lower_ty_direct(&ty, itctx)),
11131114
}
11141115
}
11151116

1116-
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> P<hir::Ty> {
1117+
fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext<'_>) -> P<hir::Ty> {
11171118
P(self.lower_ty_direct(t, itctx))
11181119
}
11191120

1120-
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty {
1121+
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty {
11211122
let kind = match t.node {
11221123
TyKind::Infer => hir::TyKind::Infer,
11231124
TyKind::Err => hir::TyKind::Err,
@@ -1289,7 +1290,7 @@ impl<'a> LoweringContext<'a> {
12891290
span: Span,
12901291
fn_def_id: Option<DefId>,
12911292
exist_ty_node_id: NodeId,
1292-
lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds,
1293+
lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds,
12931294
) -> hir::TyKind {
12941295
// Make sure we know that some funky desugaring has been going on here.
12951296
// This is a first: there is code in other places like for loop
@@ -1567,7 +1568,7 @@ impl<'a> LoweringContext<'a> {
15671568
qself: &Option<QSelf>,
15681569
p: &Path,
15691570
param_mode: ParamMode,
1570-
mut itctx: ImplTraitContext,
1571+
mut itctx: ImplTraitContext<'_>,
15711572
) -> hir::QPath {
15721573
let qself_position = qself.as_ref().map(|q| q.position);
15731574
let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx.reborrow()));
@@ -1762,7 +1763,7 @@ impl<'a> LoweringContext<'a> {
17621763
param_mode: ParamMode,
17631764
expected_lifetimes: usize,
17641765
parenthesized_generic_args: ParenthesizedGenericArgs,
1765-
itctx: ImplTraitContext,
1766+
itctx: ImplTraitContext<'_>,
17661767
) -> hir::PathSegment {
17671768
let (mut generic_args, infer_types) = if let Some(ref generic_args) = segment.args {
17681769
let msg = "parenthesized parameters may only be used with a trait";
@@ -1844,7 +1845,7 @@ impl<'a> LoweringContext<'a> {
18441845
&mut self,
18451846
data: &AngleBracketedArgs,
18461847
param_mode: ParamMode,
1847-
mut itctx: ImplTraitContext,
1848+
mut itctx: ImplTraitContext<'_>,
18481849
) -> (hir::GenericArgs, bool) {
18491850
let &AngleBracketedArgs { ref args, ref bindings, .. } = data;
18501851
let has_types = args.iter().any(|arg| match arg {
@@ -1871,7 +1872,7 @@ impl<'a> LoweringContext<'a> {
18711872
self.with_anonymous_lifetime_mode(
18721873
AnonymousLifetimeMode::PassThrough,
18731874
|this| {
1874-
const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed;
1875+
const DISALLOWED: ImplTraitContext<'_> = ImplTraitContext::Disallowed;
18751876
let &ParenthesisedArgs { ref inputs, ref output, span } = data;
18761877
let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect();
18771878
let mk_tup = |this: &mut Self, tys, span| {
@@ -2250,7 +2251,7 @@ impl<'a> LoweringContext<'a> {
22502251
fn lower_param_bound(
22512252
&mut self,
22522253
tpb: &GenericBound,
2253-
itctx: ImplTraitContext,
2254+
itctx: ImplTraitContext<'_>,
22542255
) -> hir::GenericBound {
22552256
match *tpb {
22562257
GenericBound::Trait(ref ty, modifier) => hir::GenericBound::Trait(
@@ -2304,7 +2305,7 @@ impl<'a> LoweringContext<'a> {
23042305
&mut self,
23052306
params: &[GenericParam],
23062307
add_bounds: &NodeMap<Vec<GenericBound>>,
2307-
mut itctx: ImplTraitContext,
2308+
mut itctx: ImplTraitContext<'_>,
23082309
) -> hir::HirVec<hir::GenericParam> {
23092310
params.iter().map(|param| {
23102311
self.lower_generic_param(param, add_bounds, itctx.reborrow())
@@ -2314,7 +2315,7 @@ impl<'a> LoweringContext<'a> {
23142315
fn lower_generic_param(&mut self,
23152316
param: &GenericParam,
23162317
add_bounds: &NodeMap<Vec<GenericBound>>,
2317-
mut itctx: ImplTraitContext)
2318+
mut itctx: ImplTraitContext<'_>)
23182319
-> hir::GenericParam {
23192320
let mut bounds = self.lower_param_bounds(&param.bounds, itctx.reborrow());
23202321
match param.kind {
@@ -2383,7 +2384,7 @@ impl<'a> LoweringContext<'a> {
23832384
fn lower_generics(
23842385
&mut self,
23852386
generics: &Generics,
2386-
itctx: ImplTraitContext)
2387+
itctx: ImplTraitContext<'_>)
23872388
-> hir::Generics
23882389
{
23892390
// Collect `?Trait` bounds in where clause and move them to parameter definitions.
@@ -2536,7 +2537,7 @@ impl<'a> LoweringContext<'a> {
25362537
}
25372538
}
25382539

2539-
fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext) -> hir::TraitRef {
2540+
fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext<'_>) -> hir::TraitRef {
25402541
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
25412542
hir::QPath::Resolved(None, path) => path.and_then(|path| path),
25422543
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
@@ -2552,7 +2553,7 @@ impl<'a> LoweringContext<'a> {
25522553
fn lower_poly_trait_ref(
25532554
&mut self,
25542555
p: &PolyTraitRef,
2555-
mut itctx: ImplTraitContext,
2556+
mut itctx: ImplTraitContext<'_>,
25562557
) -> hir::PolyTraitRef {
25572558
let bound_generic_params =
25582559
self.lower_generic_params(&p.bound_generic_params, &NodeMap(), itctx.reborrow());
@@ -2593,14 +2594,14 @@ impl<'a> LoweringContext<'a> {
25932594
}
25942595
}
25952596

2596-
fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext) -> hir::MutTy {
2597+
fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext<'_>) -> hir::MutTy {
25972598
hir::MutTy {
25982599
ty: self.lower_ty(&mt.ty, itctx),
25992600
mutbl: self.lower_mutability(mt.mutbl),
26002601
}
26012602
}
26022603

2603-
fn lower_param_bounds(&mut self, bounds: &[GenericBound], mut itctx: ImplTraitContext)
2604+
fn lower_param_bounds(&mut self, bounds: &[GenericBound], mut itctx: ImplTraitContext<'_>)
26042605
-> hir::GenericBounds {
26052606
bounds.iter().map(|bound| self.lower_param_bound(bound, itctx.reborrow())).collect()
26062607
}

src/librustc/hir/map/blocks.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a> ClosureParts<'a> {
143143

144144
impl<'a> FnLikeNode<'a> {
145145
/// Attempts to construct a FnLikeNode from presumed FnLike node input.
146-
pub fn from_node(node: Node) -> Option<FnLikeNode> {
146+
pub fn from_node(node: Node<'_>) -> Option<FnLikeNode<'_>> {
147147
let fn_like = match node {
148148
map::Node::Item(item) => item.is_fn_like(),
149149
map::Node::TraitItem(tm) => tm.is_fn_like(),
@@ -173,15 +173,15 @@ impl<'a> FnLikeNode<'a> {
173173
}
174174

175175
pub fn span(self) -> Span {
176-
self.handle(|i: ItemFnParts| i.span,
176+
self.handle(|i: ItemFnParts<'_>| i.span,
177177
|_, _, _: &'a ast::MethodSig, _, _, span, _| span,
178-
|c: ClosureParts| c.span)
178+
|c: ClosureParts<'_>| c.span)
179179
}
180180

181181
pub fn id(self) -> NodeId {
182-
self.handle(|i: ItemFnParts| i.id,
182+
self.handle(|i: ItemFnParts<'_>| i.id,
183183
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
184-
|c: ClosureParts| c.id)
184+
|c: ClosureParts<'_>| c.id)
185185
}
186186

187187
pub fn constness(self) -> ast::Constness {

0 commit comments

Comments
 (0)