File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1040,12 +1040,23 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
1040
1040
ast_generics : & ast:: Generics ,
1041
1041
abis : AbiSet )
1042
1042
-> 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
+
1043
1053
let ty_generics = ty_generics ( ccx, ast_generics, 0 ) ;
1044
1054
let rb = BindingRscope :: new ( def_id. node ) ;
1045
1055
let input_tys = decl. inputs
1046
1056
. iter ( )
1047
1057
. map ( |a| ty_of_arg ( ccx, & rb, a, None ) )
1048
1058
. collect ( ) ;
1059
+
1049
1060
let output_ty = ast_ty_to_ty ( ccx, & rb, decl. output ) ;
1050
1061
1051
1062
let t_fn = ty:: mk_bare_fn (
Original file line number Diff line number Diff line change
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 ( ) { }
You can’t perform that action at this time.
0 commit comments