[英]How cfg are dealt with in rustc?
This is a further question on How to extract nightly features used in a crate?这是关于如何提取板条箱中使用的夜间特征的进一步问题? .
.
I also want to know where and how #,[cfg_attr(target_os = "macos". feature(...))]
is turned into #.[feature(...)
.我还想知道
#,[cfg_attr(target_os = "macos". feature(...))]
在哪里以及如何变成#.[feature(...)
。
Could someone give me some tips about the process of rustc dealing with cfg.有人可以给我一些关于 rustc 处理 cfg 的过程的提示。
The rustc_expand
crate is responsible for expanding macros. rustc_expand
crate 负责扩展宏。 It special cases #[cfg]
and #[cfg_attr]
when parsing attribute macros such that they aren't treated like normal macros.在解析属性宏时, 特殊情况
#[cfg]
和#[cfg_attr]
不会像普通宏一样对待。
rustc_expand
calls rustc_parse::parse_cfg_attr
to parse the attribute. rustc_expand
调用rustc_parse::parse_cfg_attr
来解析属性。rustc_expand
calls rustc_attr::cfg_matches
to evaluate if the condition is met.rustc_expand
调用rustc_attr::cfg_matches
来评估是否满足条件。rustc_expand
then either includes or doesn't include the attribute passed as an argument. rustc_expand
然后包含或不包含作为参数传递的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.