darling 0.24.1

A proc-macro library for reading attributes into structs when implementing custom derives.
Documentation
//! Code generated by the derive macros used to trip the `unused_qualifications` lint in the
//! consuming crate. The generated impls reach items through the `_darling` alias, which is not a
//! `::`-rooted path, and the magic-field codegen stamps the input's span onto those paths, so the
//! warnings landed on the consuming crate's own struct fields.
//!
//! The `deny` below is the assertion: without the allow in the generated impls, this file does not
//! compile.
//!
//! Issue: https://github.com/TedDriggs/darling/issues/435

#![deny(unused_qualifications)]
#![allow(dead_code)]

use darling::{
    ast::{Data, Fields},
    FromDeriveInput, FromField, FromVariant,
};
use quote::quote;
use syn::{DeriveInput, Expr, Generics, Ident, Type};

#[derive(FromDeriveInput)]
#[darling(attributes(lints))]
struct Input {
    ident: Ident,
    generics: Generics,
    data: Data<Variant, Field>,
}

#[derive(FromField)]
#[darling(attributes(lints))]
struct Field {
    ty: Type,
    max_elems: Option<Expr>,
    flag: Option<()>,
}

#[derive(FromVariant)]
#[darling(attributes(lints))]
struct Variant {
    fields: Fields<Field>,
}

#[test]
fn expansion() {
    let input: DeriveInput = syn::parse2(quote! {
        struct Example {
            hello: String,
        }
    })
    .unwrap();

    let parsed = Input::from_derive_input(&input).unwrap();
    assert_eq!(parsed.ident, "Example");
    assert_eq!(parsed.data.take_struct().unwrap().fields.len(), 1);
}