]> git.proxmox.com Git - rustc.git/blame - vendor/structopt/tests/deny-warnings.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / vendor / structopt / tests / deny-warnings.rs
CommitLineData
f20569fa
XL
1// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9#![deny(warnings)]
10
11use structopt::StructOpt;
12
13fn try_str(s: &str) -> Result<String, std::convert::Infallible> {
14 Ok(s.into())
15}
16
17#[test]
18fn warning_never_struct() {
19 #[derive(Debug, PartialEq, StructOpt)]
20 struct Opt {
21 #[structopt(parse(try_from_str = try_str))]
22 s: String,
23 }
24 assert_eq!(
25 Opt {
26 s: "foo".to_string()
27 },
28 Opt::from_iter(&["test", "foo"])
29 );
30}
31
32#[test]
33fn warning_never_enum() {
34 #[derive(Debug, PartialEq, StructOpt)]
35 enum Opt {
36 Foo {
37 #[structopt(parse(try_from_str = try_str))]
38 s: String,
39 },
40 }
41 assert_eq!(
42 Opt::Foo {
43 s: "foo".to_string()
44 },
45 Opt::from_iter(&["test", "foo", "foo"])
46 );
47}