Repository: tokio-rs/tokio
File: tokio/build.rs (Rust)

Code before:
const CONST_MUTEX_NEW_PROBE: &str = r#"
{
    static MY_MUTEX: ::std::sync::Mutex<i32> = ::std::sync::Mutex::new(1);
    *MY_MUTEX.lock().unwrap()
}
"#;

const TARGET_HAS_ATOMIC_PROBE: &str = r#"
{
    #[cfg(target_has_atomic = "ptr")]
    let _ = (); 
}
"#;

const TARGET_ATOMIC_U64_PROBE: &str = r#"
{
    use std::sync::atomic::AtomicU64 as _;
}
"#;

fn main() {
    let mut enable_const_thread_local = false;
    let mut enable_addr_of = false;
    let mut enable_target_has_atomic = false;
    let mut enable_const_mutex_new = false;
    let mut target_needs_atomic_u64_fallback = true;

    match AutoCfg::new() {
        Ok(ac) => {
            // These checks prefer to call only `probe_rustc_version` if that is
            // enough to determine whether the feature is supported. This is
            // because the `probe_expression` call involves a call to rustc,
            // which the `probe_rustc_version` call avoids.

            // Const-initialized thread locals were stabilized in 1.59.
            if ac.probe_rustc_version(1, 60) {
                enable_const_thread_local = true;
            } else if ac.probe_rustc_version(1, 59) {
                // This compiler claims to be 1.59, but there are some nightly
                // compilers that claim to be 1.59 without supporting the
                // feature. Explicitly probe to check if code using them
                // compiles.
                //
                // The oldest nightly that supports the feature is 2021-12-06.
                if ac.probe_expression(CONST_THREAD_LOCAL_PROBE) {
                    enable_const_thread_local = true;
                }
            }

            // The `addr_of` and `addr_of_mut` macros were stabilized in 1.51.
            if ac.probe_rustc_version(1, 52) {

Review comment (suggestion):
```suggestion
    let mut target_needs_atomic_u64_fallback = false;
```

Code after:
const CONST_MUTEX_NEW_PROBE: &str = r#"
{
    static MY_MUTEX: ::std::sync::Mutex<i32> = ::std::sync::Mutex::new(1);
    *MY_MUTEX.lock().unwrap()
}
"#;

const TARGET_HAS_ATOMIC_PROBE: &str = r#"
{
    #[cfg(target_has_atomic = "ptr")]
    let _ = (); 
}
"#;

const TARGET_ATOMIC_U64_PROBE: &str = r#"
{
    use std::sync::atomic::AtomicU64 as _;
}
"#;

fn main() {
    let mut enable_const_thread_local = false;
    let mut enable_addr_of = false;
    let mut enable_target_has_atomic = false;
    let mut enable_const_mutex_new = false;
    let mut target_needs_atomic_u64_fallback = false;

    match AutoCfg::new() {
        Ok(ac) => {
            // These checks prefer to call only `probe_rustc_version` if that is
            // enough to determine whether the feature is supported. This is
            // because the `probe_expression` call involves a call to rustc,
            // which the `probe_rustc_version` call avoids.

            // Const-initialized thread locals were stabilized in 1.59.
            if ac.probe_rustc_version(1, 60) {
                enable_const_thread_local = true;
            } else if ac.probe_rustc_version(1, 59) {
                // This compiler claims to be 1.59, but there are some nightly
                // compilers that claim to be 1.59 without supporting the
                // feature. Explicitly probe to check if code using them
                // compiles.
                //
                // The oldest nightly that supports the feature is 2021-12-06.
                if ac.probe_expression(CONST_THREAD_LOCAL_PROBE) {
                    enable_const_thread_local = true;
                }
            }

            // The `addr_of` and `addr_of_mut` macros were stabilized in 1.51.
            if ac.probe_rustc_version(1, 52) {