aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/utils.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-10-15 18:46:33 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-10-16 01:15:28 +0530
commit7022bedba3ec9652490ce693e15674cf1ff7e36c (patch)
tree99a1b4887cf5d253762bad46ce0d9d344700704a /components/plugins/utils.rs
parent417cf5738e4609f4b2e34e9e0c4f7ef68f087432 (diff)
downloadservo-7022bedba3ec9652490ce693e15674cf1ff7e36c.tar.gz
servo-7022bedba3ec9652490ce693e15674cf1ff7e36c.zip
Fix unrooted_must_root lint to handle arguments/return types properly (fixes #8022)
Diffstat (limited to 'components/plugins/utils.rs')
-rw-r--r--components/plugins/utils.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/components/plugins/utils.rs b/components/plugins/utils.rs
index 7576437a939..d9816c7a921 100644
--- a/components/plugins/utils.rs
+++ b/components/plugins/utils.rs
@@ -3,12 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use rustc::front::map as ast_map;
-use rustc::lint::LateContext;
+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};
use syntax::ptr::P;
@@ -100,3 +101,16 @@ 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))
}
+
+pub fn in_derive_expn(cx: &LateContext, span: Span) -> bool {
+ cx.sess().codemap().with_expn_info(span.expn_id,
+ |info| {
+ if let Some(i) = info {
+ if let ExpnFormat::MacroAttribute(n) = i.callee.format {
+ if n.as_str().contains("derive") {
+ true
+ } else { false }
+ } else { false }
+ } else { false }
+ })
+}