Expand description

The proc_macro_derive_resolution_fallback lint detects proc macro derives using inaccessible names from parent modules.


#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::*;

pub fn foo1(a: TokenStream) -> TokenStream {
    "mod __bar { static mut BAR: Option<Something> = None; }".parse().unwrap()
extern crate foo;

struct Something;

struct Another;

fn main() {}

This will produce:

warning: cannot find type `Something` in this scope
 --> src/
8 | #[derive(Foo)]
  |          ^^^ names from parent modules are not accessible without an explicit import
  = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #50504 <>


If a proc-macro generates a module, the compiler unintentionally allowed items in that module to refer to items in the crate root without importing them. This is a future-incompatible lint to transition this to a hard error in the future. See issue #50504 for more details.