aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_plugins/unrooted_must_root.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-08-27 07:26:57 -0400
committerGitHub <noreply@github.com>2019-08-27 07:26:57 -0400
commitf79ec15d17a3fbdd5ac47aacbae898725d1a883b (patch)
tree79ec5ce7946e425abd157bada15b9aadd69d7fdd /components/script_plugins/unrooted_must_root.rs
parent245ce017e3ee985b8c69de0ef3b27f91a1d75144 (diff)
parente18846ae94f1d5f5e5e8b73aaffaf1dbbba19999 (diff)
downloadservo-f79ec15d17a3fbdd5ac47aacbae898725d1a883b.tar.gz
servo-f79ec15d17a3fbdd5ac47aacbae898725d1a883b.zip
Auto merge of #24054 - servo:rustup, r=jdm
Upgrade to rustc 1.39.0-nightly (521d78407 2019-08-25) <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24054) <!-- Reviewable:end -->
Diffstat (limited to 'components/script_plugins/unrooted_must_root.rs')
-rw-r--r--components/script_plugins/unrooted_must_root.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/components/script_plugins/unrooted_must_root.rs b/components/script_plugins/unrooted_must_root.rs
index d09dec3816a..bc99aa36d70 100644
--- a/components/script_plugins/unrooted_must_root.rs
+++ b/components/script_plugins/unrooted_must_root.rs
@@ -7,8 +7,8 @@ use rustc::hir::intravisit as visit;
use rustc::hir::{self, ExprKind, HirId};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
+use syntax::source_map;
use syntax::symbol::sym;
-use syntax::{ast, source_map};
declare_lint!(
UNROOTED_MUST_ROOT,
@@ -143,23 +143,15 @@ impl LintPass for UnrootedPass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass {
/// All structs containing #[must_root] types must be #[must_root] themselves
- fn check_struct_def(
- &mut self,
- cx: &LateContext<'a, 'tcx>,
- def: &'tcx hir::VariantData,
- _n: ast::Name,
- _gen: &'tcx hir::Generics,
- id: HirId,
- ) {
- let item = match cx.tcx.hir().get(id) {
- hir::Node::Item(item) => item,
- _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
- };
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
if item
.attrs
.iter()
- .all(|a| !a.check_name(self.symbols.must_root))
+ .any(|a| a.check_name(self.symbols.must_root))
{
+ return;
+ }
+ if let hir::ItemKind::Struct(def, ..) = &item.node {
for ref field in def.fields() {
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
if is_unrooted_ty(&self.symbols, cx, cx.tcx.type_of(def_id), false) {
@@ -171,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass {
}
/// All enums containing #[must_root] types must be #[must_root] themselves
- fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant, _gen: &hir::Generics) {
+ fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) {
let ref map = cx.tcx.hir();
if map
.expect_item(map.get_parent_item(var.id))