dtolnay / proc-macro-workshop

Learn to write Rust procedural macros  [Rust Latam conference, Montevideo Uruguay, March 2019]
Apache License 2.0
4k stars 1.01k forks source link

sorted: update 02-not-enum.stderr #35

Closed suyash closed 3 years ago

suyash commented 3 years ago

On my machine I am seeing an additional message on trying to implement the second test for sorted.

My implementation

#[proc_macro_attribute]
pub fn sorted(args: TokenStream, input: TokenStream) -> TokenStream {
    let item = parse_macro_input!(input as Item);

    match item {
        Item::Enum(item) => {
            let stream = quote! { #item };
            stream.into()
        }
        _ => Error::new_spanned(
            TokenStream2::from(args),
            "expected enum or match expression",
        )
        .to_compile_error()
        .into(),
    }
}

I have tried other things also, still getting the additional line in the error for attribute macro.

rustc --version output:

rustc 1.45.2 (d3fb005a3 2020-07-31)

Not sure if I am doing something wrong. Also the additional line specifically mentions attribute macro, and so far I have only implemented the derive and functional macro exercises from before