1
Fork 0

libsyntax: Don't strip types and lifetimes from single-segment paths in

patterns.

This breaks code like:

    fn main() {
        match Some("foo") {
            None::<int> => {}
            Some(_) => {}
        }
    }

Change this code to not contain a type error. For example:

    fn main() {
        match Some("foo") {
            None::<&str> => {}
            Some(_) => {}
        }
    }

Closes #16353.

[breaking-change]
This commit is contained in:
Patrick Walton 2014-08-12 10:33:16 -07:00
parent c7d0b5259d
commit 857ba988f1
2 changed files with 27 additions and 1 deletions

View file

@ -3157,7 +3157,16 @@ impl<'a> Parser<'a> {
}
},
_ => {
if !enum_path.global && enum_path.segments.len() == 1 {
if !enum_path.global &&
enum_path.segments.len() == 1 &&
enum_path.segments
.get(0)
.lifetimes
.len() == 0 &&
enum_path.segments
.get(0)
.types
.len() == 0 {
// it could still be either an enum
// or an identifier pattern, resolve
// will sort it out: