aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/lints
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-05-14 21:08:02 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-05-14 21:16:48 +0200
commit78e3b1a326b593546b1d50ee9afcfd703d149ddc (patch)
tree0dd07ead07ae016888724760f6109eba95ae6b19 /components/plugins/lints
parentd6509dc4c6a1ec0a0c48c0e5a669a93334407f29 (diff)
downloadservo-78e3b1a326b593546b1d50ee9afcfd703d149ddc.tar.gz
servo-78e3b1a326b593546b1d50ee9afcfd703d149ddc.zip
Update to Rust 1.10.0-nightly (2b79e05a0 2016-05-13)
Diffstat (limited to 'components/plugins/lints')
-rw-r--r--components/plugins/lints/unrooted_must_root.rs46
1 files changed, 19 insertions, 27 deletions
diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs
index 5f9f63a9e4b..9a9a43d62dc 100644
--- a/components/plugins/lints/unrooted_must_root.rs
+++ b/components/plugins/lints/unrooted_must_root.rs
@@ -106,15 +106,13 @@ impl LateLintPass for UnrootedPass {
let ref map = cx.tcx.map;
if map.expect_item(map.get_parent(var.node.data.id())).attrs.iter().all(|a| !a.check_name("must_root")) {
match var.node.data {
- hir::VariantData::Tuple(ref vec, _) => {
- for ty in vec {
- cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty.id).map(|t| {
- if is_unrooted_ty(cx, t, false) {
- cx.span_lint(UNROOTED_MUST_ROOT, ty.ty.span,
- "Type must be rooted, use #[must_root] on \
- the enum definition to propagate")
- }
- });
+ hir::VariantData::Tuple(ref fields, _) => {
+ for ref field in fields {
+ if is_unrooted_ty(cx, cx.tcx.node_id_to_type(field.id), false) {
+ cx.span_lint(UNROOTED_MUST_ROOT, field.ty.span,
+ "Type must be rooted, use #[must_root] on \
+ the enum definition to propagate")
+ }
}
}
_ => () // Struct variants already caught by check_struct_def
@@ -123,7 +121,7 @@ impl LateLintPass for UnrootedPass {
}
/// Function arguments that are #[must_root] types are not allowed
fn check_fn(&mut self, cx: &LateContext, kind: visit::FnKind, decl: &hir::FnDecl,
- block: &hir::Block, span: codemap::Span, _id: ast::NodeId) {
+ block: &hir::Block, span: codemap::Span, id: ast::NodeId) {
let in_new_function = match kind {
visit::FnKind::ItemFn(n, _, _, _, _, _, _) |
visit::FnKind::Method(n, _, _, _) => {
@@ -132,27 +130,21 @@ impl LateLintPass for UnrootedPass {
visit::FnKind::Closure(_) => return,
};
- for arg in &decl.inputs {
- cx.tcx.ast_ty_to_ty_cache.borrow().get(&arg.ty.id).map(|t| {
- if is_unrooted_ty(cx, t, false) {
- if in_derive_expn(cx, span) {
- return;
- }
+ if !in_derive_expn(cx, span) {
+ let ty = cx.tcx.node_id_to_type(id);
+
+ for (arg, ty) in decl.inputs.iter().zip(ty.fn_args().0.iter()) {
+ if is_unrooted_ty(cx, ty, false) {
cx.span_lint(UNROOTED_MUST_ROOT, arg.ty.span, "Type must be rooted")
}
- });
- }
+ }
- if !in_new_function {
- if let hir::Return(ref ty) = decl.output {
- cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty.id).map(|t| {
- if is_unrooted_ty(cx, t, false) {
- if in_derive_expn(cx, span) {
- return;
- }
- cx.span_lint(UNROOTED_MUST_ROOT, ty.span, "Type must be rooted")
+ if !in_new_function {
+ if let ty::FnOutput::FnConverging(ret) = ty.fn_ret().0 {
+ if is_unrooted_ty(cx, ret, false) {
+ cx.span_lint(UNROOTED_MUST_ROOT, decl.output.span(), "Type must be rooted")
}
- });
+ }
}
}