Change:
Gives:
Fairly sure this is intentional for
From the pull I've seen a part that I didn't see/remember: An unstable feature precisepointersizematching will be to permit matching exactly on pointer-size integer types. So you're right, this isn't a new bug, it's a known unfinished part. I hope to see that precisepointersizematching implemented.
It already exists.
I see, then what do I have to hope to see? :-)
I'm not sure the feature is ever going to be stabilised, because there are concerns that this isn't a desirable feature. But hopefully the diagnostics will at least be improved in
Do you have a link to such concerns? (Or are you willing to summarize them?) (I value your work on the compiler a lot varkor :-) )
I think the relevant concerns arose in the (from this comment up). The overview is that we ought not to make assumptions about pointer sizes on the target platform, because they're not guaranteed to be fixed, so this could cause compatibility issues.

Discussion:
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{HirId, Pat}; use rustc_middle::ty::{self, Ty, TyCtxt}; <ins> use rustc_session::config::nightly_options; </ins> use rustc_session::lint::builtin::BINDINGS_WITH_VARIANT_NAME; use rustc_session::lint::builtin::{IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS}; use rustc_session::parse::feature_err;

adt_defined_here(cx, &mut err, scrut_ty, &witnesses); err.help( "ensure that all possible cases are being handled,  <del> possibly by adding wildcards or more match arms", </del> <ins> possibly by adding wildcards or more match arms", </ins> ); err.note(&format!("the matched value is of type `{}`", scrut_ty)); <ins> if (scrut_ty == cx.tcx.types.usize || scrut_ty == cx.tcx.types.isize) && !is_empty_match && witnesses.len() == 1 && witnesses[0].is_wildcard() { err.note(&format!( "`{}` does not have a fixed maximum value,  so a wildcard `_` is necessary to match exhaustively", scrut_ty, )); if nightly_options::is_nightly_build() { err.help(&format!( "add `#![feature(precise_pointer_size_matching)]`  to the crate attributes to enable precise `{}` matching", scrut_ty, )); } } </ins> err.emit(); }

| = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` <ins> = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching </ins> error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11

| = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` <ins> = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching </ins> error: aborting due to 2 previous errors

<ins> use std::{usize, isize}; fn main() { match 0usize { //~^ ERROR non-exhaustive patterns //~| NOTE pattern `_` not covered //~| NOTE the matched value is of type `usize` //~| NOTE `usize` does not have a fixed maximum value 0 ..= usize::MAX => {} } match 0isize { //~^ ERROR non-exhaustive patterns //~| NOTE pattern `_` not covered //~| NOTE the matched value is of type `isize` //~| NOTE `isize` does not have a fixed maximum value isize::MIN ..= isize::MAX => {} } match 7usize {} //~^ ERROR non-exhaustive patterns //~| NOTE the matched value is of type `usize` } </ins>

<ins> error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:4:11 | LL |     match 0usize { |           ^^^^^^ pattern `_` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:12:11 | LL |     match 0isize { |           ^^^^^^ pattern `_` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching error[E0004]: non-exhaustive patterns: type `usize` is non-empty --> $DIR/non-exhaustive-pattern-pointer-size-int.rs:20:11 | LL |     match 7usize {} |           ^^^^^^ | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `usize` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0004`. </ins>