@@ -70,11 +70,19 @@ fn main() {
7070 let rustc_version = rustc_version ( ) ;
7171
7272 if rustc_version >= ( Version { major : 1 , minor : 77 , patch : 0 } ) {
73- // This tells the `unexpected_cfgs` lint to expect to see all of these
74- // `cfg`s. The `cargo::` syntax was only added in 1.77, so we don't emit
75- // these on earlier toolchain versions.
7673 for version_cfg in & version_cfgs {
74+ // This tells the `unexpected_cfgs` lint to expect to see all of
75+ // these `cfg`s. The `cargo::` syntax was only added in 1.77, so we
76+ // don't emit these on earlier toolchain versions.
7777 println ! ( "cargo:rustc-check-cfg=cfg({})" , version_cfg. cfg_name) ;
78+
79+ // This tells the `unexpected_cfgs` lint to expect to see `cfg`s of
80+ // the form `rust = "1.2.3"`. These aren't real `cfg`s, but we use
81+ // them in `cfg_attr(doc_cfg, doc(cfg(rust = "1.2.3")))` on items
82+ // that are version-gated so that the rendered Rustdoc shows which
83+ // Rust toolchain versions those items are available on.
84+ let Version { major, minor, patch } = version_cfg. version ;
85+ println ! ( "cargo:rustc-check-cfg=cfg(rust, values(\" {}.{}.{}\" ))" , major, minor, patch) ;
7886 }
7987 // FIXME(https://github.com/rust-lang/rust/issues/124816): Remove these
8088 // once they're no longer needed.
0 commit comments