aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/utils.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-02-15 17:48:36 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-02-15 22:11:20 +0100
commita6d59d87145ad03a95c65e5f9b384b46a91687a4 (patch)
treefaeb12aa1dbe9c108d963b1fb04222d16a285a49 /components/plugins/utils.rs
parent37dab8f9f2727debc015c3a16416cd80e9b235d4 (diff)
downloadservo-a6d59d87145ad03a95c65e5f9b384b46a91687a4.tar.gz
servo-a6d59d87145ad03a95c65e5f9b384b46a91687a4.zip
Replace inheritance_integrity by trait shenanigans
For each derived DomObject impl, we also generate a dummy trait ShouldNotImplDomObject that is implemented for all T: DomObject. We then try to implement it for each field type except the first one. If compilation succeed, this means that field type doesn't implement DomObject itself otherwise it would break coherence rules. error[E0119]: conflicting implementations of trait `dom::xmlhttprequest::_IMPL_DOMOBJECT_FOR_XMLHttpRequest::ShouldNotImplDomObject` for type `((), SomeFieldTypeThatShouldNotImplementDomObject)`: --> /Users/nox/src/servo/components/script/dom/xmlhttprequest.rs:120:1 | 120 | #[dom_struct] | ^^^^^^^^^^^^^ | | | first implementation here | conflicting implementation for `((), SomeFieldTypeThatShouldNotImplementDomObject)`
Diffstat (limited to 'components/plugins/utils.rs')
-rw-r--r--components/plugins/utils.rs30
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"])`