Suspicious error reporting from cargo check

Hello!

I was following the derive macros chapter of the book and while playing around I added some incorrect code that tries to print syn::derive::DeriveInput. It does not implement std::fmt::Display and naturally I get the error when I run cargo check. However, I believe this is not the correct place for rustc to report it.

Can someone explain why this is happening?

My code:

extern crate proc_macro;

use crate::proc_macro::TokenStream;
use quote::quote;
use syn;

#[proc_macro_derive(HelloMacro)]
pub fn hello_macro_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    println!("{}", ast); // <-- Wrong line

    impl_hello_macro(&ast)
}

fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream {
    let name = &ast.ident;
    let gen = quote! {
        impl HelloMacro for #name {
            fn hello_macro() {
                println!("Hello, Macro! My name is {}", stringify!(#name));
            }
        }
    };
    gen.into()
}

Error:

error[E0277]: `syn::derive::DeriveInput` doesn't implement `std::fmt::Display`
--> src/lib.rs:12:22
     |
12   |     impl_hello_macro(&ast)
     |                      ^^^^ `syn::derive::DeriveInput` cannot be formatted with the default formatter
     |
     = help: the trait `std::fmt::Display` is not implemented for `syn::derive::DeriveInput`
     = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
     = note: required by `std::fmt::Display::fmt`

error: aborting due to previous error

Just in case this is the output of rustc --version --verbose:

rustc 1.39.0 (4560ea788 2019-11-04)
binary: rustc
commit-hash: 4560ea788cb760f0a34127156c78e2552949f734
commit-date: 2019-11-04
host: x86_64-unknown-linux-gnu
release: 1.39.0
LLVM version: 9.0

Thanks!