]> git.lizzy.rs Git - rust.git/commitdiff
internal: sanity-check minicore flags
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jun 2021 19:38:21 +0000 (22:38 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 15 Jun 2021 19:38:21 +0000 (22:38 +0300)
crates/test_utils/src/fixture.rs
crates/test_utils/src/minicore.rs

index 535892f3fcdc4f1e4aab34605aed2d13f76e2632..7791460845815a216ca3d182338137a84f001c1c 100644 (file)
@@ -276,6 +276,7 @@ pub fn source_code(mut self) -> String {
         }
 
         let mut curr_region = "";
+        let mut seen_regions = Vec::new();
         for line in lines {
             let trimmed = line.trim();
             if let Some(region) = trimmed.strip_prefix("// region:") {
@@ -288,6 +289,7 @@ pub fn source_code(mut self) -> String {
                 curr_region = "";
                 continue;
             }
+            seen_regions.push(curr_region);
 
             let mut flag = curr_region;
             if let Some(idx) = trimmed.find("// :") {
@@ -305,6 +307,13 @@ pub fn source_code(mut self) -> String {
                 buf.push_str(line)
             }
         }
+
+        for flag in &self.valid_flags {
+            if !seen_regions.iter().any(|it| it == flag) {
+                panic!("unused minicore flag: {:?}", flag);
+            }
+        }
+
         buf
     }
 }
index f9f14b7dfa879e8b8fba0f42999b2751539d4f45..8c0d122dc83c35c8007858f02141b916a7049195 100644 (file)
@@ -64,7 +64,7 @@ pub trait Deref {
     pub use self::deref::Deref;
     // endregion:deref
 
-    //region:range
+    // region:range
     mod range {
         #[lang = "RangeFull"]
         pub struct RangeFull;
@@ -99,7 +99,7 @@ pub struct RangeToInclusive<Idx> {
     }
     pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
     pub use self::range::{RangeInclusive, RangeToInclusive};
-    //endregion:range
+    // endregion:range
 }
 
 // region:slice