Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obk
Fix wrapped valid-range handling in ty_find_init_error Rust's niche handling allows for wrapping valid ranges with end < start; for instance, a valid range with start=43 and end=41 means a niche of 42. Most places in the compiler handle this correctly, but `ty_find_init_error` assumed that `lo > 0` means the type cannot contain a zero. Fix it to handle wrapping ranges.
This commit is contained in:
commit
9f06fbd1ad
3 changed files with 73 additions and 52 deletions
|
@ -2526,7 +2526,10 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
// return `Bound::Excluded`. (And we have tests checking that we
|
||||
// handle the attribute correctly.)
|
||||
// We don't add a span since users cannot declare such types anyway.
|
||||
(Bound::Included(lo), _) if lo > 0 => {
|
||||
(Bound::Included(lo), Bound::Included(hi)) if 0 < lo && lo < hi => {
|
||||
return Some((format!("`{}` must be non-null", ty), None));
|
||||
}
|
||||
(Bound::Included(lo), Bound::Unbounded) if 0 < lo => {
|
||||
return Some((format!("`{}` must be non-null", ty), None));
|
||||
}
|
||||
(Bound::Included(_), _) | (_, Bound::Included(_))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue