Rollup of 7 pull requests by Centril · Pull Request #70062 · rust-lang/rust (original) (raw)

expand: Implement something similar to #[cfg(accessible(path))]

cc rust-lang#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