summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/cfg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/rust-analyzer/crates/cfg
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rust-analyzer/crates/cfg')
-rw-r--r--src/tools/rust-analyzer/crates/cfg/src/lib.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/cfg/src/lib.rs b/src/tools/rust-analyzer/crates/cfg/src/lib.rs
index 183b9b7d2..0aeb0b050 100644
--- a/src/tools/rust-analyzer/crates/cfg/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/cfg/src/lib.rs
@@ -86,6 +86,32 @@ impl CfgOptions {
}
}
+impl Extend<CfgAtom> for CfgOptions {
+ fn extend<T: IntoIterator<Item = CfgAtom>>(&mut self, iter: T) {
+ iter.into_iter().for_each(|cfg_flag| _ = self.enabled.insert(cfg_flag));
+ }
+}
+
+impl IntoIterator for CfgOptions {
+ type Item = <FxHashSet<CfgAtom> as IntoIterator>::Item;
+
+ type IntoIter = <FxHashSet<CfgAtom> as IntoIterator>::IntoIter;
+
+ fn into_iter(self) -> Self::IntoIter {
+ <FxHashSet<CfgAtom> as IntoIterator>::into_iter(self.enabled)
+ }
+}
+
+impl<'a> IntoIterator for &'a CfgOptions {
+ type Item = <&'a FxHashSet<CfgAtom> as IntoIterator>::Item;
+
+ type IntoIter = <&'a FxHashSet<CfgAtom> as IntoIterator>::IntoIter;
+
+ fn into_iter(self) -> Self::IntoIter {
+ <&FxHashSet<CfgAtom> as IntoIterator>::into_iter(&self.enabled)
+ }
+}
+
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct CfgDiff {
// Invariants: No duplicates, no atom that's both in `enable` and `disable`.