aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_plugins/unrooted_must_root.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2019-01-03 16:17:06 -0800
committerManish Goregaokar <manishsmail@gmail.com>2019-01-04 09:34:04 -0800
commite28e73c81fcbed570955f2175d56ee794de6882a (patch)
tree9574591ce539ea4d458a31d7e37325b8646c3294 /components/script_plugins/unrooted_must_root.rs
parent7a64588efaf45f307677b4a025b241fe3fc3b380 (diff)
downloadservo-e28e73c81fcbed570955f2175d56ee794de6882a.tar.gz
servo-e28e73c81fcbed570955f2175d56ee794de6882a.zip
Exempt Rc<Promise> from unrooted_must_root
fixes #22504
Diffstat (limited to 'components/script_plugins/unrooted_must_root.rs')
-rw-r--r--components/script_plugins/unrooted_must_root.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/components/script_plugins/unrooted_must_root.rs b/components/script_plugins/unrooted_must_root.rs
index 73ebcd76065..58700e5d6b6 100644
--- a/components/script_plugins/unrooted_must_root.rs
+++ b/components/script_plugins/unrooted_must_root.rs
@@ -45,12 +45,24 @@ fn is_unrooted_ty(cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool
let mut ret = false;
ty.maybe_walk(|t| {
match t.sty {
- ty::Adt(did, _) => {
+ ty::Adt(did, substs) => {
if cx.tcx.has_attr(did.did, "must_root") {
ret = true;
false
} else if cx.tcx.has_attr(did.did, "allow_unrooted_interior") {
false
+ } else if match_def_path(cx, did.did, &["alloc", "rc", "Rc"]) {
+ // Rc<Promise> is okay
+ let inner = substs.type_at(0);
+ if let ty::Adt(did, _) = inner.sty {
+ if cx.tcx.has_attr(did.did, "allow_unrooted_in_rc") {
+ false
+ } else {
+ true
+ }
+ } else {
+ true
+ }
} else if match_def_path(cx, did.did, &["core", "cell", "Ref"]) ||
match_def_path(cx, did.did, &["core", "cell", "RefMut"]) ||
match_def_path(cx, did.did, &["core", "slice", "Iter"]) ||