-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
// This is a stand-in for any bad crate directive | ||
mod empty {} | ||
|
||
#[derive(Builder)] | ||
// It would be nice if the "failed to resolve" errors would identify `"empty"` as the error span, | ||
// but doing so would require rewriting a lot of the code generation to use the crate_root span | ||
// for the full path of the thing being imported, and that doesn't seem worth the code churn. | ||
#[builder(crate = "empty")] | ||
struct BadCrate { | ||
lorem: String, | ||
} | ||
|
||
fn main() {} |
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,97 @@ | ||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ could not find `export` in `empty` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty::export::core::option` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this enum | ||
| | ||
5 | use derive_builder::export::core::option::Option; | ||
| | ||
|
||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty::export::core::clone` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this trait | ||
| | ||
5 | use derive_builder::export::core::clone::Clone; | ||
| | ||
|
||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty::export::core::result` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing one of these items | ||
| | ||
5 | use derive_builder::export::core::fmt::Result; | ||
| | ||
5 | use derive_builder::export::core::io::Result; | ||
| | ||
5 | use derive_builder::export::core::result::Result; | ||
| | ||
5 | use derive_builder::export::core::thread::Result; | ||
| | ||
|
||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty::export::core::convert` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this trait | ||
| | ||
5 | use derive_builder::export::core::convert::Into; | ||
| | ||
|
||
error[E0433]: failed to resolve: could not find `UninitializedFieldError` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this struct | ||
| | ||
5 | use derive_builder::UninitializedFieldError; | ||
| | ||
|
||
error[E0433]: failed to resolve: could not find `export` in `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty::export::core::default` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this trait | ||
| | ||
5 | use derive_builder::export::core::default::Default; | ||
| | ||
|
||
error[E0412]: cannot find type `UninitializedFieldError` in module `empty` | ||
--> tests/compile-fail/crate_root.rs:7:10 | ||
| | ||
7 | #[derive(Builder)] | ||
| ^^^^^^^ not found in `empty` | ||
| | ||
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider importing this struct | ||
| | ||
5 | use derive_builder::UninitializedFieldError; | ||
| |
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 @@ | ||
//! Test that an alias of derive_builder is valid in #[builder(crate = "...")] | ||
//! | ||
//! This test is imperfect, as it still passes without setting `crate = "..."`. | ||
//! This is likely because `derive_builder` is automatically present in 2018 | ||
//! without needing the extern crate line. | ||
//! | ||
//! The test will fail if an incorrect alias is used, so it adds limited value. | ||
|
||
#[macro_use] | ||
extern crate derive_builder as db; | ||
|
||
#[derive(Builder)] | ||
#[builder(crate = "db")] | ||
struct AliasedCrate { | ||
#[builder(setter(into))] | ||
lorem: String, | ||
} | ||
|
||
fn main() { | ||
AliasedCrateBuilder::default() | ||
.lorem("hello") | ||
.build() | ||
.unwrap(); | ||
} |