3 ms·
Don't. This would be a terrible lint. It's perfectly reasonable to expect an index to be in bounds for various reasons.
by Gankro 11y ago
Don't. This would be a terrible lint. It's perfectly reasonable to expect an index to be in bounds for various reasons.
- mcguire 11y agoDependent typing, dude. It's the way of the future.
- Manishearth 11y agoIt could be a pedantic lint (off by default). There may be ways to lint in case of an `if x.len()... x[...]` though. That should be done monadically; given that panics aren't supposed to be caught in most situations, we should minimize the number of ways programmer error can lead to a panic. Looking through servo's code a lot of the cases are where we use fixed-length arrays, or when dealing with graphicsy buffers. One use case which needs indexing is when we use an index as an "id". No easy way to fix that without introducing Rc or something.