Rustup
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
|
||||||
#[plugin]
|
#![plugin(clippy)]
|
||||||
extern crate clippy;
|
|
||||||
|
|
||||||
pub fn test(foo: Box<Vec<bool>>) {
|
pub fn test(foo: Box<Vec<bool>>) {
|
||||||
println!("{:?}", foo.get(0))
|
println!("{:?}", foo.get(0))
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
|
||||||
#[plugin]
|
#![plugin(clippy)]
|
||||||
extern crate clippy;
|
|
||||||
|
|
||||||
extern crate collections;
|
extern crate collections;
|
||||||
use collections::dlist::DList;
|
use collections::linked_list::LinkedList;
|
||||||
|
|
||||||
pub fn test(foo: DList<uint>) {
|
pub fn test(foo: LinkedList<uint>) {
|
||||||
println!("{:?}", foo)
|
println!("{:?}", foo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
test(DList::new());
|
test(LinkedList::new());
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
|
||||||
#[plugin]
|
#![plugin(clippy)]
|
||||||
extern crate clippy;
|
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
let x = Some(1u);
|
let x = Some(1u);
|
||||||
@@ -19,4 +18,4 @@ fn main(){
|
|||||||
(2...3, 7...9) => println!("{:?}", z),
|
(2...3, 7...9) => println!("{:?}", z),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
|
||||||
#[plugin]
|
#![plugin(clippy)]
|
||||||
extern crate clippy;
|
|
||||||
|
|
||||||
fn the_answer(ref mut x: u8) {
|
fn the_answer(ref mut x: u8) {
|
||||||
*x = 42;
|
*x = 42;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
|||||||
reg.register_lint_pass(box misc::MiscPass as LintPassObject);
|
reg.register_lint_pass(box misc::MiscPass as LintPassObject);
|
||||||
reg.register_lint_pass(box misc::StrToStringPass as LintPassObject);
|
reg.register_lint_pass(box misc::StrToStringPass as LintPassObject);
|
||||||
reg.register_lint_pass(box misc::TopLevelRefPass as LintPassObject);
|
reg.register_lint_pass(box misc::TopLevelRefPass as LintPassObject);
|
||||||
reg.register_lint_group("clippy", vec![types::BOX_VEC, types::DLIST,
|
reg.register_lint_group("clippy", vec![types::BOX_VEC, types::LINKEDLIST,
|
||||||
misc::SINGLE_MATCH, misc::STR_TO_STRING,
|
misc::SINGLE_MATCH, misc::STR_TO_STRING,
|
||||||
misc::TOPLEVEL_REF_ARG]);
|
misc::TOPLEVEL_REF_ARG]);
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/types.rs
22
src/types.rs
@@ -12,8 +12,8 @@ pub struct TypePass;
|
|||||||
|
|
||||||
declare_lint!(pub BOX_VEC, Warn,
|
declare_lint!(pub BOX_VEC, Warn,
|
||||||
"Warn on usage of Box<Vec<T>>");
|
"Warn on usage of Box<Vec<T>>");
|
||||||
declare_lint!(pub DLIST, Warn,
|
declare_lint!(pub LINKEDLIST, Warn,
|
||||||
"Warn on usage of DList");
|
"Warn on usage of LinkedList");
|
||||||
|
|
||||||
/// Matches a type with a provided string, and returns its type parameters if successful
|
/// Matches a type with a provided string, and returns its type parameters if successful
|
||||||
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
|
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
|
||||||
@@ -48,7 +48,7 @@ pub fn span_note_and_lint(cx: &Context, lint: &'static Lint, span: Span, msg: &s
|
|||||||
|
|
||||||
impl LintPass for TypePass {
|
impl LintPass for TypePass {
|
||||||
fn get_lints(&self) -> LintArray {
|
fn get_lints(&self) -> LintArray {
|
||||||
lint_array!(BOX_VEC, DLIST)
|
lint_array!(BOX_VEC, LINKEDLIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_ty(&mut self, cx: &Context, ty: &ast::Ty) {
|
fn check_ty(&mut self, cx: &Context, ty: &ast::Ty) {
|
||||||
@@ -66,17 +66,17 @@ impl LintPass for TypePass {
|
|||||||
});
|
});
|
||||||
{
|
{
|
||||||
// In case stuff gets moved around
|
// In case stuff gets moved around
|
||||||
use collections::dlist::DList as DL1;
|
use collections::linked_list::LinkedList as DL1;
|
||||||
use std::collections::dlist::DList as DL2;
|
use std::collections::linked_list::LinkedList as DL2;
|
||||||
use std::collections::DList as DL3;
|
use std::collections::linked_list::LinkedList as DL3;
|
||||||
}
|
}
|
||||||
let dlists = [vec!["std","collections","dlist","DList"],
|
let dlists = [vec!["std","collections","linked_list","LinkedList"],
|
||||||
vec!["std","collections","DList"],
|
vec!["std","collections","linked_list","LinkedList"],
|
||||||
vec!["collections","dlist","DList"]];
|
vec!["collections","linked_list","LinkedList"]];
|
||||||
for path in dlists.iter() {
|
for path in dlists.iter() {
|
||||||
if match_ty_unwrap(ty, path.as_slice()).is_some() {
|
if match_ty_unwrap(ty, path.as_slice()).is_some() {
|
||||||
span_note_and_lint(cx, DLIST, ty.span,
|
span_note_and_lint(cx, LINKEDLIST, ty.span,
|
||||||
"I see you're using a DList! Perhaps you meant some other data structure?",
|
"I see you're using a LinkedList! Perhaps you meant some other data structure?",
|
||||||
"A RingBuf might work.");
|
"A RingBuf might work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user