rust/src/librustc_feature
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
..
accepted.rs stabilize transparent_enums 2020-01-20 11:18:05 +01:00
active.rs Add min_specialization feature 2020-03-15 12:44:25 +00:00
builtin_attrs.rs Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasper 2020-03-17 03:05:12 +01:00
Cargo.toml Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
lib.rs Fix crate paths in comments 2020-01-13 01:07:43 +09:00
removed.rs Remove the no_debug feature 2020-03-03 18:22:05 +09:00