mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
Ensure that Reflectors are the first field
This commit is contained in:
parent
d761877ef6
commit
21a888341d
14 changed files with 146 additions and 21 deletions
|
@ -272,9 +272,18 @@ impl LintPass for InheritancePass {
|
|||
// #[_dom_struct_marker] here without also checking for #[dom_struct]
|
||||
if ty::has_attr(cx.tcx, ast_util::local_def(id), "_dom_struct_marker") {
|
||||
// Find the reflector, if any
|
||||
let reflector_span = def.fields.iter()
|
||||
.find(|f| match_lang_ty(cx, &*f.node.ty, "reflector"))
|
||||
.map(|f| f.span);
|
||||
let reflector_span = def.fields.iter().enumerate()
|
||||
.find(|&(ctr, f)| {
|
||||
if match_lang_ty(cx, &*f.node.ty, "reflector") {
|
||||
if ctr > 0 {
|
||||
cx.span_lint(INHERITANCE_INTEGRITY, f.span,
|
||||
"The Reflector should be the first field of the DOM struct");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
})
|
||||
.map(|(_, f)| f.span);
|
||||
// Find all #[dom_struct] fields
|
||||
let dom_spans: Vec<_> = def.fields.iter().enumerate().filter_map(|(ctr, f)| {
|
||||
if let ast::TyPath(_, _, ty_id) = f.node.ty.node {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue