Skip to content

Commit aa76ce3

Browse files
bors[bot]matklad
andauthored
Merge #6142
6142: Fix feature name r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents e5f252a + bff812d commit aa76ce3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

crates/ide/src/completion/complete_postfix/format_like.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Feature: Postfix completion for `format`-like strings.
1+
// Feature: Format String Completion.
22
//
33
// `"Result {result} is {2 + 2}"` is expanded to the `"Result {} is {}", result, 2 + 2`.
44
//

xtask/src/codegen/gen_feature_docs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ impl Feature {
3838

3939
for block in comment_blocks {
4040
let id = block.id;
41-
assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id);
41+
if let Err(msg) = is_valid_feature_name(&id) {
42+
panic!("invalid feature name: {:?}:\n {}", id, msg)
43+
}
4244
let doc = block.contents.join("\n");
4345
let location = Location::new(path.clone(), block.line);
4446
acc.push(Feature { id, location, doc })
@@ -49,7 +51,7 @@ impl Feature {
4951
}
5052
}
5153

52-
fn is_valid_feature_name(feature: &str) -> bool {
54+
fn is_valid_feature_name(feature: &str) -> Result<(), String> {
5355
'word: for word in feature.split_whitespace() {
5456
for &short in ["to", "and"].iter() {
5557
if word == short {
@@ -58,14 +60,14 @@ fn is_valid_feature_name(feature: &str) -> bool {
5860
}
5961
for &short in ["To", "And"].iter() {
6062
if word == short {
61-
return false;
63+
return Err(format!("Don't capitalize {:?}", word));
6264
}
6365
}
6466
if !word.starts_with(char::is_uppercase) {
65-
return false;
67+
return Err(format!("Capitalize {:?}", word));
6668
}
6769
}
68-
true
70+
Ok(())
6971
}
7072

7173
impl fmt::Display for Feature {

0 commit comments

Comments
 (0)