diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-02-15 20:49:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-15 20:49:47 -0800 |
commit | 84a44a401424852bc44ef5e751e84544ed892e70 (patch) | |
tree | 6797c83b3407331fd4ce4a8e6660eecd9eee534c /components/plugins/utils.rs | |
parent | ab197de04f51f4bc2ed504b846e12a0abedf8f1f (diff) | |
parent | 1464c11cea5e737be4ccc30dc5132f297bc59e0c (diff) | |
download | servo-84a44a401424852bc44ef5e751e84544ed892e70.tar.gz servo-84a44a401424852bc44ef5e751e84544ed892e70.zip |
Auto merge of #15567 - nox:plugin, r=SimonSapin
Replace inheritance_integrity by trait shenanigans
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15567)
<!-- Reviewable:end -->
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"])` |