diff options
-rw-r--r-- | crates/ide/src/completion/complete_postfix/format_like.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/gen_feature_docs.rs | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/crates/ide/src/completion/complete_postfix/format_like.rs b/crates/ide/src/completion/complete_postfix/format_like.rs index 0287fc803..81c33bf3a 100644 --- a/crates/ide/src/completion/complete_postfix/format_like.rs +++ b/crates/ide/src/completion/complete_postfix/format_like.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | // Feature: Postfix completion for `format`-like strings. | 1 | // Feature: Format String Completion. |
2 | // | 2 | // |
3 | // `"Result {result} is {2 + 2}"` is expanded to the `"Result {} is {}", result, 2 + 2`. | 3 | // `"Result {result} is {2 + 2}"` is expanded to the `"Result {} is {}", result, 2 + 2`. |
4 | // | 4 | // |
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 3f0013e82..341e67c73 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs | |||
@@ -38,7 +38,9 @@ impl Feature { | |||
38 | 38 | ||
39 | for block in comment_blocks { | 39 | for block in comment_blocks { |
40 | let id = block.id; | 40 | 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 | } | ||
42 | let doc = block.contents.join("\n"); | 44 | let doc = block.contents.join("\n"); |
43 | let location = Location::new(path.clone(), block.line); | 45 | let location = Location::new(path.clone(), block.line); |
44 | acc.push(Feature { id, location, doc }) | 46 | acc.push(Feature { id, location, doc }) |
@@ -49,7 +51,7 @@ impl Feature { | |||
49 | } | 51 | } |
50 | } | 52 | } |
51 | 53 | ||
52 | fn is_valid_feature_name(feature: &str) -> bool { | 54 | fn is_valid_feature_name(feature: &str) -> Result<(), String> { |
53 | 'word: for word in feature.split_whitespace() { | 55 | 'word: for word in feature.split_whitespace() { |
54 | for &short in ["to", "and"].iter() { | 56 | for &short in ["to", "and"].iter() { |
55 | if word == short { | 57 | if word == short { |
@@ -58,14 +60,14 @@ fn is_valid_feature_name(feature: &str) -> bool { | |||
58 | } | 60 | } |
59 | for &short in ["To", "And"].iter() { | 61 | for &short in ["To", "And"].iter() { |
60 | if word == short { | 62 | if word == short { |
61 | return false; | 63 | return Err(format!("Don't capitalize {:?}", word)); |
62 | } | 64 | } |
63 | } | 65 | } |
64 | if !word.starts_with(char::is_uppercase) { | 66 | if !word.starts_with(char::is_uppercase) { |
65 | return false; | 67 | return Err(format!("Capitalize {:?}", word)); |
66 | } | 68 | } |
67 | } | 69 | } |
68 | true | 70 | Ok(()) |
69 | } | 71 | } |
70 | 72 | ||
71 | impl fmt::Display for Feature { | 73 | impl fmt::Display for Feature { |