E0468name-resolution

An extern crate loading macros must be at the crate root

Macro-importing `extern crate` placed inside a module instead of the crate root.

Repro

mod inner {
    #[macro_use] extern crate serde;   // E0468: must be at crate root
}

Why

#[macro_use] extern crate declares macros for the whole crate; placing it in a module makes the scope confusing and is rejected. In edition 2018+ this whole pattern is deprecated — use use instead.

Fix

- Move the import to the crate root (lib.rs or main.rs). - Better: drop extern crate entirely and use serde::Serialize (or whichever macros) where needed. - For macro re-exports, use pub use crate_name::macro_name; from the crate root.

Patterns that solve this