reflect: Expect doctests to fail compile
This commit is contained in:
parent
e49d69dbc1
commit
29467faf55
|
@ -32,7 +32,7 @@ impl From<&Variant> for VariantType {
|
|||
|
||||
/// Generates the following different outputs:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// // for struct variants
|
||||
/// TestEnum::Error { msg, code }
|
||||
///
|
||||
|
@ -98,7 +98,7 @@ fn gen_variant_if(enum_id: &proc_macro2::Ident, variant: &Variant, if_body: proc
|
|||
|
||||
/// Generates the following:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// /// generated one field here
|
||||
/// if name == "msg" {
|
||||
/// return Some(msg);
|
||||
|
@ -129,7 +129,7 @@ fn gen_if_field_names(variant: &Variant) -> proc_macro2::TokenStream {
|
|||
|
||||
/// Generates the following rust code:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match name {
|
||||
/// "msg" | "code" => true,
|
||||
/// _ => false,
|
||||
|
@ -153,7 +153,7 @@ fn gen_match_names(variant: &Variant) -> proc_macro2::TokenStream {
|
|||
|
||||
/// Generates the following:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// /// generated one field here
|
||||
/// if idx == 0 {
|
||||
/// return Some(a);
|
||||
|
@ -190,7 +190,7 @@ fn gen_if_field_indices(variant: &Variant) -> proc_macro2::TokenStream {
|
|||
|
||||
/// Generates the following:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// /// generated one field here
|
||||
/// if idx == 0 {
|
||||
/// return Some("a");
|
||||
|
@ -226,7 +226,7 @@ fn gen_if_field_indices_names(variant: &Variant) -> proc_macro2::TokenStream {
|
|||
}
|
||||
|
||||
/// Generates the following:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// /// when `by_index` is false:
|
||||
///
|
||||
/// if let TestEnum::Error{ msg, code} = self {
|
||||
|
@ -301,7 +301,7 @@ fn gen_enum_if_stmts(enum_id: &proc_macro2::Ident, data: &DataEnum, by_index: bo
|
|||
|
||||
/// Generates the following rust code:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// if let TestEnum::Error { msg, code } = self {
|
||||
/// return match name {
|
||||
/// // expands for continuing struct fields
|
||||
|
@ -332,7 +332,7 @@ fn gen_enum_has_field(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_mac
|
|||
|
||||
/// Generates the following code:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match self {
|
||||
/// TestEnum::Start => 0,
|
||||
/// TestEnum::Middle(a, b) => 2,
|
||||
|
@ -359,7 +359,7 @@ fn gen_enum_fields_len(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc_ma
|
|||
|
||||
/// Generates the following code:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// if let TestEnum::Error { msg, code } = self {
|
||||
/// if idx == 0 {
|
||||
/// return Some("msg");
|
||||
|
@ -390,7 +390,7 @@ fn gen_enum_field_name_at(enum_id: &proc_macro2::Ident, data: &DataEnum) -> proc
|
|||
}
|
||||
|
||||
/// Generates the following code:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match self {
|
||||
/// TestEnum::Start => 0,
|
||||
/// TestEnum::Middle(a, b) => 1,
|
||||
|
@ -428,7 +428,7 @@ fn gen_enum_variant_name(enum_id: &proc_macro2::Ident, data: &DataEnum, gen_inde
|
|||
/// Generates a match statement that returns the types of the variants of the enum.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match self {
|
||||
/// TestEnum::Start => EnumType::Unit,
|
||||
/// TestEnum::Middle(a, b) => EnumType::Tuple,
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::add_trait_bounds;
|
|||
/// contains a borrow (mutable borrow if `is_mut` is true) to the matching struct field.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// // when `is_mut` = false
|
||||
/// match name {
|
||||
/// "x" => Some(&self.x),
|
||||
|
@ -50,7 +50,7 @@ fn gen_struct_field_match(data: &DataStruct, is_mut: bool) -> proc_macro2::Token
|
|||
/// with the provided `val`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match name {
|
||||
/// "x" => self.x = any_val.downcast_ref::<f32>()
|
||||
/// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name()))
|
||||
|
@ -91,7 +91,7 @@ fn gen_struct_set_field_match(data: &DataStruct) -> proc_macro2::TokenStream {
|
|||
/// the type of the field.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match name {
|
||||
/// "x" => Some("f32"),
|
||||
/// "y" => Some("f32"),
|
||||
|
@ -124,7 +124,7 @@ fn gen_struct_field_name_match(data: &DataStruct) -> proc_macro2::TokenStream {
|
|||
/// with the provided `val`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match name {
|
||||
/// 0 => self.x = any_val.downcast_ref::<f32>()
|
||||
/// .expect(&format!("Cannot set struct's field of {} type to the provided type of {}", "f32", val.name()))
|
||||
|
@ -165,7 +165,7 @@ fn gen_struct_set_field_match_idx(data: &DataStruct) -> proc_macro2::TokenStream
|
|||
/// type of the field.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match name {
|
||||
/// 0 => Some("f32"),
|
||||
/// 1 => Some("f32"),
|
||||
|
@ -196,7 +196,7 @@ fn gen_struct_field_name_match_idx(data: &DataStruct) -> proc_macro2::TokenStrea
|
|||
/// to the matching struct field.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// // when `is_mut` = false
|
||||
/// match idx {
|
||||
/// 0 => Some(&self.x),
|
||||
|
@ -238,7 +238,7 @@ fn gen_struct_field_match_idx(data: &DataStruct, is_mut: bool) -> proc_macro2::T
|
|||
/// and returns an Option that contains the name of the field.
|
||||
///
|
||||
/// Example:
|
||||
/// ```rust
|
||||
/// ```compile_fail
|
||||
/// match idx {
|
||||
/// 0 => Some("x"),
|
||||
/// 1 => Some("y"),
|
||||
|
|
Loading…
Reference in New Issue