Skip to content

Commit

Permalink
Added regression tests for ambiguous associated item error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bluurryy committed Sep 5, 2024
1 parent d838728 commit f505869
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/from_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ struct Point1D {
x: i32,
}

/// Making sure that `FromStr` does not trigger an ambiguous associated item error for `Err`.
#[derive(FromStr)]
enum EnumWithErr {
Err,
}

#[derive(Debug, FromStr, PartialEq, Eq)]
enum EnumNoFields {
Foo,
Expand Down Expand Up @@ -44,4 +50,4 @@ fn enum_test_case_sensitive() {
"baz".parse::<EnumNoFields>().unwrap_err().to_string(),
"Invalid `EnumNoFields` string representation",
);
}
}
8 changes: 8 additions & 0 deletions tests/try_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

use derive_more::TryFrom;

/// Making sure that `TryFrom` does not trigger an ambiguous associated item error for `Error`.
#[derive(TryFrom)]
#[try_from(repr)]
#[repr(u8)]
enum EnumWithError {
Error,
}

#[test]
fn test_with_repr() {
#[derive(TryFrom, Clone, Copy, Debug, Eq, PartialEq)]
Expand Down
10 changes: 10 additions & 0 deletions tests/try_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ enum Foo<'lt: 'static, T: Clone, const X: usize> {
X(Wrapper<'lt, X, T>),
}

enum EnumWithError {
Error,
}

/// Making sure that `TryInto` does not trigger an ambiguous associated item error for `Error`.
#[derive(TryInto)]
enum EnumIntoEnumWithError {
Foo(EnumWithError),
}

#[test]
fn test_try_into() {
let mut i = MixedInts::SmallInt(42);
Expand Down

0 comments on commit f505869

Please sign in to comment.