Skip to content

Commit

Permalink
Suppress ugly additional error message when unsafe-assume-single-core…
Browse files Browse the repository at this point in the history
… feature is wrongly enabled

After:

```
error: `portable_atomic_unsafe_assume_single_core` cfg (`unsafe-assume-single-core` feature) does not compatible with target that supports atomic CAS;
       see also <#148> for troubleshooting
   --> src/lib.rs:335:1
    |
335 | / compile_error!(
336 | |     "`portable_atomic_unsafe_assume_single_core` cfg (`unsafe-assume-single-core` feature) \
337 | |      does not compatible with target that supports atomic CAS;\n\
338 | |      see also <#148> for troubleshooting"
339 | | );
    | |_^
```

Before:

```
error: `portable_atomic_unsafe_assume_single_core` cfg (`unsafe-assume-single-core` feature) does not compatible with target that supports atomic CAS;
       see also <#148> for troubleshooting
   --> src/lib.rs:335:1
    |
335 | / compile_error!(
336 | |     "`portable_atomic_unsafe_assume_single_core` cfg (`unsafe-assume-single-core` feature) \
337 | |      does not compatible with target that supports atomic CAS;\n\
338 | |      see also <#148> for troubleshooting"
339 | | );
    | |_^

error[E0433]: failed to resolve: could not find `AtomicU8` in `imp`
   --> src/lib.rs:643:14
    |
643 |         imp::AtomicU8::is_lock_free()
    |              ^^^^^^^^ could not find `AtomicU8` in `imp`
    |
help: a struct with a similar name exists
    |
643 |         imp::AtomicU128::is_lock_free()
    |              ~~~~~~~~~~
help: consider importing this struct
    |
444 + use core::sync::atomic::AtomicU8;
    |
help: if you import `AtomicU8`, refer to it directly
    |
643 -         imp::AtomicU8::is_lock_free()
643 +         AtomicU8::is_lock_free()
    |

error[E0433]: failed to resolve: could not find `AtomicU8` in `imp`
   --> src/lib.rs:665:14
    |
665 |         imp::AtomicU8::IS_ALWAYS_LOCK_FREE
    |              ^^^^^^^^ could not find `AtomicU8` in `imp`
    |
help: a struct with a similar name exists
    |
665 |         imp::AtomicU128::IS_ALWAYS_LOCK_FREE
    |              ~~~~~~~~~~
help: consider importing this struct
    |
444 + use core::sync::atomic::AtomicU8;
    |
help: if you import `AtomicU8`, refer to it directly
    |
665 -         imp::AtomicU8::IS_ALWAYS_LOCK_FREE
665 +         AtomicU8::IS_ALWAYS_LOCK_FREE
    |

<omitted>

error[E0730]: cannot pattern-match on an array without a fixed length
    --> src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^
     |
    ::: src/lib.rs:4562:5
     |
4562 |     atomic_int!(AtomicU64, u64, 8);
     |     ------------------------------ in this macro invocation
     |
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
```
  • Loading branch information
taiki-e committed Sep 19, 2024
1 parent 8591245 commit 61dcaaa
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/imp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@
portable_atomic_no_atomic_load_store,
not(all(target_arch = "bpf", not(feature = "critical-section"))),
),
portable_atomic_unsafe_assume_single_core,
target_arch = "avr",
target_arch = "msp430",
)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
any(
target_arch = "riscv32",
target_arch = "riscv64",
feature = "critical-section",
portable_atomic_unsafe_assume_single_core,
),
portable_atomic_no_atomic_cas,
)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
any(
target_arch = "riscv32",
target_arch = "riscv64",
feature = "critical-section",
portable_atomic_unsafe_assume_single_core,
),
not(target_has_atomic = "ptr"),
)))
)]
Expand Down Expand Up @@ -310,21 +319,30 @@ pub(crate) mod float;

#[cfg(not(any(
portable_atomic_no_atomic_load_store,
portable_atomic_unsafe_assume_single_core,
target_arch = "avr",
target_arch = "msp430",
)))]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
any(
target_arch = "riscv32",
target_arch = "riscv64",
feature = "critical-section",
portable_atomic_unsafe_assume_single_core,
),
portable_atomic_no_atomic_cas,
)))
)]
#[cfg_attr(
not(portable_atomic_no_cfg_target_has_atomic),
cfg(not(all(
any(target_arch = "riscv32", target_arch = "riscv64", feature = "critical-section"),
any(
target_arch = "riscv32",
target_arch = "riscv64",
feature = "critical-section",
portable_atomic_unsafe_assume_single_core,
),
not(target_has_atomic = "ptr"),
)))
)]
Expand Down

0 comments on commit 61dcaaa

Please sign in to comment.