mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.
This commit is contained in:
parent
cf616b90a2
commit
16c7060bc8
153 changed files with 2095 additions and 1298 deletions
|
@ -21,8 +21,6 @@
|
|||
extern crate syntax;
|
||||
#[phase(plugin, link)]
|
||||
extern crate rustc;
|
||||
#[cfg(test)]
|
||||
extern crate sync;
|
||||
|
||||
use rustc::lint::LintPassObject;
|
||||
use rustc::plugin::Registry;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
use syntax::{ast, ast_util};
|
||||
use rustc::lint::{Context, LintPass, LintArray, Level};
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
use utils::match_lang_ty;
|
||||
|
||||
|
@ -42,7 +41,7 @@ impl LintPass 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 ast::TyPath(_, _, ty_id) = f.node.ty.node {
|
||||
if let ast::TyPath(_, ty_id) = f.node.ty.node {
|
||||
if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() {
|
||||
if ty::has_attr(cx.tcx, def_id, "_dom_struct_marker") {
|
||||
// If the field is not the first, it's probably
|
||||
|
|
|
@ -7,7 +7,6 @@ use syntax::ast::Public;
|
|||
use syntax::attr::AttrMetaMethods;
|
||||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
declare_lint!(PRIVATIZE, Deny,
|
||||
"Allows to enforce private fields for struct definitions")
|
||||
|
|
|
@ -6,7 +6,6 @@ use syntax::ast;
|
|||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
declare_lint!(STR_TO_STRING, Deny,
|
||||
"Warn when a String could use into_string() instead of to_string()")
|
||||
|
@ -33,13 +32,13 @@ impl LintPass for StrToStringPass {
|
|||
}
|
||||
|
||||
fn is_str(cx: &Context, expr: &ast::Expr) -> bool {
|
||||
fn walk_ty<'t>(ty: ty::t) -> ty::t {
|
||||
match ty::get(ty).sty {
|
||||
fn walk_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> {
|
||||
match ty.sty {
|
||||
ty::ty_ptr(ref tm) | ty::ty_rptr(_, ref tm) => walk_ty(tm.ty),
|
||||
_ => ty
|
||||
}
|
||||
}
|
||||
match ty::get(walk_ty(expr_ty(cx.tcx, expr))).sty {
|
||||
match walk_ty(expr_ty(cx.tcx, expr)).sty {
|
||||
ty::ty_str => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use syntax::ast;
|
|||
use syntax::attr::AttrMetaMethods;
|
||||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
use rustc::util::ppaux::Repr;
|
||||
|
||||
declare_lint!(TRANSMUTE_TYPE_LINT, Allow,
|
||||
|
@ -31,7 +30,7 @@ impl LintPass for TransmutePass {
|
|||
if path.segments.last()
|
||||
.map_or(false, |ref segment| segment.identifier.name.as_str() == "transmute")
|
||||
&& args.len() == 1 {
|
||||
let tcx = cx.tcx();
|
||||
let tcx = cx.tcx;
|
||||
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
|
||||
format!("Transmute to {} from {} detected",
|
||||
expr_ty(tcx, ex).repr(tcx),
|
||||
|
|
|
@ -7,7 +7,6 @@ use syntax::attr::AttrMetaMethods;
|
|||
use rustc::lint::{Context, LintPass, LintArray};
|
||||
use rustc::middle::ty::expr_ty;
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
use rustc::util::ppaux::Repr;
|
||||
use utils::unsafe_context;
|
||||
|
||||
|
@ -24,6 +23,7 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
|||
/// - Not being bound locally in a `let` statement, assignment, `for` loop, or `match` statement.
|
||||
///
|
||||
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a GC pass.
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct UnrootedPass;
|
||||
|
||||
// Checks if a type has the #[must_root] annotation.
|
||||
|
@ -33,7 +33,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
|||
match ty.node {
|
||||
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
|
||||
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
|
||||
ast::TyPath(_, _, id) => {
|
||||
ast::TyPath(_, id) => {
|
||||
match cx.tcx.def_map.borrow()[id].clone() {
|
||||
def::DefTy(def_id, _) => {
|
||||
if ty::has_attr(cx.tcx, def_id, "must_root") {
|
||||
|
@ -146,7 +146,7 @@ impl LintPass for UnrootedPass {
|
|||
};
|
||||
|
||||
let t = expr_ty(cx.tcx, &*expr);
|
||||
match ty::get(t).sty {
|
||||
match t.sty {
|
||||
ty::ty_struct(did, _) |
|
||||
ty::ty_enum(did, _) => {
|
||||
if ty::has_attr(cx.tcx, did, "must_root") {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use rustc::lint::Context;
|
||||
use rustc::middle::{ty, def};
|
||||
use rustc::middle::typeck::astconv::AstConv;
|
||||
|
||||
use syntax::ptr::P;
|
||||
use syntax::{ast, ast_map};
|
||||
|
@ -17,7 +16,7 @@ use syntax::attr::mark_used;
|
|||
/// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes)
|
||||
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
|
||||
match ty.node {
|
||||
TyPath(Path {segments: ref seg, ..}, _, _) => {
|
||||
TyPath(Path {segments: ref seg, ..}, _) => {
|
||||
// So ast::Path isn't the full path, just the tokens that were provided.
|
||||
// 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
|
||||
|
@ -40,7 +39,7 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]>
|
|||
/// Checks if a type has a #[servo_lang = "str"] attribute
|
||||
pub fn match_lang_ty(cx: &Context, ty: &Ty, value: &str) -> bool {
|
||||
let mut found = false;
|
||||
if let TyPath(_, _, ty_id) = ty.node {
|
||||
if let TyPath(_, ty_id) = ty.node {
|
||||
if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() {
|
||||
// Iterating through attributes is hard because of cross-crate defs
|
||||
ty::each_attr(cx.tcx, def_id, |attr| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue