mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add inheritance-checking lint
This commit is contained in:
parent
7d65673561
commit
d761877ef6
9 changed files with 139 additions and 21 deletions
|
@ -11,9 +11,9 @@ use utils::match_ty_unwrap;
|
|||
|
||||
|
||||
pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item, push: |P<Item>|) {
|
||||
|
||||
if let ast::ItemStruct(ref def, _) = item.node {
|
||||
let struct_name = item.ident;
|
||||
// This path has to be hardcoded, unfortunately, since we can't resolve paths at expansion time
|
||||
match def.fields.iter().find(|f| match_ty_unwrap(&*f.node.ty, &["dom", "bindings", "utils", "Reflector"]).is_some()) {
|
||||
// If it has a field that is a Reflector, use that
|
||||
Some(f) => {
|
||||
|
@ -28,10 +28,6 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
|
|||
impl_item.map(|it| push(it))
|
||||
},
|
||||
// Or just call it on the first field (supertype).
|
||||
// TODO: Write a lint to ensure that this first field is indeed a #[dom_struct],
|
||||
// and the only such field in the struct definition (including reflectors)
|
||||
// Unfortunately we can't do it here itself because a def_map (from middle) is not available
|
||||
// at expansion time
|
||||
None => {
|
||||
let field_name = def.fields[0].node.ident();
|
||||
let impl_item = quote_item!(cx,
|
||||
|
@ -45,6 +41,6 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
|
|||
}
|
||||
};
|
||||
} else {
|
||||
cx.span_bug(span, "#[dom_struct] seems to have been applied to a non-struct");
|
||||
cx.span_err(span, "#[dom_struct] seems to have been applied to a non-struct");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue