Skip to content

Commit 1368591

Browse files
committed
Add regression test for issue 405
error[E0599]: the method `as_display` exists for reference `&<T as FromStr>::Err`, but its trait bounds were not satisfied --> tests/test_generics.rs:178:13 | 178 | #[error("couldn't parse entry: {0}")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&<T as FromStr>::Err` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `<T as FromStr>::Err: std::fmt::Display` which is required by `&<T as FromStr>::Err: AsDisplay<'_>`
1 parent c535cec commit 1368591

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_generics.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(clippy::needless_late_init, clippy::uninlined_format_args)]
22

33
use core::fmt::{self, Debug, Display};
4+
use core::str::FromStr;
45
use thiserror::Error;
56

67
pub struct NoFormat;
@@ -160,6 +161,24 @@ pub struct StructFromGeneric<E> {
160161
#[error(transparent)]
161162
pub struct StructTransparentGeneric<E>(pub E);
162163

164+
// Should expand to:
165+
//
166+
// impl<T: FromStr> Display for AssociatedTypeError<T>
167+
// where
168+
// T::Err: Display;
169+
//
170+
// impl<T: FromStr> Error for AssociatedTypeError<T>
171+
// where
172+
// Self: Debug + Display;
173+
//
174+
#[derive(Error, Debug)]
175+
pub enum AssociatedTypeError<T: FromStr> {
176+
#[error("couldn't parse matrix")]
177+
Other,
178+
#[error("couldn't parse entry: {0}")]
179+
EntryParseError(T::Err),
180+
}
181+
163182
// Regression test for https://github.com/dtolnay/thiserror/issues/345
164183
#[test]
165184
fn test_no_bound_on_named_fmt() {

0 commit comments

Comments
 (0)