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
When a shape is annotated with @error, the code generator implements the std::error::Error and std::fmt::Display trait for that error structure. However, if this error structure contains a member field that references another structure, the code generator doesn't implement Display for the referenced structure, resulting in compilation errors.
For example, the following model generates uncompilable code:
The root cause is that when a shape is annotated with @error, the code generator implements std::error::Error for that type:
impl std::error::ErrorforErrorInInput{}
This implementation requires that the type also implements the Display trait. While the code generator correctly implements Display for ErrorInInput, it attempts to forward the display implementation to the message field. However, since ErrorMessage structure doesn't have a Display implementation, compilation fails.
Generated Code
pub struct ErrorInInput {
#[allow(missing_docs)] // documentation missing in model
pub message: ::std::option::Option<crate::model::ErrorMessage>,
}
impl ::std::fmt::Display for ErrorInInput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
::std::write!(f, "ErrorInInput")?;
if let ::std::option::Option::Some(inner_2) = &self.message {
{
::std::write!(f, ": {}", inner_2)?;
}
}
Ok(())
}
}
impl ::std::error::Error for ErrorInInput {}
The text was updated successfully, but these errors were encountered:
When a shape is annotated with
@error
, the code generator implements thestd::error::Error
andstd::fmt::Display
trait for that error structure. However, if this error structure contains a member field that references another structure, the code generator doesn't implementDisplay
for the referenced structure, resulting in compilation errors.For example, the following model generates uncompilable code:
The root cause is that when a shape is annotated with
@error
, the code generator implementsstd::error::Error
for that type:This implementation requires that the type also implements the
Display
trait. While the code generator correctly implementsDisplay
forErrorInInput
, it attempts to forward the display implementation to themessage
field. However, sinceErrorMessage
structure doesn't have aDisplay
implementation, compilation fails.Generated Code
The text was updated successfully, but these errors were encountered: