diff options
author | Peter <ptrgonda@gmail.com> | 2015-05-15 16:27:07 -0400 |
---|---|---|
committer | Peter <ptrgonda@gmail.com> | 2015-05-20 10:58:30 -0400 |
commit | 717b443eec9dac822d4599f93c723440f1c4ec9d (patch) | |
tree | c8af879ce237978070f7ad7819ad6fbb9bae4ef4 /components/plugins/lints/unrooted_must_root.rs | |
parent | f554ab1c4d0253e168247e5b3846d5461e0ede99 (diff) | |
download | servo-717b443eec9dac822d4599f93c723440f1c4ec9d.tar.gz servo-717b443eec9dac822d4599f93c723440f1c4ec9d.zip |
fixes #6069
Diffstat (limited to 'components/plugins/lints/unrooted_must_root.rs')
-rw-r--r-- | components/plugins/lints/unrooted_must_root.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index 7a39f6cc4d5..e819f8d0e4d 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -2,7 +2,7 @@ * 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 syntax::{ast, codemap, visit}; +use syntax::{ast, codemap, visit, ast_map}; use syntax::attr::AttrMetaMethods; use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty::expr_ty; @@ -52,7 +52,11 @@ impl LintPass for UnrootedPass { } /// All structs containing #[must_root] types must be #[must_root] themselves fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) { - if cx.tcx.map.expect_item(id).attrs.iter().all(|a| !a.check_name("must_root")) { + let item = match cx.tcx.map.get(id) { + ast_map::Node::NodeItem(item) => item, + _ => cx.tcx.map.expect_item(cx.tcx.map.get_parent(id)), + }; + if item.attrs.iter().all(|a| !a.check_name("must_root")) { for ref field in def.fields.iter() { lint_unrooted_ty(cx, &*field.node.ty, "Type must be rooted, use #[must_root] on the struct definition to propagate"); |