aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/utils.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-04-14 02:13:33 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-04-15 15:28:49 +0530
commite10c5807683274d52652a853ca0bbf6b71b63aca (patch)
treec3ff84bc0977e629dd5fb382ab107a6c09e850e8 /components/plugins/utils.rs
parent7faa3ed9cb87ebfa62554940e916bb7e4d04512b (diff)
downloadservo-e10c5807683274d52652a853ca0bbf6b71b63aca.tar.gz
servo-e10c5807683274d52652a853ca0bbf6b71b63aca.zip
Rust upgrade to 2016-04-12
Diffstat (limited to 'components/plugins/utils.rs')
-rw-r--r--components/plugins/utils.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/components/plugins/utils.rs b/components/plugins/utils.rs
index 29b09255936..b514e967d5b 100644
--- a/components/plugins/utils.rs
+++ b/components/plugins/utils.rs
@@ -2,11 +2,10 @@
* 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::front::map as ast_map;
+use rustc::hir::def_id::DefId;
+use rustc::hir::map as ast_map;
+use rustc::hir::{self, def};
use rustc::lint::{LateContext, LintContext};
-use rustc::middle::def;
-use rustc::middle::def_id::DefId;
-use rustc_front::hir;
use syntax::ast;
use syntax::attr::mark_used;
use syntax::codemap::{ExpnFormat, Span};
@@ -102,8 +101,22 @@ pub fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool {
/// usage e.g. with
/// `match_def_path(cx, id, &["core", "option", "Option"])`
pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
- cx.tcx.with_path(def_id, |iter| iter.map(|elem| elem.name())
- .zip(path.iter()).all(|(nm, p)| &nm.as_str() == p))
+ let krate = &cx.tcx.crate_name(def_id.krate);
+ if krate != &path[0] {
+ return false;
+ }
+
+ let path = &path[1..];
+ let other = cx.tcx.def_path(def_id).data;
+
+ if other.len() != path.len() {
+ return false;
+ }
+
+ other.into_iter()
+ .map(|e| e.data)
+ .zip(path)
+ .all(|(nm, p)| nm.as_interned_str() == *p)
}
pub fn in_derive_expn(cx: &LateContext, span: Span) -> bool {