diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index e6b6f7bbd49..161b27d7abb 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -21,13 +21,7 @@ //! (e.g. `Option`), the parameters are automatically given the //! current trait as a bound. (This includes separate type parameters //! and lifetimes for methods.) -//! - Additional bounds on the type parameters, e.g. the `Ord` instance -//! requires an explicit `PartialEq` bound at the -//! moment. (`TraitDef.additional_bounds`) -//! -//! Unsupported: FIXME #6257: calling methods on reference fields, -//! e.g. derive Eq/Ord/Clone don't work on `struct A(&int)`, -//! because of how the auto-dereferencing happens. +//! - Additional bounds on the type parameters (`TraitDef.additional_bounds`) //! //! The most important thing for implementers is the `Substructure` and //! `SubstructureFields` objects. The latter groups 5 possibilities of the @@ -79,6 +73,15 @@ //! enums (one for each variant). For empty struct and empty enum //! variants, it is represented as a count of 0. //! +//! # "`cs`" functions +//! +//! The `cs_...` functions ("combine substructure) are designed to +//! make life easier by providing some pre-made recipes for common +//! tasks; mostly calling the function being derived on all the +//! arguments and then combining them back together in some way (or +//! letting the user chose that). They are not meant to be the only +//! way to handle the structures that this code creates. +//! //! # Examples //! //! The following simplified `PartialEq` is used for in-code examples: @@ -102,22 +105,22 @@ //! When generating the `expr` for the `A` impl, the `SubstructureFields` is //! //! ```{.text} -//! Struct(~[FieldInfo { +//! Struct(vec![FieldInfo { //! span: //! name: Some(), //! self_: , -//! other: ~[, //! name: None, -//! -//! ~[] +//! self_: +//! other: vec![] //! }]) //! ``` //! @@ -128,11 +131,11 @@ //! //! ```{.text} //! EnumMatching(0, , -//! ~[FieldInfo { +//! vec![FieldInfo { //! span: //! name: None, //! self_: , -//! other: ~[] +//! other: vec![] //! }]) //! ``` //! @@ -140,11 +143,11 @@ //! //! ```{.text} //! EnumMatching(1, , -//! ~[FieldInfo { +//! vec![FieldInfo { //! span: //! name: Some(), //! self_: , -//! other: ~[] +//! other: vec![] //! }]) //! ``` //! @@ -152,7 +155,7 @@ //! //! ```{.text} //! EnumNonMatchingCollapsed( -//! ~[, ], +//! vec![, ], //! &[, ], //! &[, ]) //! ``` @@ -168,16 +171,16 @@ //! //! ## Static //! -//! A static method on the above would result in, +//! A static method on the types above would result in, //! //! ```{.text} -//! StaticStruct(, Named(~[(, )])) +//! StaticStruct(, Named(vec![(, )])) //! -//! StaticStruct(, Unnamed(~[])) +//! StaticStruct(, Unnamed(vec![])) //! -//! StaticEnum(, ~[(, , Unnamed(~[])), -//! (, , -//! Named(~[(, )]))]) +//! StaticEnum(, +//! vec![(, , Unnamed(vec![])), +//! (, , Named(vec![(, )]))]) //! ``` pub use self::StaticFields::*; @@ -1378,8 +1381,8 @@ pub fn cs_fold(use_foldl: bool, /// process the collected results. i.e. /// /// ``` -/// f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), -/// self_2.method(__arg_1_2, __arg_2_2)]) +/// f(cx, span, vec![self_1.method(__arg_1_1, __arg_2_1), +/// self_2.method(__arg_1_2, __arg_2_2)]) /// ``` #[inline] pub fn cs_same_method(f: F,