diff options
Diffstat (limited to 'components/plugins/utils.rs')
-rw-r--r-- | components/plugins/utils.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/components/plugins/utils.rs b/components/plugins/utils.rs index cbda117d75c..50ff2a959a9 100644 --- a/components/plugins/utils.rs +++ b/components/plugins/utils.rs @@ -2,18 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use rustc::hir::{self, def}; use rustc::hir::def_id::DefId; use rustc::lint::{LateContext, LintContext}; use syntax::ast; -use syntax::attr::mark_used; use syntax::codemap::{ExpnFormat, Span}; use syntax::ptr::P; - /// Matches a type with a provided string, and returns its type parameters if successful -/// -/// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes) pub fn match_ty_unwrap<'a>(ty: &'a ast::Ty, segments: &[&str]) -> Option<&'a [P<ast::Ty>]> { match ty.node { ast::TyKind::Path(_, ast::Path { segments: ref seg, .. }) => { @@ -42,31 +37,6 @@ pub fn match_ty_unwrap<'a>(ty: &'a ast::Ty, segments: &[&str]) -> Option<&'a [P< } } -/// Checks if a type has a #[servo_lang = "str"] attribute -pub fn match_lang_ty(cx: &LateContext, ty: &hir::Ty, value: &str) -> bool { - let def = match ty.node { - hir::TyPath(hir::QPath::Resolved(_, ref path)) => path.def, - _ => return false, - }; - - if let def::Def::PrimTy(_) = def { - return false; - } - - match_lang_did(cx, def.def_id(), value) -} - -pub fn match_lang_did(cx: &LateContext, did: DefId, value: &str) -> bool { - cx.tcx.get_attrs(did).iter().any(|attr| { - if attr.check_name("servo_lang") && attr.value_str().map_or(false, |v| v == value) { - mark_used(attr); - true - } else { - false - } - }) -} - /// check if a DefId's path matches the given absolute type path /// usage e.g. with /// `match_def_path(cx, id, &["core", "option", "Option"])` |