Skip to content

Commit 5cfea26

Browse files
committed
build: configure min const generics
1 parent 7814c2a commit 5cfea26

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

build.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,17 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<()> {
854854
println!("cargo:rustc-cfg=Py_3_{}", i);
855855
}
856856

857+
configure_min_const_generics();
858+
857859
Ok(())
858860
}
859861

862+
fn configure_min_const_generics() {
863+
if rustc_minor_version().unwrap_or(0) >= 51 {
864+
println!("cargo:rustc-cfg=min_const_generics");
865+
}
866+
}
867+
860868
fn check_target_architecture(interpreter_config: &InterpreterConfig) -> Result<()> {
861869
// Try to check whether the target architecture matches the python library
862870
let rust_target = match cargo_env_var("CARGO_CFG_TARGET_POINTER_WIDTH")
@@ -922,7 +930,7 @@ fn configure_abi3_without_interpreter() {
922930
}
923931

924932
fn rustc_minor_version() -> Option<u32> {
925-
let rustc = env::var_os("RUSTC")?;
933+
let rustc = env_var("RUSTC")?;
926934
let output = Command::new(rustc).arg("--version").output().ok()?;
927935
let version = core::str::from_utf8(&output.stdout).ok()?;
928936
let mut pieces = version.split('.');
@@ -932,12 +940,6 @@ fn rustc_minor_version() -> Option<u32> {
932940
pieces.next()?.parse().ok()
933941
}
934942

935-
fn manage_min_const_generics() {
936-
if rustc_minor_version().unwrap_or(0) >= 51 {
937-
println!("cargo:rustc-cfg=min_const_generics");
938-
}
939-
}
940-
941943
fn main_impl() -> Result<()> {
942944
// If PYO3_NO_PYTHON is set with abi3, we can build PyO3 without calling Python.
943945
// We only check for the abi3-py3{ABI3_MAX_MINOR} because lower versions depend on it.
@@ -974,8 +976,6 @@ fn main_impl() -> Result<()> {
974976
println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, flag)
975977
}
976978

977-
manage_min_const_generics();
978-
979979
Ok(())
980980
}
981981

0 commit comments

Comments
 (0)