Skip to content

Commit c0c2f61

Browse files
committed
Merge pull request #736 from mcarton/vec
Update to rustc 1.9.0-nightly (e91f889 2016-03-03)
2 parents bdda6a2 + 026d443 commit c0c2f61

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.45"
3+
version = "0.0.46"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/cyclomatic_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'a> Visitor<'a> for MatchArmCounter {
116116
}
117117
}
118118

119-
struct DivergenceCounter<'a, 'tcx: 'a>(u64, &'a ty::ctxt<'tcx>);
119+
struct DivergenceCounter<'a, 'tcx: 'a>(u64, &'a ty::TyCtxt<'tcx>);
120120

121121
impl<'a, 'b, 'tcx> Visitor<'a> for DivergenceCounter<'b, 'tcx> {
122122
fn visit_expr(&mut self, e: &'a Expr) {

src/vec.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::middle::ty::TypeVariants;
33
use rustc_front::hir::*;
44
use syntax::codemap::Span;
55
use syntax::ptr::P;
6-
use utils::{BOX_NEW_PATH, VEC_FROM_ELEM_PATH};
6+
use utils::VEC_FROM_ELEM_PATH;
77
use utils::{is_expn_of, match_path, snippet, span_lint_and_then};
88

99
/// **What it does:** This lint warns about using `&vec![..]` when using `&[..]` would be possible.
@@ -33,9 +33,7 @@ impl LintPass for UselessVec {
3333

3434
impl LateLintPass for UselessVec {
3535
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
36-
unexpand_vec(cx, expr);
37-
38-
// search for `&!vec[_]` expressions where the adjusted type is `&[_]`
36+
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
3937
if_let_chain!{[
4038
let TypeVariants::TyRef(_, ref ty) = cx.tcx.expr_ty_adjusted(expr).sty,
4139
let TypeVariants::TySlice(..) = ty.ty.sty,
@@ -71,7 +69,7 @@ impl LateLintPass for UselessVec {
7169

7270
/// Represent the pre-expansion arguments of a `vec!` invocation.
7371
pub enum VecArgs<'a> {
74-
/// `vec![elem, len]`
72+
/// `vec![elem; len]`
7573
Repeat(&'a P<Expr>, &'a P<Expr>),
7674
/// `vec![a, b, c]`
7775
Vec(&'a [P<Expr>]),
@@ -91,10 +89,8 @@ pub fn unexpand_vec<'e>(cx: &LateContext, expr: &'e Expr) -> Option<VecArgs<'e>>
9189
else if match_path(path, &["into_vec"]) && args.len() == 1 {
9290
// `vec![a, b, c]` case
9391
if_let_chain!{[
94-
let ExprCall(ref fun, ref args) = args[0].node,
95-
let ExprPath(_, ref path) = fun.node,
96-
match_path(path, &BOX_NEW_PATH) && args.len() == 1,
97-
let ExprVec(ref args) = args[0].node
92+
let ExprBox(ref boxed) = args[0].node,
93+
let ExprVec(ref args) = boxed.node
9894
], {
9995
return Some(VecArgs::Vec(&*args));
10096
}}

0 commit comments

Comments
 (0)