9fc5c2d00d
expand: Implement something similar to `#[cfg(accessible(path))]` cc https://github.com/rust-lang/rust/issues/64797 The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait. Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`. This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution. However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions. Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well. This is a pre-requisite for - turning `#[derive(...)]` into a regular attribute macro, - properly supporting eager expansion for macros that cannot yet be resolved like ``` fn main() { println!(not_available_yet!()); } macro_rules! make_available { () => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }} } make_available!(); ``` |
||
---|---|---|
.. | ||
deriving | ||
format_foreign | ||
asm.rs | ||
assert.rs | ||
Cargo.toml | ||
cfg_accessible.rs | ||
cfg.rs | ||
cmdline_attrs.rs | ||
compile_error.rs | ||
concat_idents.rs | ||
concat.rs | ||
env.rs | ||
format_foreign.rs | ||
format.rs | ||
global_allocator.rs | ||
global_asm.rs | ||
lib.rs | ||
log_syntax.rs | ||
proc_macro_harness.rs | ||
source_util.rs | ||
standard_library_imports.rs | ||
test_harness.rs | ||
test.rs | ||
trace_macros.rs | ||
util.rs |