diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6fbf5f071ad22..c8bd87024e882 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -893,13 +893,14 @@ impl Parser { // Parses a procedure type (`proc`). The initial `proc` keyword must // already have been parsed. pub fn parse_proc_type(&mut self) -> Ty_ { + let bounds = self.parse_optional_ty_param_bounds(); let (decl, lifetimes) = self.parse_ty_fn_decl(false); TyClosure(@ClosureTy { sigil: OwnedSigil, region: None, purity: ImpureFn, onceness: Once, - bounds: None, + bounds: bounds, decl: decl, lifetimes: lifetimes, }) diff --git a/src/test/compile-fail/proc-bounds.rs b/src/test/compile-fail/proc-bounds.rs new file mode 100644 index 0000000000000..c714bdb5b1b68 --- /dev/null +++ b/src/test/compile-fail/proc-bounds.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn is_send() {} +fn is_freeze() {} +fn is_static() {} + +fn main() { + is_send::(); + //~^ ERROR: instantiating a type parameter with an incompatible type + + is_freeze::(); + //~^ ERROR: instantiating a type parameter with an incompatible type + + is_static::(); + //~^ ERROR: instantiating a type parameter with an incompatible type +} + diff --git a/src/test/run-pass/proc-bounds.rs b/src/test/run-pass/proc-bounds.rs new file mode 100644 index 0000000000000..4a3e94704aab8 --- /dev/null +++ b/src/test/run-pass/proc-bounds.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() {} +fn bar(_: T) {} + +fn is_send() {} +fn is_freeze() {} +fn is_static() {} + +pub fn main() { + foo::(); + foo::(); + foo::(); + foo::(); + foo::(); + + is_send::(); + is_freeze::(); + is_static::(); + + + let a = 3; + bar::(proc() { + let b = &a; + println!("{}", *b); + }); +}