use rustc::hir::{Crate, Expr, ExprKind, QPath};
+use rustc::impl_lint_pass;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, impl_lint_pass};
+use rustc_session::declare_tool_lint;
+use syntax::ast::AttrKind;
use syntax::symbol::sym;
use crate::utils::{is_entrypoint_fn, snippet, span_help_and_lint};
impl LateLintPass<'_, '_> for MainRecursion {
fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
- self.has_no_std_attr = krate.attrs.iter().any(|attr| attr.path == sym::no_std);
+ self.has_no_std_attr = krate.attrs.iter().any(|attr| {
+ if let AttrKind::Normal(ref attr) = attr.kind {
+ attr.path == sym::no_std
+ } else {
+ false
+ }
+ });
}
fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) {
}
if_chain! {
- if let ExprKind::Call(func, _) = &expr.node;
- if let ExprKind::Path(path) = &func.node;
+ if let ExprKind::Call(func, _) = &expr.kind;
+ if let ExprKind::Path(path) = &func.kind;
if let QPath::Resolved(_, path) = &path;
if let Some(def_id) = path.res.opt_def_id();
if is_entrypoint_fn(cx, def_id);