11//! lint on indexing and slicing operations
22
33use 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} ;
75use rustc:: ty;
86use rustc_hir:: * ;
97use rustc_lint:: { LateContext , LateLintPass } ;
@@ -100,7 +98,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
10098
10199 if let ( Some ( start) , _) = const_range {
102100 if start > size {
103- utils :: span_lint (
101+ span_lint (
104102 cx,
105103 OUT_OF_BOUNDS_INDEXING ,
106104 range. start . map_or ( expr. span , |start| start. span ) ,
@@ -112,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
112110
113111 if let ( _, Some ( end) ) = const_range {
114112 if end > size {
115- utils :: span_lint (
113+ span_lint (
116114 cx,
117115 OUT_OF_BOUNDS_INDEXING ,
118116 range. end . map_or ( expr. span , |end| end. span ) ,
@@ -136,7 +134,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
136134 ( None , None ) => return , // [..] is ok.
137135 } ;
138136
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) ;
140138 } else {
141139 // Catchall non-range index, i.e., [n] or [n << m]
142140 if let ty:: Array ( ..) = ty. kind {
@@ -147,7 +145,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
147145 }
148146 }
149147
150- utils :: span_lint_and_help (
148+ span_lint_and_help (
151149 cx,
152150 INDEXING_SLICING ,
153151 expr. span ,
@@ -163,7 +161,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
163161/// the range. If the start or end is not constant, None is returned.
164162fn to_const_range < ' a , ' tcx > (
165163 cx : & LateContext < ' a , ' tcx > ,
166- range : Range < ' _ > ,
164+ range : higher :: Range < ' _ > ,
167165 array_size : u128 ,
168166) -> ( Option < u128 > , Option < u128 > ) {
169167 let s = range. start . map ( |expr| constant ( cx, cx. tables , expr) . map ( |( c, _) | c) ) ;
0 commit comments