From 39f10339ad205f364a7e622f4be259cd4961a0e8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 21 Aug 2024 17:01:41 +1000 Subject: [PATCH] Document the new build script magic This is a follow up to #3182 which introduced a new way of conditionally including code based on the compiler version. When originally reviewing I missed the fact that the two loops were controlled by the current compiler version (`minor`) so the created macro is different dependent on the compiler used to build the code. To help the next guy notice, add a comment. --- internals/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internals/build.rs b/internals/build.rs index b055def60..8b1007c28 100644 --- a/internals/build.rs +++ b/internals/build.rs @@ -59,6 +59,9 @@ fn write_macro(mut macro_file: impl io::Write, msrv_minor: u64, minor: u64) -> i writeln!(macro_file, "/// Currently only the `>=` operator is supported.")?; writeln!(macro_file, "#[macro_export]")?; writeln!(macro_file, "macro_rules! rust_version {{")?; + + // These two loops are the magic; we output the clause if_yes/if_no + // dependent on the current compiler version (`minor`). for version in msrv_minor..=minor { writeln!(macro_file, " (if >= 1.{} {{ $($if_yes:tt)* }} $(else {{ $($if_no:tt)* }})?) => {{", version)?; writeln!(macro_file, " $($if_yes)*")?;