Skip to content

Commit e13aab7

Browse files
authored
Merge pull request rust-lang#20884 from ChayimFriedman2/fix-cfg-error
fix: Fix "cannot insert `true` or `false` to cfg" error in fixtures
2 parents 3cc95df + 385bd28 commit e13aab7

File tree

2 files changed

+8
-1
lines changed
  • src/tools/rust-analyzer/crates

2 files changed

+8
-1
lines changed

src/tools/rust-analyzer/crates/cfg/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ impl CfgOptions {
115115
pub fn shrink_to_fit(&mut self) {
116116
self.enabled.shrink_to_fit();
117117
}
118+
119+
pub fn append(&mut self, other: CfgOptions) {
120+
// Do not call `insert_any_atom()`, as it'll check for `true` and `false`, but this is not
121+
// needed since we already checked for that when constructing `other`. Furthermore, this
122+
// will always err, as `other` inevitably contains `true` (just as we do).
123+
self.enabled.extend(other.enabled);
124+
}
118125
}
119126

120127
impl Extend<CfgAtom> for CfgOptions {

src/tools/rust-analyzer/crates/test-fixture/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl ChangeFixture {
252252
assert!(default_crate_root.is_none());
253253
default_crate_root = Some(file_id);
254254
default_edition = meta.edition;
255-
default_cfg.extend(meta.cfg.into_iter());
255+
default_cfg.append(meta.cfg);
256256
default_env.extend_from_other(&meta.env);
257257
}
258258

0 commit comments

Comments
 (0)