Closed
Description
Apologies if this has already been reported; I didn't search too hard.
STR
// bar/src/lib.rs
#![feature(proc_macro)]
extern crate proc_macro;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
#[proc_macro]
pub fn bar(_: TokenStream) -> TokenStream {
quote!(mod __bar {
// NOTE `Foo` is never imported in this module
static mut BAR: Option<Foo> = None;
}).into()
}
// foo/src/lib.rs
#![feature(proc_macro)]
extern crate bar;
use bar::bar;
struct Foo;
bar!();
This code compiles but I would expect it not to because the expanded form doesn't compile:
// foo/src/lib.rs -- `cargo expand`-ed and cleaned up
struct Foo;
mod __bar {
static mut BAR: Option<Foo> = None;
}
$ cargo build
error[E0412]: cannot find type `Foo` in this scope
--> src/lib.rs:4:28
|
4 | static mut BAR: Option<Foo> = None;
| ^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
4 | use Foo;
|
error: aborting due to previous error
Meta
$ rustc -V
rustc 1.27.0-nightly (428ea5f6b 2018-05-06)
cc @jseyfried