You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on and PR for fixing serde-rs/serde#2105 and the related stuff and making compiletests for them. For the piece
#[derive(Serialize)]#[serde(tag = "type")]enumSerializable{/// Error should be reportedTuple2(u8,u8),}
the error span would cover several lines:
error: #[serde(tag = "...")] cannot be used with tuple variants
--> tests/ui/enum-representation/internal-tuple-variant.rs:10:5
|
10 | / /// Error should be reported
11 | | Tuple2(u8, u8),
| |__________________^
Because doc comments can be very long, it is impractical to bring them into error messages. I would like to get the following message:
error: #[serde(tag = "...")] cannot be used with tuple variants
--> tests/ui/enum-representation/internal-tuple-variant.rs:10:5
|
10 | /// Error should be reported
11 | Tuple2(u8, u8),
| ^^^^^^^^^^^^^^
That error is generated by the following code in serde (here in action):
// variant.original is a `&syn::Variant`
cx.error_spanned_by(
variant.original,"#[serde(tag = \"...\")] cannot be used with tuple variants",);
Is there any way to strip span that related to doc comments (and probably to all other attributes) and keep only code span of syn::Variant, syn::Field, etc?
The text was updated successfully, but these errors were encountered:
The range that the error points to is determined by providing a ToTokens implementation that contains the tokens which are to be highlighted in the error. So for this case, something like:
let error = syn::Error::new_spanned(WithoutAttrs(variant.original),"...",);
I'm working on and PR for fixing serde-rs/serde#2105 and the related stuff and making compiletests for them. For the piece
the error span would cover several lines:
Because doc comments can be very long, it is impractical to bring them into error messages. I would like to get the following message:
That error is generated by the following code in serde (here in action):
Is there any way to strip span that related to doc comments (and probably to all other attributes) and keep only code span of
syn::Variant
,syn::Field
, etc?The text was updated successfully, but these errors were encountered: