Feature `proc_macro_span` is not known

The following snippet fails to compile: playground

lib.rs:

#![feature(proc_macro_span)

error[E0635]: unknown feature `proc_macro_span`

adding use proc_macro2::Span; makes this compile successfully.

Is this error intended?

The feature proc_macro_span is defined inside proc_macro. If it isn't used directly or indirectly, for example through proc_macro2, rustc will never learn about it's existence and give an error.

1 Like

Features are defined inside crates and the compiler learns about them on the fly?

Yes, library features are defined inside crates. They are introduced with attributes like #[unstable(feature = "proc_macro_span", issue = "54725")]. There are also language features defined inside the compiler. (See the files in https://github.com/rust-lang/rust/tree/54b7d21f59a363e53eb1c31d76b40af2ff99321c/src/librustc_feature for a complete list.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.