mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-03 10:47:16 +00:00

Originally, we used an array of `riscv_hwprobe` directly and indexed using raw numbers, making correspondence between the index and the query key less obvious. We also frequently used `out[idx].key != -1` to test whether the key is supported by the `riscv_hwprobe` system call (on the Linux kernel version we are testing) but we'd better to integrate with an operation to retrieve the value. This commit improves the ergonomics of feature querying by: 1. Utilizing macros to a. enable indexing by identifier names and b. encapsulate accesses to the `riscv_hwprobe` array to query and 2. New method `riscv_hwprobe::get()` returning `Option<u64>`, integrating availability checking and value retrieval. It also removes `has_ima` for now because it's redundant if we only need to test for single base behavior.