File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
manifest/tests/ui/invalid Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ TOML parse error at line 6, column 12
22 |
336 | [component.bad_id]
44 | ^^^^^^
5- '-'-separated words may only contain alphanumeric ASCII; got '_'
5+ words must be separated with '-', not '_'
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ impl<const DELIM: char> TryFrom<String> for Id<DELIM> {
3333 if id. is_empty ( ) {
3434 return Err ( "empty" . into ( ) ) ;
3535 }
36+ // Special-case common "wrong separator" errors
37+ if let Some ( wrong) = wrong_delim :: < DELIM > ( ) {
38+ if id. contains ( wrong) {
39+ return Err ( format ! (
40+ "words must be separated with {DELIM:?}, not {wrong:?}"
41+ ) ) ;
42+ }
43+ }
3644 for word in id. split ( DELIM ) {
3745 if word. is_empty ( ) {
3846 return Err ( format ! ( "{DELIM:?}-separated words must not be empty" ) ) ;
@@ -59,3 +67,11 @@ impl<const DELIM: char> TryFrom<String> for Id<DELIM> {
5967 Ok ( Self ( id) )
6068 }
6169}
70+
71+ const fn wrong_delim < const DELIM : char > ( ) -> Option < char > {
72+ match DELIM {
73+ '_' => Some ( '-' ) ,
74+ '-' => Some ( '_' ) ,
75+ _ => None ,
76+ }
77+ }
You can’t perform that action at this time.
0 commit comments