mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Upgrade to rustc 1.17.0-nightly (ea7a6486a 2017-02-04)
This commit is contained in:
parent
fb7f65fc57
commit
1aa0b16299
4 changed files with 16 additions and 14 deletions
|
@ -56,11 +56,13 @@ fn is_unrooted_ty(cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool
|
|||
|| match_def_path(cx, did.did, &["std", "collections", "hash", "map", "VacantEntry"]) {
|
||||
// Structures which are semantically similar to an &ptr.
|
||||
false
|
||||
} else if did.is_box() && in_new_function {
|
||||
// box in new() is okay
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
},
|
||||
ty::TyBox(..) if in_new_function => false, // box in new() is okay
|
||||
ty::TyRef(..) => false, // don't recurse down &ptrs
|
||||
ty::TyRawPtr(..) => false, // don't recurse down *ptrs
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => false,
|
||||
|
@ -84,13 +86,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass {
|
|||
_n: ast::Name,
|
||||
_gen: &hir::Generics,
|
||||
id: ast::NodeId) {
|
||||
let item = match cx.tcx.map.get(id) {
|
||||
let item = match cx.tcx.hir.get(id) {
|
||||
ast_map::Node::NodeItem(item) => item,
|
||||
_ => cx.tcx.map.expect_item(cx.tcx.map.get_parent(id)),
|
||||
_ => cx.tcx.hir.expect_item(cx.tcx.hir.get_parent(id)),
|
||||
};
|
||||
if item.attrs.iter().all(|a| !a.check_name("must_root")) {
|
||||
for ref field in def.fields() {
|
||||
let def_id = cx.tcx.map.local_def_id(field.id);
|
||||
let def_id = cx.tcx.hir.local_def_id(field.id);
|
||||
if is_unrooted_ty(cx, cx.tcx.item_type(def_id), false) {
|
||||
cx.span_lint(UNROOTED_MUST_ROOT, field.span,
|
||||
"Type must be rooted, use #[must_root] on the struct definition to propagate")
|
||||
|
@ -101,12 +103,12 @@ 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) {
|
||||
let ref map = cx.tcx.map;
|
||||
let ref map = cx.tcx.hir;
|
||||
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 fields, _) => {
|
||||
for ref field in fields {
|
||||
let def_id = cx.tcx.map.local_def_id(field.id);
|
||||
let def_id = cx.tcx.hir.local_def_id(field.id);
|
||||
if is_unrooted_ty(cx, cx.tcx.item_type(def_id), false) {
|
||||
cx.span_lint(UNROOTED_MUST_ROOT, field.ty.span,
|
||||
"Type must be rooted, use #[must_root] on \
|
||||
|
@ -135,7 +137,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass {
|
|||
};
|
||||
|
||||
if !in_derive_expn(cx, span) {
|
||||
let def_id = cx.tcx.map.local_def_id(id);
|
||||
let def_id = cx.tcx.hir.local_def_id(id);
|
||||
let ty = cx.tcx.item_type(def_id);
|
||||
|
||||
for (arg, ty) in decl.inputs.iter().zip(ty.fn_args().0.iter()) {
|
||||
|
@ -224,6 +226,6 @@ impl<'a, 'b, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'b, 'tcx> {
|
|||
fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem) {}
|
||||
fn visit_ty(&mut self, _: &'tcx hir::Ty) { }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'tcx> {
|
||||
hir::intravisit::NestedVisitorMap::OnlyBodies(&self.cx.tcx.map)
|
||||
hir::intravisit::NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue