rust/src/librustc_builtin_macros
Mazdak Farrokhzad 9fc5c2d00d
Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasper
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!();
    ```
2020-03-17 03:05:12 +01:00
..
deriving Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasper 2020-03-17 03:05:12 +01:00
format_foreign Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
asm.rs Rollup merge of #69579 - petrochenkov:noprevspan, r=Centril 2020-03-01 19:28:10 +09:00
assert.rs ast: Mac/Macro -> MacCall 2020-03-12 22:26:52 +03:00
Cargo.toml Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
cfg_accessible.rs builtin_macros: Add attribute macro #[cfg_accessible(path)] 2020-03-10 01:02:13 +03:00
cfg.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
cmdline_attrs.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
compile_error.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
concat_idents.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
concat.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
env.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
format_foreign.rs Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
format.rs rustc_parse: Use Token::ident where possible 2020-03-09 12:42:41 +03:00
global_allocator.rs Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) 2020-03-05 16:39:12 +01:00
global_asm.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
lib.rs builtin_macros: Add attribute macro #[cfg_accessible(path)] 2020-03-10 01:02:13 +03:00
log_syntax.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
proc_macro_harness.rs ast: Mac/Macro -> MacCall 2020-03-12 22:26:52 +03:00
source_util.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
standard_library_imports.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
test_harness.rs ast: Mac/Macro -> MacCall 2020-03-12 22:26:52 +03:00
test.rs ast: Mac/Macro -> MacCall 2020-03-12 22:26:52 +03:00
trace_macros.rs Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
util.rs expand/builtin_macros: Minor cleanup 2020-03-09 20:50:48 +03:00