Dogfood {exclusive,half-open} ranges in compiler (nfc)
In particular, this allows us to write more explicit matches that avoid the pitfalls of using a fully general fall-through case, yet remain fairly ergonomic. Less logic is in guard cases, more is in the actual exhaustive case analysis. No functional changes.
This commit is contained in:
parent
a9cd294cf2
commit
0e88db7db4
6 changed files with 14 additions and 10 deletions
|
@ -250,13 +250,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
has_emitted
|
||||
}
|
||||
ty::Array(ty, len) => match len.try_eval_usize(cx.tcx, cx.param_env) {
|
||||
// If the array is empty we don't lint, to avoid false positives
|
||||
Some(0) | None => false,
|
||||
// If the array is definitely non-empty, we can do `#[must_use]` checking.
|
||||
Some(n) if n != 0 => {
|
||||
Some(n) => {
|
||||
let descr_pre = &format!("{}array{} of ", descr_pre, plural_suffix,);
|
||||
check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, n as usize + 1)
|
||||
}
|
||||
// Otherwise, we don't lint, to avoid false positives.
|
||||
_ => false,
|
||||
},
|
||||
ty::Closure(..) => {
|
||||
cx.struct_span_lint(UNUSED_MUST_USE, span, |lint| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue