}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
let extern_repr_count = it.attrs
.iter()
.filter(|attr| {
}
}
- fn check_generics(&mut self,
- cx: &LateContext<'a, 'tcx>,
- it: &'tcx hir::Generics) {
+ fn check_generics(&mut self, cx: &LateContext, it: &hir::Generics) {
for gen in it.ty_params.iter() {
self.check_case(cx, "type parameter", gen.name, gen.span);
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, cr: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) {
let attr_crate_name = cr.attrs
.iter()
.find(|at| at.check_name("crate_name"))
}
fn check_fn(&mut self,
- cx: &LateContext<'a, 'tcx>,
- fk: FnKind,
- _: &'tcx hir::FnDecl,
- _: &'tcx hir::Expr,
- span: Span,
- id: ast::NodeId) {
+ cx: &LateContext,
+ fk: FnKind,
+ _: &hir::FnDecl,
+ _: &hir::Expr,
+ span: Span,
+ id: ast::NodeId) {
match fk {
FnKind::Method(name, ..) => {
match method_context(cx, id, span) {
}
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &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(&mut self,
- cx: &LateContext<'a, 'tcx>,
- trait_item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) {
if let hir::MethodTraitItem(_, None) = trait_item.node {
self.check_snake_case(cx,
"trait method",
}
}
- fn check_lifetime_def(&mut self,
- cx: &LateContext<'a, 'tcx>,
- t: &'tcx hir::LifetimeDef) {
+ fn check_lifetime_def(&mut self, cx: &LateContext, t: &hir::LifetimeDef) {
self.check_snake_case(cx,
"lifetime",
&t.lifetime.name.as_str(),
Some(t.lifetime.span));
}
- fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
+ fn check_pat(&mut self, cx: &LateContext, p: &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) {
}
fn check_struct_def(&mut self,
- cx: &LateContext<'a, 'tcx>,
- s: &'tcx hir::VariantData,
- _: ast::Name,
- _: &'tcx hir::Generics,
- _: ast::NodeId) {
+ cx: &LateContext,
+ s: &hir::VariantData,
+ _: ast::Name,
+ _: &hir::Generics,
+ _: ast::NodeId) {
for sf in s.fields() {
self.check_snake_case(cx, "structure field", &sf.name.as_str(), Some(sf.span));
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemStatic(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
}
}
- fn check_trait_item(&mut self,
- cx: &LateContext<'a, 'tcx>,
- ti: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) {
match ti.node {
hir::ConstTraitItem(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ti.name, ti.span);
}
}
- fn check_impl_item(&mut self,
- cx: &LateContext<'a, 'tcx>,
- ii: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
match ii.node {
hir::ImplItemKind::Const(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ii.name, ii.span);
}
}
- fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, p: &'tcx hir::Pat) {
+ fn check_pat(&mut self, cx: &LateContext, p: &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() {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &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 {
pub struct BoxPointers;
impl BoxPointers {
- fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext<'a, 'tcx>, span: Span, ty: Ty<'tcx>) {
+ fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext, span: Span, ty: Ty) {
for leaf_ty in ty.walk() {
if let ty::TyBox(_) = leaf_ty.sty {
let m = format!("type uses owned (Box type) pointers: {}", ty);
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemFn(..) |
hir::ItemTy(..) |
}
}
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
let ty = cx.tcx.tables().node_id_to_type(e.id);
self.check_heap_type(cx, e.span, ty);
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
- fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx hir::Pat) {
+ fn check_pat(&mut self, cx: &LateContext, pat: &hir::Pat) {
if let PatKind::Struct(_, ref field_pats, _) = pat.node {
for fieldpat in field_pats {
if fieldpat.node.is_shorthand {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &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) {
}
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemTrait(hir::Unsafety::Unsafe, ..) => {
cx.span_lint(UNSAFE_CODE, it.span, "declaration of an `unsafe` trait")
}
fn check_fn(&mut self,
- cx: &LateContext<'a, 'tcx>,
- fk: FnKind<'tcx>,
- _: &'tcx hir::FnDecl,
- _: &'tcx hir::Expr,
- span: Span,
- _: ast::NodeId) {
+ cx: &LateContext,
+ fk: FnKind<'tcx>,
+ _: &hir::FnDecl,
+ _: &hir::Expr,
+ span: Span,
+ _: ast::NodeId) {
match fk {
FnKind::ItemFn(_, _, hir::Unsafety::Unsafe, ..) => {
cx.span_lint(UNSAFE_CODE, span, "declaration of an `unsafe` function")
}
}
- fn check_trait_item(&mut self,
- cx: &LateContext<'a, 'tcx>,
- trait_item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) {
if let hir::MethodTraitItem(ref sig, None) = trait_item.node {
if sig.unsafety == hir::Unsafety::Unsafe {
cx.span_lint(UNSAFE_CODE,
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
- fn enter_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, attrs: &'tcx [ast::Attribute]) {
+ fn enter_lint_attrs(&mut self, _: &LateContext, attrs: &[ast::Attribute]) {
let doc_hidden = self.doc_hidden() ||
attrs.iter().any(|attr| {
attr.check_name("doc") &&
self.doc_hidden_stack.push(doc_hidden);
}
- fn exit_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _attrs: &'tcx [ast::Attribute]) {
+ fn exit_lint_attrs(&mut self, _: &LateContext, _attrs: &[ast::Attribute]) {
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
}
fn check_struct_def(&mut self,
- _: &LateContext<'a, 'tcx>,
- _: &'tcx hir::VariantData,
- _: ast::Name,
- _: &'tcx hir::Generics,
- item_id: ast::NodeId) {
+ _: &LateContext,
+ _: &hir::VariantData,
+ _: ast::Name,
+ _: &hir::Generics,
+ item_id: ast::NodeId) {
self.struct_def_stack.push(item_id);
}
fn check_struct_def_post(&mut self,
- _: &LateContext<'a, 'tcx>,
- _: &'tcx hir::VariantData,
- _: ast::Name,
- _: &'tcx hir::Generics,
- item_id: ast::NodeId) {
+ _: &LateContext,
+ _: &hir::VariantData,
+ _: ast::Name,
+ _: &hir::Generics,
+ item_id: ast::NodeId) {
let popped = self.struct_def_stack.pop().expect("empty struct_def_stack");
assert!(popped == item_id);
}
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate");
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
let desc = match it.node {
hir::ItemFn(..) => "a function",
hir::ItemMod(..) => "a module",
self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc);
}
- fn check_trait_item(&mut self,
- cx: &LateContext<'a, 'tcx>,
- trait_item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) {
if self.private_traits.contains(&trait_item.id) {
return;
}
desc);
}
- fn check_impl_item(&mut self,
- cx: &LateContext<'a, 'tcx>,
- impl_item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
// If the method is an impl for a trait, don't doc.
if method_context(cx, impl_item.id, impl_item.span) == MethodLateContext::TraitImpl {
return;
desc);
}
- fn check_struct_field(&mut self,
- cx: &LateContext<'a, 'tcx>,
- sf: &'tcx hir::StructField) {
+ fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) {
if !sf.is_positional() {
if sf.vis == hir::Public || self.in_variant {
let cur_struct_def = *self.struct_def_stack
}
}
- fn check_variant(&mut self,
- cx: &LateContext<'a, 'tcx>,
- v: &'tcx hir::Variant,
- _: &'tcx hir::Generics) {
+ fn check_variant(&mut self, cx: &LateContext, v: &hir::Variant, _: &hir::Generics) {
self.check_missing_docs_attrs(cx,
Some(v.node.data.id()),
&v.node.attrs,
self.in_variant = true;
}
- fn check_variant_post(&mut self,
- _: &LateContext<'a, 'tcx>,
- _: &'tcx hir::Variant,
- _: &'tcx hir::Generics) {
+ fn check_variant_post(&mut self, _: &LateContext, _: &hir::Variant, _: &hir::Generics) {
assert!(self.in_variant);
self.in_variant = false;
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
if !cx.access_levels.is_reachable(item.id) {
return;
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
if !cx.access_levels.is_reachable(item.id) {
return;
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion {
fn check_fn(&mut self,
- cx: &LateContext<'a, 'tcx>,
- fn_kind: FnKind<'tcx>,
- _: &'tcx hir::FnDecl,
- blk: &'tcx hir::Expr,
- sp: Span,
- id: ast::NodeId) {
+ cx: &LateContext,
+ fn_kind: FnKind,
+ _: &hir::FnDecl,
+ blk: &hir::Expr,
+ sp: Span,
+ id: ast::NodeId) {
let method = match fn_kind {
FnKind::ItemFn(..) => None,
FnKind::Method(..) => {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
if cx.sess().plugin_registrar_fn.get().is_some() {
// We're compiling a plugin; it's fine to link other plugins.
return;
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemFn(.., ref generics, _) => {
if attr::contains_name(&it.attrs, "no_mangle") {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
use syntax::abi::Abi::RustIntrinsic;
let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures {
- fn check_attribute(&mut self,
- ctx: &LateContext<'a, 'tcx>,
- attr: &'tcx ast::Attribute) {
+ fn check_attribute(&mut self, ctx: &LateContext, attr: &ast::Attribute) {
if attr.meta().check_name("feature") {
if let Some(items) = attr.meta().meta_item_list() {
for item in items {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
- fn check_item(&mut self, ctx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, ctx: &LateContext, item: &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() {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
match e.node {
hir::ExprUnary(hir::UnNeg, ref expr) => {
if let hir::ExprLit(ref lit) = expr.node {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &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 {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &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
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedMut {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
if let hir::ExprMatch(_, ref arms, _) = e.node {
for a in arms {
self.check_unused_mut_pat(cx, &a.pats)
}
}
- fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
+ fn check_stmt(&mut self, cx: &LateContext, s: &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));
}
fn check_fn(&mut self,
- cx: &LateContext<'a, 'tcx>,
- _: FnKind<'tcx>,
- decl: &'tcx hir::FnDecl,
- _: &'tcx hir::Expr,
- _: Span,
- _: ast::NodeId) {
+ cx: &LateContext,
+ _: FnKind,
+ decl: &hir::FnDecl,
+ _: &hir::Expr,
+ _: Span,
+ _: ast::NodeId) {
for a in &decl.inputs {
self.check_unused_mut_pat(cx, slice::ref_slice(&a.pat));
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
- fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
+ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
let expr = match s.node {
hir::StmtSemi(ref expr, _) => &**expr,
_ => return,
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedUnsafe {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &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) &&
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
- fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx hir::Stmt) {
+ fn check_stmt(&mut self, cx: &LateContext, s: &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");
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
- fn check_attribute(&mut self,
- cx: &LateContext<'a, 'tcx>,
- attr: &'tcx ast::Attribute) {
+ fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
debug!("checking attribute: {:?}", attr);
// Note that check_name() marks the attribute as used if it matches.
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
+ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
match e.node {
hir::ExprBox(_) => {}
_ => return,
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext, krate: &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]");
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &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'"),
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext, krate: &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]");
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext, it: &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'"),
}
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,
+ fn check_fn(&mut self, cx: &LateContext,
+ fk: FnKind, _: &hir::FnDecl, expr: &hir::Expr,
span: Span, node: ast::NodeId)
{
if let FnKind::Closure(..) = fk { return }