Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit type annotations for
vec.push(break)
test
This code was being correctly matched by the never-type fallback lint. In this case, the fallback is actually safe - constructing a `Vec<!>` is perfectly fine. However, the lint doesn't know that - without knowing about the inner details of `Vec`, there's no way of knowing that changing `Vec::<()>::new()` to `Vec::<!>::new()` is safe. I think this should be sufficiently rare in practice as to not be an issue. If a Vec<_> gets inferred to Vec<!> due to fallback, you must have never pushed anything to it (or else fallback would not have run due to the type variable being constrained). If the error does come up, adding type annotations is sufficient to fix the problem - using `Vec<()>`, `Vec<!> or (before the `!` type is stabilized) `Vec<std::convert::Infallible`, or really any type, will work. Alternatively, we might consider special-casing some (or all) safe methods in `libcore` and `libstd`, as fallback should never cause an issue with them.
- Loading branch information