Skip to content

Commit c2d4837

Browse files
committed
---
yaml --- r: 108843 b: refs/heads/dist-snap c: 67c5d79 h: refs/heads/master i: 108841: ef5453d 108839: e75b58e v: v3
1 parent 6a2807e commit c2d4837

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: a871068b472d234e6515d5e979fac4826ec1dac1
9+
refs/heads/dist-snap: 67c5d793add67878e6e472258748ac13e0f90366
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/typeck/collect.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,23 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
10401040
ast_generics: &ast::Generics,
10411041
abis: AbiSet)
10421042
-> ty::ty_param_bounds_and_ty {
1043+
1044+
for i in decl.inputs.iter() {
1045+
match (*i).pat.node {
1046+
ast::PatIdent(_, _, _) => (),
1047+
ast::PatWild => (),
1048+
_ => ccx.tcx.sess.span_err((*i).pat.span,
1049+
"patterns aren't allowed in foreign function declarations")
1050+
}
1051+
}
1052+
10431053
let ty_generics = ty_generics(ccx, ast_generics, 0);
10441054
let rb = BindingRscope::new(def_id.node);
10451055
let input_tys = decl.inputs
10461056
.iter()
10471057
.map(|a| ty_of_arg(ccx, &rb, a, None))
10481058
.collect();
1059+
10491060
let output_ty = ast_ty_to_ty(ccx, &rb, decl.output);
10501061

10511062
let t_fn = ty::mk_bare_fn(
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 { x: int }
12+
extern {
13+
fn foo(1: ());
14+
//~^ ERROR: patterns aren't allowed in foreign function declarations
15+
fn bar((): int);
16+
//~^ ERROR: patterns aren't allowed in foreign function declarations
17+
fn baz(Foo { x }: int);
18+
//~^ ERROR: patterns aren't allowed in foreign function declarations
19+
fn qux((x,y): ());
20+
//~^ ERROR: patterns aren't allowed in foreign function declarations
21+
fn this_is_actually_ok(a: uint);
22+
fn and_so_is_this(_: uint);
23+
}
24+
fn main() {}

0 commit comments

Comments
 (0)