internal: sanity-check minicore flags

This commit is contained in:
Aleksey Kladov 2021-06-15 22:38:21 +03:00
parent 09c4013ec0
commit 2eef66a2ed
2 changed files with 11 additions and 2 deletions

View file

@ -276,6 +276,7 @@ impl MiniCore {
} }
let mut curr_region = ""; let mut curr_region = "";
let mut seen_regions = Vec::new();
for line in lines { for line in lines {
let trimmed = line.trim(); let trimmed = line.trim();
if let Some(region) = trimmed.strip_prefix("// region:") { if let Some(region) = trimmed.strip_prefix("// region:") {
@ -288,6 +289,7 @@ impl MiniCore {
curr_region = ""; curr_region = "";
continue; continue;
} }
seen_regions.push(curr_region);
let mut flag = curr_region; let mut flag = curr_region;
if let Some(idx) = trimmed.find("// :") { if let Some(idx) = trimmed.find("// :") {
@ -305,6 +307,13 @@ impl MiniCore {
buf.push_str(line) buf.push_str(line)
} }
} }
for flag in &self.valid_flags {
if !seen_regions.iter().any(|it| it == flag) {
panic!("unused minicore flag: {:?}", flag);
}
}
buf buf
} }
} }

View file

@ -64,7 +64,7 @@ pub mod ops {
pub use self::deref::Deref; pub use self::deref::Deref;
// endregion:deref // endregion:deref
//region:range // region:range
mod range { mod range {
#[lang = "RangeFull"] #[lang = "RangeFull"]
pub struct RangeFull; pub struct RangeFull;
@ -99,7 +99,7 @@ pub mod ops {
} }
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
pub use self::range::{RangeInclusive, RangeToInclusive}; pub use self::range::{RangeInclusive, RangeToInclusive};
//endregion:range // endregion:range
} }
// region:slice // region:slice