1
Fork 0

remove useless lifetime outlives bounds

This commit is contained in:
Oliver Schneider 2016-12-07 13:14:47 +01:00
parent 5e51edb0de
commit 5beeb1eec7
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
11 changed files with 165 additions and 190 deletions

View file

@ -262,4 +262,4 @@ impl LintPass for HardwiredLints {
}
}
impl LateLintPass for HardwiredLints {}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}

View file

@ -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 {
@ -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)]

View file

@ -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| {
@ -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() {
@ -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"))
@ -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,
@ -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 {
@ -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,
@ -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) {
@ -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,
@ -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);
@ -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 {
@ -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 {
@ -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() {

View file

@ -69,8 +69,8 @@ impl LintPass for WhileTrue {
}
}
impl LateLintPass for WhileTrue {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
if let hir::ExprWhile(ref cond, ..) = e.node {
if let hir::ExprLit(ref lit) = cond.node {
if let ast::LitKind::Bool(true) = lit.node {
@ -109,8 +109,8 @@ impl LintPass for BoxPointers {
}
}
impl LateLintPass for BoxPointers {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
match it.node {
hir::ItemFn(..) |
hir::ItemTy(..) |
@ -137,7 +137,7 @@ impl LateLintPass for BoxPointers {
}
}
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
let ty = cx.tcx.tables().node_id_to_type(e.id);
self.check_heap_type(cx, e.span, ty);
}
@ -158,8 +158,8 @@ impl LintPass for NonShorthandFieldPatterns {
}
}
impl LateLintPass for NonShorthandFieldPatterns {
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx hir::Pat) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx hir::Pat) {
if let PatKind::Struct(_, ref field_pats, _) = pat.node {
for fieldpat in field_pats {
if fieldpat.node.is_shorthand {
@ -194,8 +194,8 @@ impl LintPass for UnsafeCode {
}
}
impl LateLintPass for UnsafeCode {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
if let hir::ExprBlock(ref blk) = e.node {
// Don't warn about generated blocks, that'll just pollute the output.
if blk.rules == hir::UnsafeBlock(hir::UserProvided) {
@ -204,7 +204,7 @@ impl LateLintPass for UnsafeCode {
}
}
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) {
match it.node {
hir::ItemTrait(hir::Unsafety::Unsafe, ..) => {
cx.span_lint(UNSAFE_CODE, it.span, "declaration of an `unsafe` trait")
@ -218,7 +218,7 @@ impl LateLintPass for UnsafeCode {
}
}
fn check_fn<'a, 'tcx: 'a>(&mut self,
fn check_fn(&mut self,
cx: &LateContext<'a, 'tcx>,
fk: FnKind<'tcx>,
_: &'tcx hir::FnDecl,
@ -240,7 +240,7 @@ impl LateLintPass for UnsafeCode {
}
}
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(ref sig, None) = trait_item.node {
@ -329,10 +329,8 @@ impl LintPass for MissingDoc {
}
}
impl LateLintPass for MissingDoc {
fn enter_lint_attrs<'a, 'tcx: 'a>(&mut self,
_: &LateContext<'a, 'tcx>,
attrs: &'tcx [ast::Attribute]) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
fn enter_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, attrs: &'tcx [ast::Attribute]) {
let doc_hidden = self.doc_hidden() ||
attrs.iter().any(|attr| {
attr.check_name("doc") &&
@ -344,13 +342,11 @@ impl LateLintPass for MissingDoc {
self.doc_hidden_stack.push(doc_hidden);
}
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self,
_: &LateContext<'a, 'tcx>,
_attrs: &'tcx [ast::Attribute]) {
fn exit_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _attrs: &'tcx [ast::Attribute]) {
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
}
fn check_struct_def<'a, 'tcx: 'a>(&mut self,
fn check_struct_def(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData,
_: ast::Name,
@ -359,7 +355,7 @@ impl LateLintPass for MissingDoc {
self.struct_def_stack.push(item_id);
}
fn check_struct_def_post<'a, 'tcx: 'a>(&mut self,
fn check_struct_def_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::VariantData,
_: ast::Name,
@ -369,11 +365,11 @@ impl LateLintPass for MissingDoc {
assert!(popped == item_id);
}
fn check_crate<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate");
}
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) {
let desc = match it.node {
hir::ItemFn(..) => "a function",
hir::ItemMod(..) => "a module",
@ -418,7 +414,7 @@ impl LateLintPass for MissingDoc {
self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc);
}
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 self.private_traits.contains(&trait_item.id) {
@ -438,7 +434,7 @@ impl LateLintPass for MissingDoc {
desc);
}
fn check_impl_item<'a, 'tcx: 'a>(&mut self,
fn check_impl_item(&mut self,
cx: &LateContext<'a, 'tcx>,
impl_item: &'tcx hir::ImplItem) {
// If the method is an impl for a trait, don't doc.
@ -458,7 +454,7 @@ impl LateLintPass for MissingDoc {
desc);
}
fn check_struct_field<'a, 'tcx: 'a>(&mut self,
fn check_struct_field(&mut self,
cx: &LateContext<'a, 'tcx>,
sf: &'tcx hir::StructField) {
if !sf.is_positional() {
@ -475,7 +471,7 @@ impl LateLintPass for MissingDoc {
}
}
fn check_variant<'a, 'tcx: 'a>(&mut self,
fn check_variant(&mut self,
cx: &LateContext<'a, 'tcx>,
v: &'tcx hir::Variant,
_: &'tcx hir::Generics) {
@ -488,7 +484,7 @@ impl LateLintPass for MissingDoc {
self.in_variant = true;
}
fn check_variant_post<'a, 'tcx: 'a>(&mut self,
fn check_variant_post(&mut self,
_: &LateContext<'a, 'tcx>,
_: &'tcx hir::Variant,
_: &'tcx hir::Generics) {
@ -512,8 +508,8 @@ impl LintPass for MissingCopyImplementations {
}
}
impl LateLintPass for MissingCopyImplementations {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
if !cx.access_levels.is_reachable(item.id) {
return;
}
@ -581,8 +577,8 @@ impl LintPass for MissingDebugImplementations {
}
}
impl LateLintPass for MissingDebugImplementations {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
if !cx.access_levels.is_reachable(item.id) {
return;
}
@ -687,8 +683,8 @@ impl LintPass for UnconditionalRecursion {
}
}
impl LateLintPass for UnconditionalRecursion {
fn check_fn<'a, 'tcx: 'a>(&mut self,
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
fn check_fn(&mut self,
cx: &LateContext<'a, 'tcx>,
fn_kind: FnKind<'tcx>,
_: &'tcx hir::FnDecl,
@ -950,8 +946,8 @@ impl LintPass for PluginAsLibrary {
}
}
impl LateLintPass for PluginAsLibrary {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
if cx.sess().plugin_registrar_fn.get().is_some() {
// We're compiling a plugin; it's fine to link other plugins.
return;
@ -1016,8 +1012,8 @@ impl LintPass for InvalidNoMangleItems {
}
}
impl LateLintPass for InvalidNoMangleItems {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
match it.node {
hir::ItemFn(.., ref generics, _) => {
if attr::contains_name(&it.attrs, "no_mangle") {
@ -1070,8 +1066,8 @@ impl LintPass for MutableTransmutes {
}
}
impl LateLintPass for MutableTransmutes {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
use syntax::abi::Abi::RustIntrinsic;
let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
@ -1138,8 +1134,8 @@ impl LintPass for UnstableFeatures {
}
}
impl LateLintPass for UnstableFeatures {
fn check_attribute<'a, 'tcx: 'a>(&mut self,
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures {
fn check_attribute(&mut self,
ctx: &LateContext<'a, 'tcx>,
attr: &'tcx ast::Attribute) {
if attr.meta().check_name("feature") {
@ -1167,8 +1163,8 @@ impl LintPass for UnionsWithDropFields {
}
}
impl LateLintPass for UnionsWithDropFields {
fn check_item<'a, 'tcx: 'a>(&mut self, ctx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
fn check_item(&mut self, ctx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
if let hir::ItemUnion(ref vdata, _) = item.node {
let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id);
for field in vdata.fields() {

View file

@ -103,8 +103,8 @@ impl LintPass for TypeLimits {
}
}
impl LateLintPass for TypeLimits {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
match e.node {
hir::ExprUnary(hir::UnNeg, ref expr) => {
if let hir::ExprLit(ref lit) = expr.node {
@ -706,8 +706,8 @@ impl LintPass for ImproperCTypes {
}
}
impl LateLintPass for ImproperCTypes {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
let mut vis = ImproperCTypesVisitor { cx: cx };
if let hir::ItemForeignMod(ref nmod) = it.node {
if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic {
@ -734,8 +734,8 @@ impl LintPass for VariantSizeDifferences {
}
}
impl LateLintPass for VariantSizeDifferences {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
if let hir::ItemEnum(ref enum_definition, ref gens) = it.node {
if gens.ty_params.is_empty() {
// sizes only make sense for non-generic types

View file

@ -77,8 +77,8 @@ impl LintPass for UnusedMut {
}
}
impl LateLintPass for UnusedMut {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedMut {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
if let hir::ExprMatch(_, ref arms, _) = e.node {
for a in arms {
self.check_unused_mut_pat(cx, &a.pats)
@ -86,7 +86,7 @@ impl LateLintPass for UnusedMut {
}
}
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
if let hir::StmtDecl(ref d, _) = s.node {
if let hir::DeclLocal(ref l) = d.node {
self.check_unused_mut_pat(cx, slice::ref_slice(&l.pat));
@ -94,7 +94,7 @@ impl LateLintPass for UnusedMut {
}
}
fn check_fn<'a, 'tcx: 'a>(&mut self,
fn check_fn(&mut self,
cx: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
@ -128,8 +128,8 @@ impl LintPass for UnusedResults {
}
}
impl LateLintPass for UnusedResults {
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
let expr = match s.node {
hir::StmtSemi(ref expr, _) => &**expr,
_ => return,
@ -187,8 +187,8 @@ impl LintPass for UnusedUnsafe {
}
}
impl LateLintPass for UnusedUnsafe {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedUnsafe {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
if let hir::ExprBlock(ref blk) = e.node {
// Don't warn about generated blocks, that'll just pollute the output.
if blk.rules == hir::UnsafeBlock(hir::UserProvided) &&
@ -214,8 +214,8 @@ impl LintPass for PathStatements {
}
}
impl LateLintPass for PathStatements {
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
if let hir::StmtSemi(ref expr, _) = s.node {
if let hir::ExprPath(_) = expr.node {
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
@ -239,8 +239,8 @@ impl LintPass for UnusedAttributes {
}
}
impl LateLintPass for UnusedAttributes {
fn check_attribute<'a, 'tcx: 'a>(&mut self,
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
fn check_attribute(&mut self,
cx: &LateContext<'a, 'tcx>,
attr: &'tcx ast::Attribute) {
debug!("checking attribute: {:?}", attr);
@ -435,8 +435,8 @@ impl LintPass for UnusedAllocation {
}
}
impl LateLintPass for UnusedAllocation {
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
match e.node {
hir::ExprBox(_) => {}
_ => return,

View file

@ -32,8 +32,8 @@ impl LintPass for Pass {
}
}
impl LateLintPass for Pass {
fn check_crate<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
if !attr::contains_name(&krate.attrs, "crate_okay") {
cx.span_lint(CRATE_NOT_OKAY, krate.span,
"crate is not marked with #![crate_okay]");
@ -43,5 +43,5 @@ impl LateLintPass for Pass {
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_late_lint_pass(box Pass as LateLintPassObject);
reg.register_late_lint_pass(box Pass);
}

View file

@ -34,8 +34,8 @@ impl LintPass for Pass {
}
}
impl LateLintPass for Pass {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
match &*it.name.as_str() {
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
@ -46,6 +46,6 @@ impl LateLintPass for Pass {
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_late_lint_pass(box Pass as LateLintPassObject);
reg.register_late_lint_pass(box Pass);
reg.register_lint_group("lint_me", vec![TEST_LINT, PLEASE_LINT]);
}

View file

@ -32,8 +32,8 @@ impl LintPass for Pass {
}
}
impl LateLintPass for Pass {
fn check_crate<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
if !attr::contains_name(&krate.attrs, "crate_okay") {
cx.span_lint(CRATE_NOT_OKAY, krate.span,
"crate is not marked with #![crate_okay]");
@ -43,5 +43,5 @@ impl LateLintPass for Pass {
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_late_lint_pass(box Pass as LateLintPassObject);
reg.register_late_lint_pass(box Pass);
}

View file

@ -34,8 +34,8 @@ impl LintPass for Pass {
}
}
impl LateLintPass for Pass {
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
match &*it.name.as_str() {
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
@ -46,6 +46,6 @@ impl LateLintPass for Pass {
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_late_lint_pass(box Pass as LateLintPassObject);
reg.register_late_lint_pass(box Pass);
reg.register_lint_group("lint_me", vec![TEST_LINT, PLEASE_LINT]);
}

View file

@ -39,8 +39,8 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray { lint_array!(REGION_HIERARCHY) }
}
impl LateLintPass for Pass {
fn check_fn<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>,
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>,
fk: FnKind<'tcx>, _: &'tcx hir::FnDecl, expr: &'tcx hir::Expr,
span: Span, node: ast::NodeId)
{