mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Address review comments
This commit is contained in:
parent
d241826987
commit
f0b8391762
1 changed files with 7 additions and 10 deletions
|
@ -62,14 +62,11 @@ impl LintPass for TransmutePass {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
||||||
let ty = match ty.node {
|
match ty.node {
|
||||||
ast::TyBox(ref t) | ast::TyUniq(ref t) |
|
ast::TyBox(ref t) | ast::TyUniq(ref t) |
|
||||||
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
|
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
|
||||||
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => &**t,
|
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
|
||||||
_ => ty
|
ast::TyPath(_, _, id) => {
|
||||||
};
|
|
||||||
match ty.node {
|
|
||||||
ast::TyPath(_, _, id) => {
|
|
||||||
match cx.tcx.def_map.borrow().get_copy(&id) {
|
match cx.tcx.def_map.borrow().get_copy(&id) {
|
||||||
def::DefTy(def_id) => {
|
def::DefTy(def_id) => {
|
||||||
if ty::has_attr(cx.tcx, def_id, "must_root") {
|
if ty::has_attr(cx.tcx, def_id, "must_root") {
|
||||||
|
@ -80,7 +77,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LintPass for UnrootedPass {
|
impl LintPass for UnrootedPass {
|
||||||
|
@ -125,7 +122,7 @@ impl LintPass for UnrootedPass {
|
||||||
ast::DefaultBlock => {
|
ast::DefaultBlock => {
|
||||||
for arg in decl.inputs.iter() {
|
for arg in decl.inputs.iter() {
|
||||||
lint_unrooted_ty(cx, &*arg.ty,
|
lint_unrooted_ty(cx, &*arg.ty,
|
||||||
"Type must be rooted, use #[must_root] on the struct definition to propagate")
|
"Type must be rooted, use #[must_root] on the fn definition to propagate")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => () // fn is `unsafe`
|
_ => () // fn is `unsafe`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue