mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Rust upgrade to nightly 20151002
This commit is contained in:
parent
ba2714f4f6
commit
48b3259c90
8 changed files with 52 additions and 54 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use rustc::lint::{LateContext, LintPass, LintArray, Level, LateLintPass, LintContext};
|
||||
use rustc::middle::def;
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc_front::hir;
|
||||
use syntax::ast;
|
||||
use utils::match_lang_ty;
|
||||
|
@ -25,11 +24,11 @@ impl LintPass for InheritancePass {
|
|||
}
|
||||
|
||||
impl LateLintPass for InheritancePass {
|
||||
fn check_struct_def(&mut self, cx: &LateContext, def: &hir::StructDef, _i: ast::Ident,
|
||||
fn check_struct_def(&mut self, cx: &LateContext, def: &hir::StructDef, _n: ast::Name,
|
||||
_gen: &hir::Generics, id: ast::NodeId) {
|
||||
// Lints are run post expansion, so it's fine to use
|
||||
// #[_dom_struct_marker] here without also checking for #[dom_struct]
|
||||
if cx.tcx.has_attr(DefId::local(id), "_dom_struct_marker") {
|
||||
if cx.tcx.has_attr(cx.tcx.map.local_def_id(id), "_dom_struct_marker") {
|
||||
// Find the reflector, if any
|
||||
let reflector_span = def.fields.iter().enumerate()
|
||||
.find(|&(ctr, f)| {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc_front::hir;
|
||||
use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
|
@ -27,16 +26,16 @@ impl LateLintPass for PrivatizePass {
|
|||
fn check_struct_def(&mut self,
|
||||
cx: &LateContext,
|
||||
def: &hir::StructDef,
|
||||
_i: ast::Ident,
|
||||
_n: ast::Name,
|
||||
_gen: &hir::Generics,
|
||||
id: ast::NodeId) {
|
||||
if cx.tcx.has_attr(DefId::local(id), "privatize") {
|
||||
if cx.tcx.has_attr(cx.tcx.map.local_def_id(id), "privatize") {
|
||||
for field in &def.fields {
|
||||
match field.node {
|
||||
hir::StructField_ { kind: hir::NamedField(ident, visibility), .. } if visibility == hir::Public => {
|
||||
hir::StructField_ { kind: hir::NamedField(name, visibility), .. } if visibility == hir::Public => {
|
||||
cx.span_lint(PRIVATIZE, field.span,
|
||||
&format!("Field {} is public where only private fields are allowed",
|
||||
ident.name));
|
||||
name));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ impl LateLintPass for StrToStringPass {
|
|||
fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprMethodCall(ref method, _, ref args)
|
||||
if method.node.name.as_str() == "to_string"
|
||||
if method.node.as_str() == "to_string"
|
||||
&& is_str(cx, &*args[0]) => {
|
||||
cx.span_lint(STR_TO_STRING, expr.span,
|
||||
"str.to_owned() is more efficient than str.to_string(), please use it instead");
|
||||
|
|
|
@ -84,7 +84,7 @@ impl LateLintPass for UnrootedPass {
|
|||
fn check_struct_def(&mut self,
|
||||
cx: &LateContext,
|
||||
def: &hir::StructDef,
|
||||
_i: ast::Ident,
|
||||
_n: ast::Name,
|
||||
_gen: &hir::Generics,
|
||||
id: ast::NodeId) {
|
||||
let item = match cx.tcx.map.get(id) {
|
||||
|
@ -124,10 +124,10 @@ impl LateLintPass for UnrootedPass {
|
|||
fn check_fn(&mut self, cx: &LateContext, kind: visit::FnKind, decl: &hir::FnDecl,
|
||||
block: &hir::Block, _span: codemap::Span, id: ast::NodeId) {
|
||||
match kind {
|
||||
visit::FnKind::ItemFn(i, _, _, _, _, _) |
|
||||
visit::FnKind::Method(i, _, _) if i.name.as_str() == "new"
|
||||
|| i.name.as_str() == "new_inherited"
|
||||
|| i.name.as_str() == "new_initialized" => {
|
||||
visit::FnKind::ItemFn(n, _, _, _, _, _) |
|
||||
visit::FnKind::Method(n, _, _) if n.as_str() == "new"
|
||||
|| n.as_str() == "new_inherited"
|
||||
|| n.as_str() == "new_initialized" => {
|
||||
self.in_new_function = true;
|
||||
return;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue