Skip to content

guide: Add a fn main() to avoid a macro scope warning

Ian Jackson requested to merge macro-scope into main

Without this, this text generates the following warning:

  warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
    --> target/debug/build/derive-deftly-book-tests-556024dcaed7b4a7/out/book_chapters.rs:66:1
     |
  7  | / derive_deftly::define_derive_deftly! {
  8  | |     /// Derives `HelloWorld`, providing `greet`
  9  | |     pub HelloWorld:
  10 | |     impl $crate::HelloWorld for $ttype {
  ...  |
  14 | |     }
  15 | | }
     | |_^
     |
     = help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
     = note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
     = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
     = note: the macro `derive_deftly::define_derive_deftly` may come from an old version of the `derive_deftly_macros` crate, try updating your dependency with `cargo update -p derive_deftly_macros`
     = note: `#[warn(non_local_definitions)]` on by default
     = note: this warning originates in the macro `derive_deftly::define_derive_deftly` (in Nightly builds, run with -Z macro-backtrace for more info)

(However, by default, it's suppressed; I'll file a separate ticket about that.)

Merge request reports

Loading