Skip to content

Commit 5beeb1e

Browse files
committed
remove useless lifetime outlives bounds
1 parent 5e51edb commit 5beeb1e

File tree

11 files changed

+165
-190
lines changed

11 files changed

+165
-190
lines changed

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,4 @@ impl LintPass for HardwiredLints {
262262
}
263263
}
264264

265-
impl LateLintPass for HardwiredLints {}
265+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}

src/librustc/lint/mod.rs

+74-95
Original file line numberDiff line numberDiff line change
@@ -129,106 +129,85 @@ pub trait LintPass {
129129
//
130130
// FIXME: eliminate the duplication with `Visitor`. But this also
131131
// contains a few lint-specific methods with no equivalent in `Visitor`.
132-
pub trait LateLintPass: LintPass {
132+
pub trait LateLintPass<'a, 'tcx>: LintPass {
133133
fn check_name(&mut self, _: &LateContext, _: Span, _: ast::Name) { }
134-
fn check_crate<'a, 'tcx:'a >(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
135-
fn check_crate_post<'a, 'tcx: 'a>(&mut self,
136-
_: &'a LateContext<'a, 'tcx>,
137-
_: &'tcx hir::Crate) { }
138-
fn check_mod<'a, 'tcx: 'a>(&mut self,
139-
_: &'a LateContext<'a, 'tcx>,
140-
_: &'tcx hir::Mod,
141-
_: Span,
142-
_: ast::NodeId) { }
143-
fn check_mod_post<'a, 'tcx: 'a>(&mut self,
144-
_: &'a LateContext<'a, 'tcx>,
145-
_: &'tcx hir::Mod,
146-
_: Span,
147-
_: ast::NodeId) { }
148-
fn check_foreign_item<'a, 'tcx: 'a>(&mut self,
149-
_: &'a LateContext<'a, 'tcx>,
150-
_: &'tcx hir::ForeignItem) { }
151-
fn check_foreign_item_post<'a, 'tcx: 'a>(&mut self,
152-
_: &'a LateContext<'a, 'tcx>,
153-
_: &'tcx hir::ForeignItem) { }
154-
fn check_item<'a, 'tcx: 'a>(&mut self,
155-
_: &'a LateContext<'a, 'tcx>,
156-
_: &'tcx hir::Item) { }
157-
fn check_item_post<'a, 'tcx: 'a>(&mut self,
158-
_: &'a LateContext<'a, 'tcx>,
159-
_: &'tcx hir::Item) { }
160-
fn check_local<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Local) { }
161-
fn check_block<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
162-
fn check_block_post<'a, 'tcx: 'a>(&mut self,
163-
_: &'a LateContext<'a, 'tcx>,
164-
_: &'tcx hir::Block) { }
165-
fn check_stmt<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Stmt) { }
166-
fn check_arm<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Arm) { }
167-
fn check_pat<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Pat) { }
168-
fn check_decl<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Decl) { }
169-
fn check_expr<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
170-
fn check_expr_post<'a, 'tcx: 'a>(&mut self,
171-
_: &'a LateContext<'a, 'tcx>,
172-
_: &'tcx hir::Expr) { }
173-
fn check_ty<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
174-
fn check_generics<'a, 'tcx: 'a>(&mut self,
175-
_: &'a LateContext<'a, 'tcx>,
176-
_: &'tcx hir::Generics) { }
177-
fn check_fn<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
178-
_: FnKind<'tcx>, _: &'tcx hir::FnDecl, _: &'tcx hir::Expr, _: Span, _: ast::NodeId) { }
179-
fn check_fn_post<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
180-
_: FnKind<'tcx>, _: &'tcx hir::FnDecl, _: &'tcx hir::Expr, _: Span, _: ast::NodeId) { }
181-
fn check_trait_item<'a, 'tcx: 'a>(&mut self,
182-
_: &'a LateContext<'a, 'tcx>,
183-
_: &'tcx hir::TraitItem) { }
184-
fn check_trait_item_post<'a, 'tcx: 'a>(&mut self,
185-
_: &'a LateContext<'a, 'tcx>,
186-
_: &'tcx hir::TraitItem) { }
187-
fn check_impl_item<'a, 'tcx: 'a>(&mut self,
188-
_: &'a LateContext<'a, 'tcx>,
189-
_: &'tcx hir::ImplItem) { }
190-
fn check_impl_item_post<'a, 'tcx: 'a>(&mut self,
191-
_: &'a LateContext<'a, 'tcx>,
192-
_: &'tcx hir::ImplItem) { }
193-
fn check_struct_def<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
194-
_: &'tcx hir::VariantData, _: ast::Name, _: &'tcx hir::Generics, _: ast::NodeId) { }
195-
fn check_struct_def_post<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
196-
_: &'tcx hir::VariantData, _: ast::Name, _: &'tcx hir::Generics, _: ast::NodeId) { }
197-
fn check_struct_field<'a, 'tcx: 'a>(&mut self,
198-
_: &'a LateContext<'a, 'tcx>,
199-
_: &'tcx hir::StructField) { }
200-
fn check_variant<'a, 'tcx: 'a>(&mut self,
201-
_: &'a LateContext<'a, 'tcx>,
202-
_: &'tcx hir::Variant,
203-
_: &'tcx hir::Generics) { }
204-
fn check_variant_post<'a, 'tcx: 'a>(&mut self,
205-
_: &'a LateContext<'a, 'tcx>,
206-
_: &'tcx hir::Variant,
207-
_: &'tcx hir::Generics) { }
208-
fn check_lifetime<'a, 'tcx: 'a>(&mut self,
209-
_: &'a LateContext<'a, 'tcx>,
210-
_: &'tcx hir::Lifetime) { }
211-
fn check_lifetime_def<'a, 'tcx: 'a>(&mut self,
212-
_: &'a LateContext<'a, 'tcx>,
213-
_: &'tcx hir::LifetimeDef) { }
214-
fn check_path<'a, 'tcx: 'a>(&mut self,
215-
_: &'a LateContext<'a, 'tcx>,
216-
_: &'tcx hir::Path,
217-
_: ast::NodeId) { }
218-
fn check_attribute<'a, 'tcx: 'a>(&mut self,
219-
_: &'a LateContext<'a, 'tcx>,
220-
_: &'tcx ast::Attribute) { }
134+
fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
135+
fn check_crate_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
136+
fn check_mod(&mut self,
137+
_: &LateContext<'a, 'tcx>,
138+
_: &'tcx hir::Mod,
139+
_: Span,
140+
_: ast::NodeId) { }
141+
fn check_mod_post(&mut self,
142+
_: &LateContext<'a, 'tcx>,
143+
_: &'tcx hir::Mod,
144+
_: Span,
145+
_: ast::NodeId) { }
146+
fn check_foreign_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ForeignItem) { }
147+
fn check_foreign_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ForeignItem) { }
148+
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Item) { }
149+
fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Item) { }
150+
fn check_local(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Local) { }
151+
fn check_block(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
152+
fn check_block_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
153+
fn check_stmt(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Stmt) { }
154+
fn check_arm(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Arm) { }
155+
fn check_pat(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Pat) { }
156+
fn check_decl(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Decl) { }
157+
fn check_expr(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
158+
fn check_expr_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
159+
fn check_ty(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
160+
fn check_generics(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Generics) { }
161+
fn check_fn(&mut self,
162+
_: &LateContext<'a, 'tcx>,
163+
_: FnKind<'tcx>,
164+
_: &'tcx hir::FnDecl,
165+
_: &'tcx hir::Expr,
166+
_: Span,
167+
_: ast::NodeId) { }
168+
fn check_fn_post(&mut self,
169+
_: &LateContext<'a, 'tcx>,
170+
_: FnKind<'tcx>,
171+
_: &'tcx hir::FnDecl,
172+
_: &'tcx hir::Expr,
173+
_: Span,
174+
_: ast::NodeId) { }
175+
fn check_trait_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::TraitItem) { }
176+
fn check_trait_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::TraitItem) { }
177+
fn check_impl_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ImplItem) { }
178+
fn check_impl_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ImplItem) { }
179+
fn check_struct_def(&mut self,
180+
_: &LateContext<'a, 'tcx>,
181+
_: &'tcx hir::VariantData,
182+
_: ast::Name,
183+
_: &'tcx hir::Generics,
184+
_: ast::NodeId) { }
185+
fn check_struct_def_post(&mut self,
186+
_: &LateContext<'a, 'tcx>,
187+
_: &'tcx hir::VariantData,
188+
_: ast::Name,
189+
_: &'tcx hir::Generics,
190+
_: ast::NodeId) { }
191+
fn check_struct_field(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::StructField) { }
192+
fn check_variant(&mut self,
193+
_: &LateContext<'a, 'tcx>,
194+
_: &'tcx hir::Variant,
195+
_: &'tcx hir::Generics) { }
196+
fn check_variant_post(&mut self,
197+
_: &LateContext<'a, 'tcx>,
198+
_: &'tcx hir::Variant,
199+
_: &'tcx hir::Generics) { }
200+
fn check_lifetime(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Lifetime) { }
201+
fn check_lifetime_def(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::LifetimeDef) { }
202+
fn check_path(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Path, _: ast::NodeId) { }
203+
fn check_attribute(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx ast::Attribute) { }
221204

222205
/// Called when entering a syntax node that can have lint attributes such
223206
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
224-
fn enter_lint_attrs<'a, 'tcx: 'a>(&mut self,
225-
_: &'a LateContext<'a, 'tcx>,
226-
_: &'tcx [ast::Attribute]) { }
207+
fn enter_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx [ast::Attribute]) { }
227208

228209
/// Counterpart to `enter_lint_attrs`.
229-
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self,
230-
_: &'a LateContext<'a, 'tcx>,
231-
_: &'tcx [ast::Attribute]) { }
210+
fn exit_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx [ast::Attribute]) { }
232211
}
233212

