Auto merge of #14292 - servo:rustup, r=KiChjang

Update to Rust 1.15.0-nightly (1c448574b 2016-11-28)

<!-- 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/14292)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-29 12:20:58 -08:00 committed by GitHub
commit f159b5cb10
14 changed files with 207 additions and 228 deletions

View file

@ -10,6 +10,6 @@ path = "lib.rs"
proc-macro = true
[dependencies]
syn = "0.9"
syn = "0.10"
quote = "0.3"
synstructure = "0.2"
synstructure = "0.4"

View file

@ -24,7 +24,8 @@ fn expand_string(input: &str) -> String {
});
let name = &type_.ident;
let (impl_generics, ty_generics, mut where_clause) = type_.generics.split_for_impl();
let (impl_generics, ty_generics, where_clause) = type_.generics.split_for_impl();
let mut where_clause = where_clause.clone();
for param in &type_.generics.ty_params {
where_clause.predicates.push(syn::WherePredicate::BoundPredicate(syn::WhereBoundPredicate {
bound_lifetimes: Vec::new(),
@ -40,8 +41,6 @@ fn expand_string(input: &str) -> String {
}
let tokens = quote! {
#type_
impl #impl_generics ::dom::bindings::trace::JSTraceable for #name #ty_generics #where_clause {
#[inline]
#[allow(unused_variables, unused_imports)]

View file

@ -38,9 +38,6 @@ extern crate net_traits;
extern crate ordered_float;
extern crate parking_lot;
#[macro_use]
#[no_link]
extern crate plugins as servo_plugins;
#[macro_use]
extern crate profile_traits;
#[macro_use]
extern crate range;

View file

@ -29,7 +29,7 @@ extern crate syntax;
use rustc_plugin::Registry;
use syntax::ext::base::*;
use syntax::feature_gate::AttributeType::Whitelisted;
use syntax::parse::token::intern;
use syntax::symbol::Symbol;
// Public for documentation to show up
/// Handles the auto-deriving for `#[derive(JSTraceable)]`
@ -42,17 +42,24 @@ mod utils;
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(intern("_generate_reflector"),
MultiDecorator(box reflector::expand_reflector));
reg.register_syntax_extension(
Symbol::intern("dom_struct"),
MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(
Symbol::intern("_generate_reflector"),
MultiDecorator(box reflector::expand_reflector));
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass);
reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
reg.register_early_lint_pass(box lints::ban::BanPass);
reg.register_attribute("must_root".to_string(), Whitelisted);
reg.register_attribute("servo_lang".to_string(), Whitelisted);
reg.register_attribute("_dom_struct_marker".to_string(), Whitelisted);
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
reg.register_attribute("must_root".to_string(), Whitelisted);
reg.register_attribute("privatize".to_string(), Whitelisted);
reg.register_attribute("servo_lang".to_string(), Whitelisted);
register_clippy(reg);
}

View file

@ -44,22 +44,19 @@ impl LateLintPass for InheritancePass {
.map(|(_, f)| f.span);
// Find all #[dom_struct] fields
let dom_spans: Vec<_> = def.fields().iter().enumerate().filter_map(|(ctr, f)| {
if let hir::TyPath(..) = f.ty.node {
if let Some(&def::PathResolution { base_def: def, .. }) =
cx.tcx.def_map.borrow().get(&f.ty.id) {
if let def::Def::PrimTy(_) = def {
return None;
}
if cx.tcx.has_attr(def.def_id(), "_dom_struct_marker") {
// If the field is not the first, it's probably
// being misused (a)
if ctr > 0 {
cx.span_lint(INHERITANCE_INTEGRITY, f.span,
"Bare DOM structs should only be used as the first field of a \
DOM struct. Consider using JS<T> instead.");
}
return Some(f.span)
if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = f.ty.node {
if let def::Def::PrimTy(_) = path.def {
return None;
}
if cx.tcx.has_attr(path.def.def_id(), "_dom_struct_marker") {
// If the field is not the first, it's probably
// being misused (a)
if ctr > 0 {
cx.span_lint(INHERITANCE_INTEGRITY, f.span,
"Bare DOM structs should only be used as the first field of a \
DOM struct. Consider using JS<T> instead.");
}
return Some(f.span)
}
}
None

View file

@ -25,15 +25,15 @@ impl LateLintPass for TransmutePass {
match ex.node {
hir::ExprCall(ref expr, ref args) => {
match expr.node {
hir::ExprPath(_, ref path) => {
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
if path.segments.last()
.map_or(false, |ref segment| segment.name.as_str() == "transmute") &&
.map_or(false, |ref segment| &*segment.name.as_str() == "transmute") &&
args.len() == 1 {
let tcx = cx.tcx;
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
&format!("Transmute to {:?} from {:?} detected",
tcx.expr_ty(ex),
tcx.expr_ty(&**args.get(0).unwrap())
tcx.tables().expr_ty(ex),
tcx.tables().expr_ty(&args.get(0).unwrap())
));
}
}

View file

@ -90,7 +90,8 @@ impl LateLintPass for UnrootedPass {
};
if item.attrs.iter().all(|a| !a.check_name("must_root")) {
for ref field in def.fields() {
if is_unrooted_ty(cx, cx.tcx.node_id_to_type(field.id), false) {
let def_id = cx.tcx.map.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")
}
@ -105,7 +106,8 @@ impl LateLintPass for UnrootedPass {
match var.node.data {
hir::VariantData::Tuple(ref fields, _) => {
for ref field in fields {
if is_unrooted_ty(cx, cx.tcx.node_id_to_type(field.id), false) {
let def_id = cx.tcx.map.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 \
the enum definition to propagate")
@ -118,17 +120,18 @@ 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) {
body: &hir::Expr, span: codemap::Span, id: ast::NodeId) {
let in_new_function = match kind {
visit::FnKind::ItemFn(n, _, _, _, _, _, _) |
visit::FnKind::Method(n, _, _, _) => {
n.as_str() == "new" || n.as_str().starts_with("new_")
&*n.as_str() == "new" || n.as_str().starts_with("new_")
}
visit::FnKind::Closure(_) => return,
};
if !in_derive_expn(cx, span) {
let ty = cx.tcx.node_id_to_type(id);
let def_id = cx.tcx.map.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()) {
if is_unrooted_ty(cx, ty, false) {
@ -147,7 +150,7 @@ impl LateLintPass for UnrootedPass {
cx: cx,
in_new_function: in_new_function,
};
visit::walk_block(&mut visitor, block);
visit::walk_expr(&mut visitor, body);
}
}
@ -161,7 +164,7 @@ impl<'a, 'b: 'a, 'tcx: 'a+'b> visit::Visitor<'a> for FnDefVisitor<'a, 'b, 'tcx>
let cx = self.cx;
fn require_rooted(cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr) {
let ty = cx.tcx.expr_ty(&*subexpr);
let ty = cx.tcx.tables().expr_ty(&subexpr);
if is_unrooted_ty(cx, ty, in_new_function) {
cx.span_lint(UNROOTED_MUST_ROOT,
subexpr.span,
@ -194,8 +197,8 @@ impl<'a, 'b: 'a, 'tcx: 'a+'b> visit::Visitor<'a> for FnDefVisitor<'a, 'b, 'tcx>
fn visit_pat(&mut self, pat: &'a hir::Pat) {
let cx = self.cx;
if let hir::PatKind::Binding(hir::BindingMode::BindByValue(_), _, _) = pat.node {
let ty = cx.tcx.pat_ty(pat);
if let hir::PatKind::Binding(hir::BindingMode::BindByValue(_), _, _, _) = pat.node {
let ty = cx.tcx.tables().pat_ty(pat);
if is_unrooted_ty(cx, ty, self.in_new_function) {
cx.span_lint(UNROOTED_MUST_ROOT,
pat.span,
@ -207,9 +210,9 @@ impl<'a, 'b: 'a, 'tcx: 'a+'b> visit::Visitor<'a> for FnDefVisitor<'a, 'b, 'tcx>
}
fn visit_fn(&mut self, kind: visit::FnKind<'a>, decl: &'a hir::FnDecl,
block: &'a hir::Block, span: codemap::Span, id: ast::NodeId) {
body: &'a hir::Expr, span: codemap::Span, id: ast::NodeId) {
if let visit::FnKind::Closure(_) = kind {
visit::walk_fn(self, kind, decl, block, span, id);
visit::walk_fn(self, kind, decl, body, span, id);
}
}

View file

@ -21,7 +21,7 @@ pub fn match_ty_unwrap<'a>(ty: &'a ast::Ty, segments: &[&str]) -> Option<&'a [P<
// I could muck around with the maps and find the full path
// however the more efficient way is to simply reverse the iterators and zip them
// which will compare them in reverse until one of them runs out of segments
if seg.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name.as_str() == *b) {
if seg.iter().rev().zip(segments.iter().rev()).all(|(a, b)| &*a.identifier.name.as_str() == *b) {
match seg.last() {
Some(&ast::PathSegment { parameters: ast::PathParameters::AngleBracketed(ref a), .. }) => {
Some(&a.types)
@ -38,13 +38,8 @@ pub fn match_ty_unwrap<'a>(ty: &'a ast::Ty, segments: &[&str]) -> Option<&'a [P<
/// Checks if a type has a #[servo_lang = "str"] attribute
pub fn match_lang_ty(cx: &LateContext, ty: &hir::Ty, value: &str) -> bool {
match ty.node {
hir::TyPath(..) => {},
_ => return false,
}
let def = match cx.tcx.def_map.borrow().get(&ty.id) {
Some(&def::PathResolution { base_def: def, .. }) => def,
let def = match ty.node {
hir::TyPath(hir::QPath::Resolved(_, ref path)) => path.def,
_ => return false,
};
@ -57,17 +52,11 @@ pub fn match_lang_ty(cx: &LateContext, ty: &hir::Ty, value: &str) -> bool {
pub fn match_lang_did(cx: &LateContext, did: DefId, value: &str) -> bool {
cx.tcx.get_attrs(did).iter().any(|attr| {
match attr.node.value.node {
ast::MetaItemKind::NameValue(ref name, ref val) if &**name == "servo_lang" => {
match val.node {
ast::LitKind::Str(ref v, _) if &**v == value => {
mark_used(attr);
true
},
_ => false,
}
}
_ => false,
if attr.check_name("servo_lang") && attr.value_str().map_or(false, |v| v == value) {
mark_used(attr);
true
} else {
false
}
})
}
@ -91,7 +80,7 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
other.into_iter()
.map(|e| e.data)
.zip(path)
.all(|(nm, p)| nm.as_interned_str() == *p)
.all(|(nm, p)| &*nm.as_interned_str() == *p)
}
pub fn in_derive_expn(cx: &LateContext, span: Span) -> bool {

View file

@ -5,7 +5,6 @@
use cssparser::Parser;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding;
use dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
@ -82,7 +81,6 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule {
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-appendrule
fn AppendRule(&self, rule: DOMString) {
let global = self.global();
let window = global.as_window();
let rule = Keyframe::parse(&rule, self.cssrule.parent_stylesheet().style_stylesheet(),
ParserContextExtraData::default());
if let Ok(rule) = rule {

View file

@ -5,7 +5,6 @@
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CSSRuleListBinding;
use dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};

View file

@ -649,7 +649,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
for debug_string in opt_match.opt_strs("Z") {
if let Err(e) = debug_options.extend(debug_string) {
return args_fail(&format!("error: unrecognized debug option: {}", e));
args_fail(&format!("error: unrecognized debug option: {}", e));
}
}