-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use trybuild for testing expected proc macro errors (#205)
- Loading branch information
Showing
60 changed files
with
984 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
|
||
#[test] | ||
fn ui() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/ui/*.rs"); | ||
} |
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,23 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, default_value = true)] | ||
b: bool, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/bool_default_value.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: default_value is meaningless for bool |
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,23 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, required = true)] | ||
b: bool, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/bool_required.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: required is meaningless for bool |
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,32 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt)] | ||
struct DaemonOpts { | ||
#[structopt(short)] | ||
user: String, | ||
#[structopt(short)] | ||
group: String, | ||
} | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
/// Opts. | ||
#[structopt(flatten)] | ||
opts: DaemonOpts, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/flatten_and_doc.rs:21:10 | ||
| | ||
21 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: methods and doc comments are not allowed for flattened entry |
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 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt)] | ||
struct DaemonOpts { | ||
#[structopt(short)] | ||
user: String, | ||
#[structopt(short)] | ||
group: String, | ||
} | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, flatten)] | ||
opts: DaemonOpts, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/flatten_and_methods.rs:21:10 | ||
| | ||
21 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: methods and doc comments are not allowed for flattened entry |
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 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt)] | ||
struct DaemonOpts { | ||
#[structopt(short)] | ||
user: String, | ||
#[structopt(short)] | ||
group: String, | ||
} | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(flatten, parse(from_occurrences))] | ||
opts: DaemonOpts, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/flatten_and_parse.rs:21:10 | ||
| | ||
21 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: parse attribute is not allowed for flattened entry |
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,24 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(test(1, 2))] | ||
debug: bool, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} | ||
|
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/literal_list_element.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: unsupported option: test ( 1 , 2 ) |
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,23 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, non_existing_attribute = 1)] | ||
debug: bool, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error[E0599]: no method named `non_existing_attribute` found for type `structopt::clap::Arg<'_, '_>` in the current scope | ||
--> $DIR/non_existent_attr.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
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,24 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, aliases = &["debug", "dbg"])] | ||
debug: bool, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} | ||
|
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/non_literal_attr_value.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: invalid structopt syntax: expected literal: # [ structopt ( short , aliases = & [ "debug" , "dbg" ] ) ] |
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,22 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
n: Option<Option<u32>>, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/opt_opt_nonpositional.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: Option<Option<T>> type is meaningless for positional argument |
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,22 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
n: Option<Vec<u32>>, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/opt_vec_nonpositional.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: Option<Vec<T>> type is meaningless for positional argument |
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,23 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
extern crate structopt; | ||
|
||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug)] | ||
#[structopt(name = "basic")] | ||
struct Opt { | ||
#[structopt(short, default_value = 1)] | ||
n: Option<u32>, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::from_args(); | ||
println!("{:?}", opt); | ||
} |
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,7 @@ | ||
error: proc-macro derive panicked | ||
--> $DIR/option_default_value.rs:13:10 | ||
| | ||
13 | #[derive(StructOpt, Debug)] | ||
| ^^^^^^^^^ | ||
| | ||
= help: message: default_value is meaningless for Option |
Oops, something went wrong.