Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: unqualified result types causing compilation failures with deriv…
…e implementations
- Loading branch information
1 parent
ada95d6
commit 746ff3e
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/// Regression test to ensure that type aliases do not cause compilation failures. | ||
use clap::Parser; | ||
use std::str::FromStr; | ||
|
||
// Result type alias | ||
#[allow(dead_code)] | ||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
// Wrapper to use for Option type alias | ||
struct Wrapper<T>(T); | ||
|
||
impl<T: FromStr> FromStr for Wrapper<T> { | ||
type Err = <T as FromStr>::Err; | ||
|
||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { | ||
T::from_str(s).map(Wrapper) | ||
} | ||
} | ||
|
||
type Option<T> = std::option::Option<Wrapper<T>>; | ||
|
||
#[derive(Parser)] | ||
pub struct Opts { | ||
another_string: Option<String>, | ||
strings: Vec<String>, | ||
} | ||
|
||
#[test] | ||
fn type_alias_regressions() { | ||
Opts::parse(); | ||
} |