-
Notifications
You must be signed in to change notification settings - Fork 89
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
44 changed files
with
625 additions
and
1 deletion.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
derive_builder/tests/compile-fail/nightly/rename_setter_struct_level.stderr
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,11 @@ | ||
error: Unknown field: `name` | ||
--> $DIR/rename_setter_struct_level.rs:7:18 | ||
| | ||
7 | #[builder(setter(name = "foo"))] | ||
| ^^^^^^^^^^^^ | ||
|
||
error[E0433]: failed to resolve: use of undeclared type or module `LoremBuilder` | ||
--> $DIR/rename_setter_struct_level.rs:14:13 | ||
| | ||
14 | let x = LoremBuilder::default() | ||
| ^^^^^^^^^^^^ use of undeclared type or module `LoremBuilder` |
30 changes: 30 additions & 0 deletions
30
derive_builder/tests/compile-fail/since-1.40.0/private_build_fn.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,30 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
mod container { | ||
/// `LoremBuilder` should be accessible outside the module, but its | ||
/// build method should not be. | ||
#[derive(Debug, Default, Builder)] | ||
#[builder(default, public, build_fn(private))] | ||
pub struct Lorem { | ||
foo: usize, | ||
bar: String, | ||
} | ||
|
||
impl LoremBuilder { | ||
/// Create a `Lorem` | ||
pub fn my_build(&self) -> Lorem { | ||
self.build().expect("All good") | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
use container::{Lorem, LoremBuilder}; | ||
|
||
let lorem1 = LoremBuilder::default().my_build(); | ||
|
||
let lorem2 = LoremBuilder::default().build().unwrap(); | ||
|
||
println!("{:?} vs {:?}", lorem1, lorem2); | ||
} |
13 changes: 13 additions & 0 deletions
13
derive_builder/tests/compile-fail/since-1.40.0/private_build_fn.stderr
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,13 @@ | ||
warning: unused import: `Lorem` | ||
--> $DIR/private_build_fn.rs:23:21 | ||
| | ||
23 | use container::{Lorem, LoremBuilder}; | ||
| ^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default | ||
|
||
error[E0624]: method `build` is private | ||
--> $DIR/private_build_fn.rs:27:42 | ||
| | ||
27 | let lorem2 = LoremBuilder::default().build().unwrap(); | ||
| ^^^^^ |
23 changes: 23 additions & 0 deletions
23
derive_builder/tests/compile-fail/since-1.40.0/private_builder.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 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
pub mod foo { | ||
/// The builder struct's declaration of privacy should override the field's | ||
/// attempt to be public later on. | ||
#[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
#[builder(private, setter(into))] | ||
pub struct Lorem { | ||
pub private: String, | ||
#[builder(public)] | ||
pub public: String, | ||
} | ||
} | ||
|
||
fn main() { | ||
let x = foo::LoremBuilder::default() | ||
.public("Hello") | ||
.build() | ||
.unwrap(); | ||
|
||
assert_eq!(x.public, "Hello".to_string()); | ||
} |
11 changes: 11 additions & 0 deletions
11
derive_builder/tests/compile-fail/since-1.40.0/private_builder.stderr
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,11 @@ | ||
error[E0603]: struct `LoremBuilder` is private | ||
--> $DIR/private_builder.rs:17:18 | ||
| | ||
17 | let x = foo::LoremBuilder::default() | ||
| ^^^^^^^^^^^^ | ||
|
||
error[E0624]: method `build` is private | ||
--> $DIR/private_builder.rs:19:10 | ||
| | ||
19 | .build() | ||
| ^^^^^ |
26 changes: 26 additions & 0 deletions
26
derive_builder/tests/compile-fail/since-1.40.0/private_fields.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,26 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
/// This builder is in an inner module to make sure private fields aren't accessible | ||
/// from the `main` function. | ||
mod inner { | ||
/// The `LoremBuilder` struct will have private fields for `ipsum` and `dolor`, and | ||
/// a public `sit` field. | ||
#[derive(Debug, Builder)] | ||
#[builder(field(private), setter(into))] | ||
pub struct Lorem { | ||
ipsum: String, | ||
dolor: u16, | ||
#[builder(field(public))] | ||
sit: bool, | ||
} | ||
} | ||
|
||
fn main() { | ||
use inner::LoremBuilder; | ||
|
||
let mut lorem = LoremBuilder::default(); | ||
lorem.dolor(15u16); | ||
lorem.sit = Some(true); // <-- public | ||
lorem.dolor = Some(0); // <-- private | ||
} |
5 changes: 5 additions & 0 deletions
5
derive_builder/tests/compile-fail/since-1.40.0/private_fields.stderr
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,5 @@ | ||
error[E0616]: field `dolor` of struct `inner::LoremBuilder` is private | ||
--> $DIR/private_fields.rs:25:5 | ||
| | ||
25 | lorem.dolor = Some(0); // <-- private | ||
| ^^^^^^^^^^^ |
25 changes: 25 additions & 0 deletions
25
derive_builder/tests/compile-fail/since-1.40.0/rename_setter_struct_level.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,25 @@ | ||
#[macro_use] | ||
extern crate pretty_assertions; | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
#[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
#[builder(setter(name = "foo"))] | ||
struct Lorem { | ||
ipsum: &'static str, | ||
pub dolor: &'static str, | ||
} | ||
|
||
fn main() { | ||
let x = LoremBuilder::default() | ||
.ipsum("ipsum") | ||
.foo("dolor") | ||
.build() | ||
.unwrap(); | ||
|
||
assert_eq!(x, | ||
Lorem { | ||
ipsum: "ipsum", | ||
dolor: "dolor", | ||
}); | ||
} |
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
derive_builder/tests/compile-fail/since-1.42.0/private_build_fn.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,30 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
mod container { | ||
/// `LoremBuilder` should be accessible outside the module, but its | ||
/// build method should not be. | ||
#[derive(Debug, Default, Builder)] | ||
#[builder(default, public, build_fn(private))] | ||
pub struct Lorem { | ||
foo: usize, | ||
bar: String, | ||
} | ||
|
||
impl LoremBuilder { | ||
/// Create a `Lorem` | ||
pub fn my_build(&self) -> Lorem { | ||
self.build().expect("All good") | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
use container::{Lorem, LoremBuilder}; | ||
|
||
let lorem1 = LoremBuilder::default().my_build(); | ||
|
||
let lorem2 = LoremBuilder::default().build().unwrap(); | ||
|
||
println!("{:?} vs {:?}", lorem1, lorem2); | ||
} |
13 changes: 13 additions & 0 deletions
13
derive_builder/tests/compile-fail/since-1.42.0/private_build_fn.stderr
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,13 @@ | ||
warning: unused import: `Lorem` | ||
--> $DIR/private_build_fn.rs:23:21 | ||
| | ||
23 | use container::{Lorem, LoremBuilder}; | ||
| ^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default | ||
|
||
error[E0624]: method `build` is private | ||
--> $DIR/private_build_fn.rs:27:42 | ||
| | ||
27 | let lorem2 = LoremBuilder::default().build().unwrap(); | ||
| ^^^^^ |
23 changes: 23 additions & 0 deletions
23
derive_builder/tests/compile-fail/since-1.42.0/private_builder.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 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
pub mod foo { | ||
/// The builder struct's declaration of privacy should override the field's | ||
/// attempt to be public later on. | ||
#[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
#[builder(private, setter(into))] | ||
pub struct Lorem { | ||
pub private: String, | ||
#[builder(public)] | ||
pub public: String, | ||
} | ||
} | ||
|
||
fn main() { | ||
let x = foo::LoremBuilder::default() | ||
.public("Hello") | ||
.build() | ||
.unwrap(); | ||
|
||
assert_eq!(x.public, "Hello".to_string()); | ||
} |
17 changes: 17 additions & 0 deletions
17
derive_builder/tests/compile-fail/since-1.42.0/private_builder.stderr
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,17 @@ | ||
error[E0603]: struct `LoremBuilder` is private | ||
--> $DIR/private_builder.rs:17:18 | ||
| | ||
17 | let x = foo::LoremBuilder::default() | ||
| ^^^^^^^^^^^^ this struct is private | ||
| | ||
note: the struct `LoremBuilder` is defined here | ||
--> $DIR/private_builder.rs:7:41 | ||
| | ||
7 | #[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
| ^^^^^^^ | ||
|
||
error[E0624]: method `build` is private | ||
--> $DIR/private_builder.rs:19:10 | ||
| | ||
19 | .build() | ||
| ^^^^^ |
26 changes: 26 additions & 0 deletions
26
derive_builder/tests/compile-fail/since-1.42.0/private_fields.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,26 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
/// This builder is in an inner module to make sure private fields aren't accessible | ||
/// from the `main` function. | ||
mod inner { | ||
/// The `LoremBuilder` struct will have private fields for `ipsum` and `dolor`, and | ||
/// a public `sit` field. | ||
#[derive(Debug, Builder)] | ||
#[builder(field(private), setter(into))] | ||
pub struct Lorem { | ||
ipsum: String, | ||
dolor: u16, | ||
#[builder(field(public))] | ||
sit: bool, | ||
} | ||
} | ||
|
||
fn main() { | ||
use inner::LoremBuilder; | ||
|
||
let mut lorem = LoremBuilder::default(); | ||
lorem.dolor(15u16); | ||
lorem.sit = Some(true); // <-- public | ||
lorem.dolor = Some(0); // <-- private | ||
} |
5 changes: 5 additions & 0 deletions
5
derive_builder/tests/compile-fail/since-1.42.0/private_fields.stderr
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,5 @@ | ||
error[E0616]: field `dolor` of struct `inner::LoremBuilder` is private | ||
--> $DIR/private_fields.rs:25:5 | ||
| | ||
25 | lorem.dolor = Some(0); // <-- private | ||
| ^^^^^^^^^^^ |
25 changes: 25 additions & 0 deletions
25
derive_builder/tests/compile-fail/since-1.42.0/rename_setter_struct_level.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,25 @@ | ||
#[macro_use] | ||
extern crate pretty_assertions; | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
#[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
#[builder(setter(name = "foo"))] | ||
struct Lorem { | ||
ipsum: &'static str, | ||
pub dolor: &'static str, | ||
} | ||
|
||
fn main() { | ||
let x = LoremBuilder::default() | ||
.ipsum("ipsum") | ||
.foo("dolor") | ||
.build() | ||
.unwrap(); | ||
|
||
assert_eq!(x, | ||
Lorem { | ||
ipsum: "ipsum", | ||
dolor: "dolor", | ||
}); | ||
} |
11 changes: 11 additions & 0 deletions
11
derive_builder/tests/compile-fail/since-1.42.0/rename_setter_struct_level.stderr
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,11 @@ | ||
error: Unknown field: `name` | ||
--> $DIR/rename_setter_struct_level.rs:7:18 | ||
| | ||
7 | #[builder(setter(name = "foo"))] | ||
| ^^^^ | ||
|
||
error[E0433]: failed to resolve: use of undeclared type or module `LoremBuilder` | ||
--> $DIR/rename_setter_struct_level.rs:14:13 | ||
| | ||
14 | let x = LoremBuilder::default() | ||
| ^^^^^^^^^^^^ use of undeclared type or module `LoremBuilder` |
30 changes: 30 additions & 0 deletions
30
derive_builder/tests/compile-fail/since-1.43.0/private_build_fn.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,30 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
mod container { | ||
/// `LoremBuilder` should be accessible outside the module, but its | ||
/// build method should not be. | ||
#[derive(Debug, Default, Builder)] | ||
#[builder(default, public, build_fn(private))] | ||
pub struct Lorem { | ||
foo: usize, | ||
bar: String, | ||
} | ||
|
||
impl LoremBuilder { | ||
/// Create a `Lorem` | ||
pub fn my_build(&self) -> Lorem { | ||
self.build().expect("All good") | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
use container::{Lorem, LoremBuilder}; | ||
|
||
let lorem1 = LoremBuilder::default().my_build(); | ||
|
||
let lorem2 = LoremBuilder::default().build().unwrap(); | ||
|
||
println!("{:?} vs {:?}", lorem1, lorem2); | ||
} |
13 changes: 13 additions & 0 deletions
13
derive_builder/tests/compile-fail/since-1.43.0/private_build_fn.stderr
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,13 @@ | ||
warning: unused import: `Lorem` | ||
--> $DIR/private_build_fn.rs:23:21 | ||
| | ||
23 | use container::{Lorem, LoremBuilder}; | ||
| ^^^^^ | ||
| | ||
= note: `#[warn(unused_imports)]` on by default | ||
|
||
error[E0624]: method `build` is private | ||
--> $DIR/private_build_fn.rs:27:42 | ||
| | ||
27 | let lorem2 = LoremBuilder::default().build().unwrap(); | ||
| ^^^^^ |
23 changes: 23 additions & 0 deletions
23
derive_builder/tests/compile-fail/since-1.43.0/private_builder.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 @@ | ||
#[macro_use] | ||
extern crate derive_builder; | ||
|
||
pub mod foo { | ||
/// The builder struct's declaration of privacy should override the field's | ||
/// attempt to be public later on. | ||
#[derive(Debug, PartialEq, Default, Builder, Clone)] | ||
#[builder(private, setter(into))] | ||
pub struct Lorem { | ||
pub private: String, | ||
#[builder(public)] | ||
pub public: String, | ||
} | ||
} | ||
|
||
fn main() { | ||
let x = foo::LoremBuilder::default() | ||
.public("Hello") | ||
.build() | ||
.unwrap(); | ||
|
||
assert_eq!(x.public, "Hello".to_string()); | ||
} |
Oops, something went wrong.