diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-16 17:14:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 17:14:04 +0100 |
| commit | fc094a1813de0fb58cb9d4be00f5e86701000f2a (patch) | |
| tree | 47307098adff66ef168f74bb3a135ab5c43b3f60 /compiler/rustc_target/src/spec | |
| parent | 34e789a8fb05b5f4ee9e24eff803e2dd6e2bbcc5 (diff) | |
| parent | 6ec3cf9abc15368df705b65e20e7e753d565fe71 (diff) | |
| download | rust-fc094a1813de0fb58cb9d4be00f5e86701000f2a.tar.gz rust-fc094a1813de0fb58cb9d4be00f5e86701000f2a.zip | |
Rollup merge of #137072 - Urgau:check-cfg-load-builtins-at-once, r=Noratrieb
Load all builtin targets at once instead of one by one in check-cfg This PR adds a method on `rustc_target::Target` to load all the builtin targets at once, and then uses that method when constructing the `target_*` values in check-cfg instead of load loading each target one by one by their name, which requires a lookup and was more of a hack anyway. This may give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
Diffstat (limited to 'compiler/rustc_target/src/spec')
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 794d6457cb7..f7e467b0c11 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1658,6 +1658,14 @@ macro_rules! supported_targets { Some(t) } + fn load_all_builtins() -> impl Iterator<Item = Target> { + [ + $( targets::$module::target, )+ + ] + .into_iter() + .map(|f| f()) + } + #[cfg(test)] mod tests { // Cannot put this into a separate file without duplication, make an exception. @@ -3360,6 +3368,11 @@ impl Target { } } + /// Load all built-in targets + pub fn builtins() -> impl Iterator<Item = Target> { + load_all_builtins() + } + /// Search for a JSON file specifying the given target tuple. /// /// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the |
