add some imports to guard against crate moves

This commit is contained in:
Georg Brandl 2015-08-16 09:03:06 +02:00
parent 47b605304d
commit 64954283c1
3 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#![feature(plugin_registrar, box_syntax)]
#![feature(rustc_private, collections)]
#![feature(rustc_private, core, collections)]
#![feature(str_split_at)]
#[macro_use]
@ -8,6 +8,7 @@ extern crate syntax;
extern crate rustc;
// Only for the compile time checking of paths
extern crate core;
extern crate collections;
use rustc::plugin::Registry;

View File

@ -16,12 +16,19 @@ declare_lint!(pub STR_TO_STRING, Warn,
declare_lint!(pub STRING_TO_STRING, Warn,
"calling `String.to_string()` which is a no-op");
#[allow(unused_imports)]
impl LintPass for MethodsPass {
fn get_lints(&self) -> LintArray {
lint_array!(OPTION_UNWRAP_USED, RESULT_UNWRAP_USED, STR_TO_STRING, STRING_TO_STRING)
}
fn check_expr(&mut self, cx: &Context, expr: &Expr) {
{
// In case stuff gets moved around
use core::option::Option;
use core::result::Result;
use collections::string::String;
}
if let ExprMethodCall(ref ident, _, ref args) = expr.node {
let ref obj_ty = walk_ptrs_ty(cx.tcx.expr_ty(&*args[0])).sty;
if ident.node.name == "unwrap" {

View File

@ -63,10 +63,8 @@ impl LintPass for TypePass {
// In case stuff gets moved around
use collections::linked_list::LinkedList as DL1;
use std::collections::linked_list::LinkedList as DL2;
use std::collections::linked_list::LinkedList as DL3;
}
let dlists = [vec!["std","collections","linked_list","LinkedList"],
vec!["std","collections","linked_list","LinkedList"],
vec!["collections","linked_list","LinkedList"]];
for path in &dlists {
if match_ty_unwrap(ty, &path[..]).is_some() {