impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
let expr = match s.node {
- hir::StmtSemi(ref expr, _) => &**expr,
+ hir::StmtKind::Semi(ref expr, _) => &**expr,
_ => return,
};
// attribute which does exist on the comparison trait methods
hir::ExprBinary(bin_op, ..) => {
match bin_op.node {
- hir::BiEq | hir::BiLt | hir::BiLe | hir::BiNe | hir::BiGe | hir::BiGt => {
+ hir::BinOpKind::Eq | hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Ne | hir::BinOpKind::Ge | hir::BinOpKind::Gt => {
Some("comparison")
},
- hir::BiAdd | hir::BiSub | hir::BiDiv | hir::BiMul | hir::BiRem => {
+ hir::BinOpKind::Add | hir::BinOpKind::Sub | hir::BinOpKind::Div | hir::BinOpKind::Mul | hir::BinOpKind::Rem => {
Some("arithmetic operation")
},
- hir::BiAnd | hir::BiOr => {
+ hir::BinOpKind::And | hir::BinOpKind::Or => {
Some("logical operation")
},
- hir::BiBitXor | hir::BiBitAnd | hir::BiBitOr | hir::BiShl | hir::BiShr => {
+ hir::BinOpKind::BitXor | hir::BinOpKind::BitAnd | hir::BinOpKind::BitOr | hir::BinOpKind::Shl | hir::BinOpKind::Shr => {
Some("bitwise operation")
},
}
if attr.check_name("must_use") {
let mut msg = format!("unused {}`{}` which must be used",
describe_path, cx.tcx.item_path_str(def_id));
- // check for #[must_use="..."]
- if let Some(s) = attr.value_str() {
- msg.push_str(": ");
- msg.push_str(&s.as_str());
+ let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg);
+ // check for #[must_use = "..."]
+ if let Some(note) = attr.value_str() {
+ err.note(¬e.as_str());
}
- cx.span_lint(UNUSED_MUST_USE, sp, &msg);
+ err.emit();
return true;
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
- if let hir::StmtSemi(ref expr, _) = s.node {
- if let hir::ExprPath(_) = expr.node {
+ if let hir::StmtKind::Semi(ref expr, _) = s.node {
+ if let hir::ExprKind::Path(_) = 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, attr: &ast::Attribute) {
debug!("checking attribute: {:?}", attr);
- let name = unwrap_or!(attr.name(), return);
-
// Note that check_name() marks the attribute as used if it matches.
for &(ref name, ty, _) in BUILTIN_ATTRIBUTES {
match ty {
}
}
+ let name = attr.name();
if !attr::is_used(attr) {
debug!("Emitting warning for: {:?}", attr);
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
// Trigger the lint if the nested item is a non-self single item
let node_ident;
match items[0].0.kind {
- ast::UseTreeKind::Simple(rename) => {
+ ast::UseTreeKind::Simple(rename, ..) => {
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
if orig_ident.name == keywords::SelfValue.name() {
return;