Skip to content

Commit

Permalink
remove useless lifetime outlives bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 7, 2016
1 parent 5e51edb commit 5beeb1e
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 190 deletions.
2 changes: 1 addition & 1 deletion src/librustc/lint/builtin.rs
Expand Up @@ -262,4 +262,4 @@ impl LintPass for HardwiredLints {
}
}

impl LateLintPass for HardwiredLints {}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}
169 changes: 74 additions & 95 deletions src/librustc/lint/mod.rs
Expand Up @@ -129,106 +129,85 @@ pub trait LintPass {
//
// FIXME: eliminate the duplication with `Visitor`. But this also
// contains a few lint-specific methods with no equivalent in `Visitor`.
pub trait LateLintPass: LintPass {
pub trait LateLintPass<'a, 'tcx>: LintPass {
fn check_name(&mut self, _: &LateContext, _: Span, _: ast::Name) { }
fn check_crate<'a, 'tcx:'a >(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
fn check_crate_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Crate) { }
fn check_mod<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Mod,
_: Span,
_: ast::NodeId) { }
fn check_mod_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Mod,
_: Span,
_: ast::NodeId) { }
fn check_foreign_item<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::ForeignItem) { }
fn check_foreign_item_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::ForeignItem) { }
fn check_item<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Item) { }
fn check_item_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Item) { }
fn check_local<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Local) { }
fn check_block<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
fn check_block_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Block) { }
fn check_stmt<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Stmt) { }
fn check_arm<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Arm) { }
fn check_pat<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Pat) { }
fn check_decl<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Decl) { }
fn check_expr<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
fn check_expr_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Expr) { }
fn check_ty<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
fn check_generics<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Generics) { }
fn check_fn<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
_: FnKind<'tcx>, _: &'tcx hir::FnDecl, _: &'tcx hir::Expr, _: Span, _: ast::NodeId) { }
fn check_fn_post<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
_: FnKind<'tcx>, _: &'tcx hir::FnDecl, _: &'tcx hir::Expr, _: Span, _: ast::NodeId) { }
fn check_trait_item<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::TraitItem) { }
fn check_trait_item_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::TraitItem) { }
fn check_impl_item<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::ImplItem) { }
fn check_impl_item_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::ImplItem) { }
fn check_struct_def<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData, _: ast::Name, _: &'tcx hir::Generics, _: ast::NodeId) { }
fn check_struct_def_post<'a, 'tcx: 'a>(&mut self, _: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData, _: ast::Name, _: &'tcx hir::Generics, _: ast::NodeId) { }
fn check_struct_field<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::StructField) { }
fn check_variant<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Variant,
_: &'tcx hir::Generics) { }
fn check_variant_post<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Variant,
_: &'tcx hir::Generics) { }
fn check_lifetime<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Lifetime) { }
fn check_lifetime_def<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::LifetimeDef) { }
fn check_path<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx hir::Path,
_: ast::NodeId) { }
fn check_attribute<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx ast::Attribute) { }
fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
fn check_crate_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
fn check_mod(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::Mod,
_: Span,
_: ast::NodeId) { }
fn check_mod_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::Mod,
_: Span,
_: ast::NodeId) { }
fn check_foreign_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ForeignItem) { }
fn check_foreign_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ForeignItem) { }
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Item) { }
fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Item) { }
fn check_local(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Local) { }
fn check_block(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
fn check_block_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Block) { }
fn check_stmt(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Stmt) { }
fn check_arm(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Arm) { }
fn check_pat(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Pat) { }
fn check_decl(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Decl) { }
fn check_expr(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
fn check_expr_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Expr) { }
fn check_ty(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
fn check_generics(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Generics) { }
fn check_fn(&mut self,
_: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
_: &'tcx hir::FnDecl,
_: &'tcx hir::Expr,
_: Span,
_: ast::NodeId) { }
fn check_fn_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
_: &'tcx hir::FnDecl,
_: &'tcx hir::Expr,
_: Span,
_: ast::NodeId) { }
fn check_trait_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::TraitItem) { }
fn check_trait_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::TraitItem) { }
fn check_impl_item(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ImplItem) { }
fn check_impl_item_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::ImplItem) { }
fn check_struct_def(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData,
_: ast::Name,
_: &'tcx hir::Generics,
_: ast::NodeId) { }
fn check_struct_def_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData,
_: ast::Name,
_: &'tcx hir::Generics,
_: ast::NodeId) { }
fn check_struct_field(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::StructField) { }
fn check_variant(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::Variant,
_: &'tcx hir::Generics) { }
fn check_variant_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::Variant,
_: &'tcx hir::Generics) { }
fn check_lifetime(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Lifetime) { }
fn check_lifetime_def(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::LifetimeDef) { }
fn check_path(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Path, _: ast::NodeId) { }
fn check_attribute(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx ast::Attribute) { }

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

/// Counterpart to `enter_lint_attrs`.
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self,
_: &'a LateContext<'a, 'tcx>,
_: &'tcx [ast::Attribute]) { }
fn exit_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx [ast::Attribute]) { }
}

pub trait EarlyLintPass: LintPass {
Expand Down Expand Up @@ -282,7 +261,7 @@ pub trait EarlyLintPass: LintPass {

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

/// Identifies a lint known to the compiler.
#[derive(Clone, Copy, Debug)]
Expand Down
32 changes: 16 additions & 16 deletions src/librustc_lint/bad_style.rs
Expand Up @@ -99,8 +99,8 @@ impl LintPass for NonCamelCaseTypes {
}
}

impl LateLintPass for NonCamelCaseTypes {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
let extern_repr_count = it.attrs
.iter()
.filter(|attr| {
Expand Down Expand Up @@ -133,7 +133,7 @@ impl LateLintPass for NonCamelCaseTypes {
}
}

fn check_generics<'a, 'tcx: 'a>(&mut self,
fn check_generics(&mut self,
cx: &LateContext<'a, 'tcx>,
it: &'tcx hir::Generics) {
for gen in it.ty_params.iter() {
Expand Down Expand Up @@ -228,8 +228,8 @@ impl LintPass for NonSnakeCase {
}
}

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

fn check_fn<'a, 'tcx: 'a>(&mut self,
fn check_fn(&mut self,
cx: &LateContext<'a, 'tcx>,
fk: FnKind,
_: &'tcx hir::FnDecl,
Expand All @@ -267,13 +267,13 @@ impl LateLintPass for NonSnakeCase {
}
}

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

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

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

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

fn check_struct_def<'a, 'tcx: 'a>(&mut self,
fn check_struct_def(&mut self,
cx: &LateContext<'a, 'tcx>,
s: &'tcx hir::VariantData,
_: ast::Name,
Expand Down Expand Up @@ -354,8 +354,8 @@ impl LintPass for NonUpperCaseGlobals {
}
}

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

fn check_trait_item<'a, 'tcx: 'a>(&mut self,
fn check_trait_item(&mut self,
cx: &LateContext<'a, 'tcx>,
ti: &'tcx hir::TraitItem) {
match ti.node {
Expand All @@ -378,7 +378,7 @@ impl LateLintPass for NonUpperCaseGlobals {
}
}

fn check_impl_item<'a, 'tcx: 'a>(&mut self,
fn check_impl_item(&mut self,
cx: &LateContext<'a, 'tcx>,
ii: &'tcx hir::ImplItem) {
match ii.node {
Expand All @@ -389,7 +389,7 @@ impl LateLintPass for NonUpperCaseGlobals {
}
}

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

0 comments on commit 5beeb1e

Please sign in to comment.