diff --git a/CHANGELOG.md b/CHANGELOG.md index c202f64b..0286aca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.2.7 (unreleased) + +* Fail compilation when using `default_value` and `required` with `Option` ([#88](https://github.com/TeXitoi/structopt/pull/88)) by [@Kerollmops](https://github.com/Kerollmops) + # v0.2.6 (2018-03-31) * Fail compilation when using `default_value` or `required` with `bool` ([#80](https://github.com/TeXitoi/structopt/issues/80)) by [@TeXitoi](https://github.com/TeXitoi) diff --git a/structopt-derive/src/attrs.rs b/structopt-derive/src/attrs.rs index 849b2a08..39883faa 100644 --- a/structopt-derive/src/attrs.rs +++ b/structopt-derive/src/attrs.rs @@ -261,13 +261,24 @@ impl Attrs { } } - if res.ty == Ty::Bool { - if res.has_method("default_value") { - panic!("default_value is meaningless for bool") - } - if res.has_method("required") { - panic!("required is meaningless for bool") - } + match res.ty { + Ty::Bool => { + if res.has_method("default_value") { + panic!("default_value is meaningless for bool") + } + if res.has_method("required") { + panic!("required is meaningless for bool") + } + }, + Ty::Option => { + if res.has_method("default_value") { + panic!("default_value is meaningless for Option") + } + if res.has_method("required") { + panic!("required is meaningless for Option") + } + }, + _ => (), } res