<p dir="auto">Apologies if this is a dupe.</p>
<p dir="auto">This doesn't compile:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn main() {
    match 25u8 {
        0 ... 24 =&gt; println!(&quot;less than 25&quot;),
        25 =&gt; println!(&quot;exactly 25&quot;),
        26 ... 255 =&gt; println!(&quot;above 25&quot;)
    }
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">match</span> <span class="pl-c1">25u8</span> <span class="pl-kos">{</span>
        <span class="pl-c1">0</span> ... <span class="pl-c1">24</span> =&gt; <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"less than 25"</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
        <span class="pl-c1">25</span> =&gt; <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"exactly 25"</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
        <span class="pl-c1">26</span> ... <span class="pl-c1">255</span> =&gt; <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"above 25"</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:2:5: 6:6 error: non-exhaustive patterns: `_` not covered [E0004]
&lt;anon&gt;:2     match 25u8 {
&lt;anon&gt;:3         0 ... 24 =&gt; println!(&quot;less than 25&quot;),
&lt;anon&gt;:4         25 =&gt; println!(&quot;exactly 25&quot;),
&lt;anon&gt;:5         26 ... 255 =&gt; println!(&quot;above 25&quot;)
&lt;anon&gt;:6     }
&lt;anon&gt;:2:5: 6:6 help: see the detailed explanation for E0004
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:2:5: 6:6 error: non-exhaustive patterns: `_` not covered [E0004]
&lt;anon&gt;:2     match 25u8 {
&lt;anon&gt;:3         0 ... 24 =&gt; println!("less than 25"),
&lt;anon&gt;:4         25 =&gt; println!("exactly 25"),
&lt;anon&gt;:5         26 ... 255 =&gt; println!("above 25")
&lt;anon&gt;:6     }
&lt;anon&gt;:2:5: 6:6 help: see the detailed explanation for E0004
error: aborting due to previous error
</code></pre></div>
<p dir="auto">The compiler isn't actually checking whether all the values for <code class="notranslate">u8</code> are covered, it's just checking whether or not there's a case for <code class="notranslate">_</code>.</p>
<p dir="auto">I've created some code that takes a <code class="notranslate">Range&lt;T&gt;</code> (the 'all-encompassing' range, i.e. <code class="notranslate">0...255</code> for <code class="notranslate">u8</code>) and <code class="notranslate">Vec&lt;Range&lt;T&gt;&gt; where T: Ord + Copy</code> and determines which ranges (if any) are not covered by the ranges provided by the vector. However, this code needs proper inclusive range support in order to work; I can't add 1 to the maximum value of a type in order to make it include every possible value for that type. That is available <a href="https://gist.github.com/aarzee/4395cb34eef31ea4e5c4">here</a>.</p>
<p dir="auto">I'm interested in implementing this logic in the compiler but I've no idea where to start, plus the code has the aforementioned inclusive range requirement.</p>
<p dir="auto">The following function does not compile because rustc determines that the patterns in the match statement are non-exhaustive.  However, the pattern matches every possible value of the integer type, and the compiler should be able to detect this.</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="fn wont_compile(x : u8) { 
    match (x) {
        0x00 .. 0xff =&gt; { }
    }
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">wont_compile</span><span class="pl-kos">(</span><span class="pl-s1">x</span> <span class="pl-kos">:</span> <span class="pl-smi">u8</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> 
    <span class="pl-k">match</span> <span class="pl-kos">(</span>x<span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-c1">0x00</span> .. <span class="pl-c1">0xff</span> =&gt; <span class="pl-kos">{</span> <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>