X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_lint%2Funused.rs;h=af43030d0f2aecf9e5038f4385d0995aded2e424;hb=f49f38871389041671cc710a044e8360091840a3;hp=a93946df68f9235d484b50da6fae287bada285ab;hpb=aba84894d1879a7429d5bc20d0bfdca3471685de;p=rust.git diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index a93946df68f..af43030d0f2 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -1,6 +1,7 @@ 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; @@ -25,7 +26,7 @@ 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! { @@ -277,12 +278,6 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) { } } -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, @@ -603,6 +598,25 @@ fn check_param(&mut self, cx: &EarlyContext<'_>, param: &ast::Param) { 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! {