mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
fixes #6069
This commit is contained in:
parent
f554ab1c4d
commit
717b443eec
5 changed files with 17 additions and 13 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue