mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Specify actions
This commit is contained in:
parent
c116171879
commit
f593393ebb
7 changed files with 64 additions and 17 deletions
|
@ -38,11 +38,7 @@ impl Feature {
|
|||
|
||||
for block in comment_blocks {
|
||||
let id = block.id;
|
||||
assert!(
|
||||
id.split_ascii_whitespace().all(|it| it.starts_with(char::is_uppercase)),
|
||||
"bad feature: {}",
|
||||
id
|
||||
);
|
||||
assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id);
|
||||
let doc = block.contents.join("\n");
|
||||
acc.push(Feature { id, path: path.clone(), doc })
|
||||
}
|
||||
|
@ -52,6 +48,25 @@ impl Feature {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_valid_feature_name(feature: &str) -> bool {
|
||||
'word: for word in feature.split_whitespace() {
|
||||
for &short in ["to"].iter() {
|
||||
if word == short {
|
||||
continue 'word;
|
||||
}
|
||||
}
|
||||
for &short in ["To"].iter() {
|
||||
if word == short {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if !word.starts_with(char::is_uppercase) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
impl fmt::Display for Feature {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, "=== {}", self.id)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue