Skip to content

advanced_slice_patterns has unreachable expression #37598

Closed
@adjivas

Description

@adjivas

Hello,

According to this chapiter, I have writted this example:

#![feature(advanced_slice_patterns, slice_patterns)]


fn check(list: &[u8]) {
    match list {
        &[] => {},
        &[u1 @ b'\xF0' ... b'\xF4', u2 @ b'\x8F' ... b'\x90',
          u3 @ b'\x80' ... b'\xBF', u4 @ b'\x80' ... b'\xBF', ref next..] => {
            println!("{} {} {} {}", u1, u2, u3, u4);
            check(next)
        },
        &[u1, ref next..] => {
            println!("{}", u1);
            check(next)
        },
    }
}

fn main() {
    let buf = &[b'0', b'1', b'4'];
    
    check(&buf[..]);
}

But after the rustc 1.14.0-nightly version from 2016-10-25 -aef18be1b-,
I expected to see this happen:

error[E0001]: unreachable pattern
  --> <anon>:12:9
   |
12 |         &[u1 @ b'\xF0' ... b'\xF4',
   |         ^ this is an unreachable pattern

error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions