1
1
//! lint on indexing and slicing operations
2
2
3
3
use crate :: consts:: { constant, Constant } ;
4
- use crate :: utils;
5
- use crate :: utils:: higher;
6
- use crate :: utils:: higher:: Range ;
4
+ use crate :: utils:: { higher, span_lint, span_lint_and_help} ;
7
5
use rustc:: ty;
8
6
use rustc_hir:: * ;
9
7
use rustc_lint:: { LateContext , LateLintPass } ;
@@ -100,7 +98,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
100
98
101
99
if let ( Some ( start) , _) = const_range {
102
100
if start > size {
103
- utils :: span_lint (
101
+ span_lint (
104
102
cx,
105
103
OUT_OF_BOUNDS_INDEXING ,
106
104
range. start . map_or ( expr. span , |start| start. span ) ,
@@ -112,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
112
110
113
111
if let ( _, Some ( end) ) = const_range {
114
112
if end > size {
115
- utils :: span_lint (
113
+ span_lint (
116
114
cx,
117
115
OUT_OF_BOUNDS_INDEXING ,
118
116
range. end . map_or ( expr. span , |end| end. span ) ,
@@ -136,7 +134,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
136
134
( None , None ) => return , // [..] is ok.
137
135
} ;
138
136
139
- utils :: span_lint_and_help ( cx, INDEXING_SLICING , expr. span , "slicing may panic." , help_msg) ;
137
+ span_lint_and_help ( cx, INDEXING_SLICING , expr. span , "slicing may panic." , help_msg) ;
140
138
} else {
141
139
// Catchall non-range index, i.e., [n] or [n << m]
142
140
if let ty:: Array ( ..) = ty. kind {
@@ -147,7 +145,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
147
145
}
148
146
}
149
147
150
- utils :: span_lint_and_help (
148
+ span_lint_and_help (
151
149
cx,
152
150
INDEXING_SLICING ,
153
151
expr. span ,
@@ -163,7 +161,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
163
161
/// the range. If the start or end is not constant, None is returned.
164
162
fn to_const_range < ' a , ' tcx > (
165
163
cx : & LateContext < ' a , ' tcx > ,
166
- range : Range < ' _ > ,
164
+ range : higher :: Range < ' _ > ,
167
165
array_size : u128 ,
168
166
) -> ( Option < u128 > , Option < u128 > ) {
169
167
let s = range. start . map ( |expr| constant ( cx, cx. tables , expr) . map ( |( c, _) | c) ) ;
0 commit comments