use rustc::hir::def::{Res, DefKind};
use rustc::hir::def_id::DefId;
use rustc::lint;
+use rustc::lint::builtin::UNUSED_ATTRIBUTES;
use rustc::ty::{self, Ty};
use rustc::ty::adjustment;
use rustc_data_structures::fx::FxHashMap;
pub UNUSED_MUST_USE,
Warn,
"unused result of a type flagged as `#[must_use]`",
- report_in_external_macro: true
+ report_in_external_macro
}
declare_lint! {
}
}
-declare_lint! {
- pub UNUSED_ATTRIBUTES,
- Warn,
- "detects attributes that were not used by the compiler"
-}
-
#[derive(Copy, Clone)]
pub struct UnusedAttributes {
builtin_attributes: &'static FxHashMap<Symbol, &'static BuiltinAttribute>,
fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
self.check_unused_parens_pat(cx, &arm.pat, false, false);
}
+
+ fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) {
+ if let &ast::TyKind::Paren(ref r) = &ty.kind {
+ match &r.kind {
+ &ast::TyKind::TraitObject(..) => {}
+ &ast::TyKind::ImplTrait(_, ref bounds) if bounds.len() > 1 => {}
+ _ => {
+ let pattern_text = if let Ok(snippet) = cx.sess().source_map()
+ .span_to_snippet(ty.span) {
+ snippet
+ } else {
+ pprust::ty_to_string(ty)
+ };
+
+ Self::remove_outer_parens(cx, ty.span, &pattern_text, "type", (false, false));
+ }
+ }
+ }
+ }
}
declare_lint! {