Make event_enum! error message more helpful
This commit is contained in:
parent
86ca6bb39d
commit
aea827a199
@ -192,11 +192,18 @@ fn to_event_content_path(name: &LitStr) -> TokenStream {
|
||||
pub(crate) fn to_camel_case(name: &LitStr) -> Ident {
|
||||
let span = name.span();
|
||||
let name = name.value();
|
||||
assert_eq!(&name[..2], "m.");
|
||||
|
||||
assert_eq!(
|
||||
&name[..2],
|
||||
"m.",
|
||||
"well-known matrix events have to start with `m.`"
|
||||
);
|
||||
|
||||
let s = name[2..]
|
||||
.split(&['.', '_'] as &[char])
|
||||
.map(|s| s.chars().next().unwrap().to_uppercase().to_string() + &s[1..])
|
||||
.collect::<String>();
|
||||
|
||||
Ident::new(&s, span)
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ error: proc macro panicked
|
||||
|
|
||||
= help: message: assertion failed: `(left == right)`
|
||||
left: `"no"`,
|
||||
right: `"m."`
|
||||
right: `"m."`: well-known matrix events have to start with `m.`
|
||||
|
||||
error[E0433]: failed to resolve: could not find `not` in `ruma_events`
|
||||
--> $DIR/08-enum-invalid-path.rs:6:9
|
||||
|
Loading…
x
Reference in New Issue
Block a user