Skip to content

Commit 3e9ce5a

Browse files
author
Jakub Bukaj
committed
Do not accept functions in enum patterns past resolve
1 parent 083578d commit 3e9ce5a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/librustc/middle/resolve.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5077,7 +5077,6 @@ impl<'a> Resolver<'a> {
50775077
PatEnum(ref path, _) => {
50785078
// This must be an enum variant, struct or const.
50795079
match self.resolve_path(pat_id, path, ValueNS, false) {
5080-
Some(def @ (DefFn(..), _)) |
50815080
Some(def @ (DefVariant(..), _)) |
50825081
Some(def @ (DefStruct(..), _)) |
50835082
Some(def @ (DefConst(..), _)) => {

src/test/compile-fail/issue-10200.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo(bool);
12+
fn foo(_: uint) -> Foo { Foo(false) }
13+
14+
fn main() {
15+
match Foo(true) {
16+
foo(x) //~ ERROR `foo` is not an enum variant, struct or const
17+
=> ()
18+
}
19+
}

0 commit comments

Comments
 (0)