Expand discriminant overflow error message
Renders as:
error[cxxbridge]: discriminant overflow on value after 4294967295
┌─ src/main.rs:11:9
│
11 │ B,
│ ^ discriminant overflow
│
= note: explicitly set `= 0` if that is desired outcome
This more closely matches rustc's error message, which is:
error[E0370]: enum discriminant overflowed
--> src/lib.rs:4:5
|
4 | B,
| ^ overflowed on value after 255
|
= note: explicitly set `B = 0` if that is desired outcome
diff --git a/syntax/parse.rs b/syntax/parse.rs
index 1f6cbac..7e4422d 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -112,7 +112,8 @@
}
}
if variant.discriminant.is_none() && prev_discriminant.unwrap_or(0) == u32::MAX {
- return Err(Error::new_spanned(variant, "overflowed on value"));
+ let msg = format!("discriminant overflow on value after {}", u32::MAX);
+ return Err(Error::new_spanned(variant, msg));
}
let discriminant =
parse_discriminant(&variant)?.unwrap_or_else(|| prev_discriminant.map_or(0, |n| n + 1));