Check that we don't treat any type but a range type as a range

This commit is contained in:
Oliver Schneider
2018-05-08 17:16:01 +02:00
parent e456241f18
commit c6e35eae53
6 changed files with 46 additions and 12 deletions

View File

@@ -73,7 +73,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
}
// Index is a constant range
if let Some(range) = higher::range(index) {
if let Some(range) = higher::range(cx, index) {
if let Some((start, end)) = to_const_range(cx, range, size) {
if start > size || end > size {
utils::span_lint(cx, OUT_OF_BOUNDS_INDEXING, e.span, "range is out of bounds");
@@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
}
}
if let Some(range) = higher::range(index) {
if let Some(range) = higher::range(cx, index) {
// Full ranges are always valid
if range.start.is_none() && range.end.is_none() {
return;