mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-18 20:11:03 +00:00
Guard against duplicate matchers in build script
This commit is contained in:
parent
de6d418d42
commit
0c93ca80f4
@ -38,7 +38,7 @@ impl MappingTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, DeserializeFromStr)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, DeserializeFromStr)]
|
||||||
/// A single matcher.
|
/// A single matcher.
|
||||||
///
|
///
|
||||||
/// Codegen converts this into a `Lazy<GlobMatcher>`.
|
/// Codegen converts this into a `Lazy<GlobMatcher>`.
|
||||||
@ -124,7 +124,7 @@ impl Matcher {
|
|||||||
/// A segment in a matcher.
|
/// A segment in a matcher.
|
||||||
///
|
///
|
||||||
/// Corresponds to `syntax_mapping::MatcherSegment`.
|
/// Corresponds to `syntax_mapping::MatcherSegment`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
enum MatcherSegment {
|
enum MatcherSegment {
|
||||||
Text(String),
|
Text(String),
|
||||||
Env(String),
|
Env(String),
|
||||||
@ -196,6 +196,14 @@ fn read_all_mappings() -> anyhow::Result<MappingList> {
|
|||||||
all_mappings.extend(mappings.0);
|
all_mappings.extend(mappings.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let duplicates = all_mappings
|
||||||
|
.iter()
|
||||||
|
.duplicates_by(|(matcher, _)| matcher)
|
||||||
|
.collect_vec();
|
||||||
|
if !duplicates.is_empty() {
|
||||||
|
bail!("Rules with duplicate matchers found: {duplicates:?}");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(MappingList(all_mappings))
|
Ok(MappingList(all_mappings))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user