use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc_ast::ast;
use rustc_ast::ast::{ExprKind, StmtKind};
-use rustc_ast::attr;
use rustc_ast::util::parser;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span, DUMMY_SP};
-use log::debug;
+use tracing::debug;
declare_lint! {
pub UNUSED_MUST_USE,
descr_post_path: &str,
) -> bool {
for attr in cx.tcx.get_attrs(def_id).iter() {
- if attr.check_name(sym::must_use) {
+ if cx.sess().check_name(attr, sym::must_use) {
cx.struct_span_lint(UNUSED_MUST_USE, span, |lint| {
let msg = format!(
"unused {}`{}`{} that must be used",
}
}
- if !attr::is_used(attr) {
+ if !cx.sess().is_attr_used(attr) {
debug!("emitting warning for: {:?}", attr);
cx.struct_span_lint(UNUSED_ATTRIBUTES, attr.span, |lint| {
lint.build("unused attribute").emit()
let mut err = lint.build(&span_msg);
let mut ate_left_paren = false;
let mut ate_right_paren = false;
- let parens_removed = pattern.trim_matches(|c| match c {
- '(' | '{' => {
- if ate_left_paren {
- false
- } else {
- ate_left_paren = true;
- true
+ let parens_removed = pattern
+ .trim_matches(|c| match c {
+ '(' | '{' => {
+ if ate_left_paren {
+ false
+ } else {
+ ate_left_paren = true;
+ true
+ }
}
- }
- ')' | '}' => {
- if ate_right_paren {
- false
- } else {
- ate_right_paren = true;
- true
+ ')' | '}' => {
+ if ate_right_paren {
+ false
+ } else {
+ ate_right_paren = true;
+ true
+ }
}
- }
- _ => false,
- });
+ _ => false,
+ })
+ .trim();
let replace = {
let mut replace = if keep_space.0 {