@@ -4,6 +4,7 @@ use rustc_front::hir::*;
4
4
use std:: collections:: HashMap ;
5
5
use std:: collections:: hash_map:: Entry ;
6
6
use syntax:: parse:: token:: InternedString ;
7
+ use syntax:: util:: small_vector:: SmallVector ;
7
8
use utils:: { SpanlessEq , SpanlessHash } ;
8
9
use utils:: { get_parent_expr, in_macro, span_note_and_lint} ;
9
10
@@ -78,8 +79,8 @@ impl LateLintPass for CopyAndPaste {
78
79
}
79
80
80
81
let ( conds, blocks) = if_sequence ( expr) ;
81
- lint_same_then_else ( cx, & blocks) ;
82
- lint_same_cond ( cx, & conds) ;
82
+ lint_same_then_else ( cx, blocks. as_slice ( ) ) ;
83
+ lint_same_cond ( cx, conds. as_slice ( ) ) ;
83
84
lint_match_arms ( cx, expr) ;
84
85
}
85
86
}
@@ -143,9 +144,9 @@ fn lint_match_arms(cx: &LateContext, expr: &Expr) {
143
144
/// Return the list of condition expressions and the list of blocks in a sequence of `if/else`.
144
145
/// Eg. would return `([a, b], [c, d, e])` for the expression
145
146
/// `if a { c } else if b { d } else { e }`.
146
- fn if_sequence ( mut expr : & Expr ) -> ( Vec < & Expr > , Vec < & Block > ) {
147
- let mut conds = vec ! [ ] ;
148
- let mut blocks = vec ! [ ] ;
147
+ fn if_sequence ( mut expr : & Expr ) -> ( SmallVector < & Expr > , SmallVector < & Block > ) {
148
+ let mut conds = SmallVector :: zero ( ) ;
149
+ let mut blocks = SmallVector :: zero ( ) ;
149
150
150
151
while let ExprIf ( ref cond, ref then_block, ref else_expr) = expr. node {
151
152
conds. push ( & * * cond) ;
0 commit comments