librustc: Implement the syntax in the RFC for unboxed closure sugar.

Part of issue #16640. I am leaving this issue open to handle parsing of
higher-rank lifetimes in traits.

This change breaks code that used unboxed closures:

* Instead of `F:|&: int| -> int`, write `F:Fn(int) -> int`.

* Instead of `F:|&mut: int| -> int`, write `F:FnMut(int) -> int`.

* Instead of `F:|: int| -> int`, write `F:FnOnce(int) -> int`.

[breaking-change]
This commit is contained in:
Patrick Walton
2014-09-05 21:27:47 -07:00
parent 9c41064308
commit 7c00d77e8b
17 changed files with 207 additions and 117 deletions

View File

@@ -213,12 +213,19 @@ pub static DUMMY_NODE_ID: NodeId = -1;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum TyParamBound {
TraitTyParamBound(TraitRef),
UnboxedFnTyParamBound(UnboxedFnTy),
UnboxedFnTyParamBound(P<UnboxedFnBound>),
RegionTyParamBound(Lifetime)
}
pub type TyParamBounds = OwnedSlice<TyParamBound>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct UnboxedFnBound {
pub path: Path,
pub decl: P<FnDecl>,
pub ref_id: NodeId,
}
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TyParam {
pub ident: Ident,