234213
pub trait EarlyLintPass: LintPass {
@@ -282,7 +261,7 @@ pub trait EarlyLintPass: LintPass {
282261

283262
/// A lint pass boxed up as a trait object.
284263
pub type EarlyLintPassObject = Box<EarlyLintPass + 'static>;
285-
pub type LateLintPassObject = Box<LateLintPass + 'static>;
264+
pub type LateLintPassObject = Box<for<'a, 'tcx> LateLintPass<'a, 'tcx> + 'static>;
286265

287266
/// Identifies a lint known to the compiler.
288267
#[derive(Clone, Copy, Debug)]

src/librustc_lint/bad_style.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ impl LintPass for NonCamelCaseTypes {
9999
}
100100
}
101101

102-
impl LateLintPass for NonCamelCaseTypes {
103-
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
102+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
103+
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
104104
let extern_repr_count = it.attrs
105105
.iter()
106106
.filter(|attr| {
@@ -133,7 +133,7 @@ impl LateLintPass for NonCamelCaseTypes {
133133
}
134134
}
135135

136-
fn check_generics<'a, 'tcx: 'a>(&mut self,
136+
fn check_generics(&mut self,
137137
cx: &LateContext<'a, 'tcx>,
138138
it: &'tcx hir::Generics) {
139139
for gen in it.ty_params.iter() {
@@ -228,8 +228,8 @@ impl LintPass for NonSnakeCase {
228228
}
229229
}
230230

231-
impl LateLintPass for NonSnakeCase {
232-
fn check_crate<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, cr: &'tcx hir::Crate) {
231+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
232+
fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, cr: &'tcx hir::Crate) {
233233
let attr_crate_name = cr.attrs
234234
.iter()
235235
.find(|at| at.check_name("crate_name"))
@@ -241,7 +241,7 @@ impl LateLintPass for NonSnakeCase {
241241
}
242242
}
243243

244-
fn check_fn<'a, 'tcx: 'a>(&mut self,
244+
fn check_fn(&mut self,
245245
cx: &LateContext<'a, 'tcx>,
246246
fk: FnKind,
247247
_: &'tcx hir::FnDecl,
@@ -267,13 +267,13 @@ impl LateLintPass for NonSnakeCase {
267267
}
268268
}
269269

270-
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
270+
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
271271
if let hir::ItemMod(_) = it.node {
272272
self.check_snake_case(cx, "module", &it.name.as_str(), Some(it.span));
273273
}
274274
}
275275

276-
fn check_trait_item<'a, 'tcx: 'a>(&mut self,
276+
fn check_trait_item(&mut self,
277277
cx: &LateContext<'a, 'tcx>,
278278
trait_item: &'tcx hir::TraitItem) {
279279
if let hir::MethodTraitItem(_, None) = trait_item.node {
@@ -284,7 +284,7 @@ impl LateLintPass for NonSnakeCase {
284284
}
285285
}
286286

287-
fn check_lifetime_def<'a, 'tcx: 'a>(&mut self,
287+
fn check_lifetime_def(&mut self,
288288
cx: &LateContext<'a, 'tcx>,
289289
t: &'tcx hir::LifetimeDef) {
290290
self.check_snake_case(cx,
@@ -293,7 +293,7 @@ impl LateLintPass for NonSnakeCase {
293293
Some(t.lifetime.span));
294294
}
295295

296-
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
296+
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
297297
// Exclude parameter names from foreign functions
298298
let parent_node = cx.tcx.map.get_parent_node(p.id);
299299
if let hir::map::NodeForeignItem(item) = cx.tcx.map.get(parent_node) {
@@ -307,7 +307,7 @@ impl LateLintPass for NonSnakeCase {
307307
}
308308
}
309309

310-
fn check_struct_def<'a, 'tcx: 'a>(&mut self,
310+
fn check_struct_def(&mut self,
311311
cx: &LateContext<'a, 'tcx>,
312312
s: &'tcx hir::VariantData,
313313
_: ast::Name,
@@ -354,8 +354,8 @@ impl LintPass for NonUpperCaseGlobals {
354354
}
355355
}
356356

357-
impl LateLintPass for NonUpperCaseGlobals {
358-
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
357+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
358+
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
359359
match it.node {
360360
hir::ItemStatic(..) => {
361361
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
@@ -367,7 +367,7 @@ impl LateLintPass for NonUpperCaseGlobals {
367367
}
368368
}
369369

370-
fn check_trait_item<'a, 'tcx: 'a>(&mut self,
370+
fn check_trait_item(&mut self,
371371
cx: &LateContext<'a, 'tcx>,
372372
ti: &'tcx hir::TraitItem) {
373373
match ti.node {
@@ -378,7 +378,7 @@ impl LateLintPass for NonUpperCaseGlobals {
378378
}
379379
}
380380

381-
fn check_impl_item<'a, 'tcx: 'a>(&mut self,
381+
fn check_impl_item(&mut self,
382382
cx: &LateContext<'a, 'tcx>,
383383
ii: &'tcx hir::ImplItem) {
384384
match ii.node {
@@ -389,7 +389,7 @@ impl LateLintPass for NonUpperCaseGlobals {
389389
}
390390
}
391391

392-
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
392+
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
393393
// Lint for constants that look like binding identifiers (#7526)
394394
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
395395
if !path.global && path.segments.len() == 1 && path.segments[0].parameters.is_empty() {

0 commit comments

Comments
 (0)