Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
@@ -0,0 +1,27 @@
use derive_builder::Builder;
#[derive(Builder)]
#[builder(build_fn(error(validation_error = false, path = "hello")))]
struct Fee {
hi: u32,
}
#[derive(Builder)]
#[builder(build_fn(error(validation_error = false), validate = "hello"))]
struct Foo {
hi: u32,
}
#[derive(Builder)]
#[builder(build_fn(error(path = "hello")))]
struct Fii {
hi: u32,
}
#[derive(Builder)]
#[builder(build_fn(error()))]
struct Fum {
hi: u32,
}
fn main() {}
@@ -0,0 +1,31 @@
error: Unknown field: `path`
--> tests/compile-fail/build_fn_error.rs:4:52
|
4 | #[builder(build_fn(error(validation_error = false, path = "hello")))]
| ^^^^
error: Cannot set `error(validation_error = false)` when using `validate`
--> tests/compile-fail/build_fn_error.rs:10:45
|
10 | #[builder(build_fn(error(validation_error = false), validate = "hello"))]
| ^^^^^
error: Unknown field: `path`
--> tests/compile-fail/build_fn_error.rs:16:26
|
16 | #[builder(build_fn(error(path = "hello")))]
| ^^^^
error: Missing field `validation_error` at build_fn/error
--> tests/compile-fail/build_fn_error.rs:15:10
|
15 | #[derive(Builder)]
| ^^^^^^^
|
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info)
error: Missing field `validation_error`
--> tests/compile-fail/build_fn_error.rs:22:20
|
22 | #[builder(build_fn(error()))]
| ^^^^^
@@ -0,0 +1,12 @@
#[macro_use]
extern crate derive_builder;
#[derive(Debug, PartialEq, Default, Builder, Clone)]
pub struct Lorem {
ok: String,
#[builder_field_attr(no_such_attribute)]
broken: String,
}
fn main() {}
@@ -0,0 +1,5 @@
error: cannot find attribute `no_such_attribute` in this scope
--> tests/compile-fail/builder_field_attr.rs:8:26
|
8 | #[builder_field_attr(no_such_attribute)]
| ^^^^^^^^^^^^^^^^^
@@ -0,0 +1,22 @@
#[macro_use]
extern crate derive_builder;
#[derive(Debug, PartialEq, Default, Builder, Clone)]
pub struct Lorem {
// `default` is incompatible with `field.build`
#[builder(
default = "1",
field(build = "self.ipsum.map(|v| v + 42).unwrap_or(100)")
)]
ipsum: usize,
// `default` is incompatible with `field.ty`, even without `field.build`
#[builder(default = "2", field(ty = "usize"))]
sit: usize,
// Both errors can occur on the same field
#[builder(default = "3", field(ty = "usize", build = "self.ipsum + 42"))]
amet: usize,
}
fn main() {}
@@ -0,0 +1,23 @@
error: #[builder(default)] and #[builder(field(build="..."))] cannot be used together
--> tests/compile-fail/builder_field_custom.rs:8:19
|
8 | default = "1",
| ^^^
error: #[builder(default)] and #[builder(field(ty="..."))] cannot be used together
--> tests/compile-fail/builder_field_custom.rs:14:25
|
14 | #[builder(default = "2", field(ty = "usize"))]
| ^^^
error: #[builder(default)] and #[builder(field(build="..."))] cannot be used together
--> tests/compile-fail/builder_field_custom.rs:18:25
|
18 | #[builder(default = "3", field(ty = "usize", build = "self.ipsum + 42"))]
| ^^^
error: #[builder(default)] and #[builder(field(ty="..."))] cannot be used together
--> tests/compile-fail/builder_field_custom.rs:18:25
|
18 | #[builder(default = "3", field(ty = "usize", build = "self.ipsum + 42"))]
| ^^^
@@ -0,0 +1,16 @@
#![deny(unused_must_use)]
#[macro_use]
extern crate derive_builder;
#[derive(Debug, PartialEq, Default, Builder, Clone)]
pub struct Lorem {
ok: String,
#[builder_setter_attr(must_use)]
broken: usize,
}
fn main() {
LoremBuilder::default().broken(42);
}
@@ -0,0 +1,11 @@
error: unused return value of `LoremBuilder::broken` that must be used
--> tests/compile-fail/builder_setter_attr.rs:15:5
|
15 | LoremBuilder::default().broken(42);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> tests/compile-fail/builder_setter_attr.rs:1:9
|
1 | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
@@ -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() {}
@@ -0,0 +1,122 @@
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 one of these items
|
5 | use core::option::Option;
|
5 | use derive_builder::export::core::option::Option;
|
5 | use serde::__private::Option;
|
5 | use std::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 one of these items
|
5 | use core::clone::Clone;
|
5 | use derive_builder::export::core::clone::Clone;
|
5 | use serde::__private::Clone;
|
5 | use std::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 core::fmt::Result;
|
5 | use core::result::Result;
|
5 | use derive_builder::export::core::fmt::Result;
|
5 | use derive_builder::export::core::io::Result;
|
and 9 other candidates
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 one of these items
|
5 | use core::convert::Into;
|
5 | use derive_builder::export::core::convert::Into;
|
5 | use serde::__private::Into;
|
5 | use std::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 one of these items
|
5 | use core::default::Default;
|
5 | use derive_builder::export::core::default::Default;
|
5 | use serde::__private::Default;
|
5 | use std::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;
|
@@ -0,0 +1,44 @@
#[macro_use]
extern crate derive_builder;
use derive_builder::UninitializedFieldError;
trait Popular {
fn is_popular(&self) -> bool;
}
impl<'a> Popular for &'a str {
fn is_popular(&self) -> bool {
!self.starts_with('b')
}
}
#[derive(Debug, Builder)]
#[builder(build_fn(validate = "check_person", error = "Error<N>"))]
struct Person<N> {
name: N,
age: u16,
}
enum Error<N> {
UninitializedField(&'static str),
UnpopularName(N),
}
impl<N> From<UninitializedFieldError> for Error<N> {
fn from(error: UninitializedFieldError) -> Self {
Self::UninitializedField(error.field_name())
}
}
fn check_person<N: Popular + Clone>(builder: &PersonBuilder<N>) -> Result<(), Error<N>> {
if let Some(name) = &builder.name {
if !name.is_popular() {
return Err(Error::UnpopularName(name.clone()));
}
}
Ok(())
}
fn main() {}
@@ -0,0 +1,15 @@
error[E0277]: the trait bound `N: Popular` is not satisfied
--> tests/compile-fail/custom_error_generic_missing_bound.rs:17:31
|
17 | #[builder(build_fn(validate = "check_person", error = "Error<N>"))]
| ^^^^^^^^^^^^^^ the trait `Popular` is not implemented for `N`
|
note: required by a bound in `check_person`
--> tests/compile-fail/custom_error_generic_missing_bound.rs:34:20
|
34 | fn check_person<N: Popular + Clone>(builder: &PersonBuilder<N>) -> Result<(), Error<N>> {
| ^^^^^^^ required by this bound in `check_person`
help: consider restricting type parameter `N`
|
18 | struct Person<N: Popular> {
| +++++++++
@@ -0,0 +1,37 @@
#[macro_use]
extern crate derive_builder;
fn validate_age(age: usize) -> Result<(), Error> {
if age > 200 {
Err(Error::UnrealisticAge(age))
} else {
Ok(())
}
}
fn check_person(builder: &PersonBuilder) -> Result<(), Error> {
if let Some(age) = builder.age {
validate_age(age)
} else {
Ok(())
}
}
#[derive(Builder)]
#[builder(build_fn(validate = "check_person", error = "Error"))]
struct Person {
name: String,
age: usize,
}
// NOTE: This enum has a variant for the uninitialized field case (called MissingData)
// but has forgotten `impl From<derive_builder::UninitializedFieldError>`, which is a
// compile-blocking mistake.
#[derive(Debug)]
enum Error {
/// A required field is not filled out.
MissingData(&'static str),
UnrealisticAge(usize),
}
fn main() {}
@@ -0,0 +1,7 @@
error[E0277]: the trait bound `Error: From<UninitializedFieldError>` is not satisfied
--> tests/compile-fail/custom_error_no_from.rs:21:55
|
21 | #[builder(build_fn(validate = "check_person", error = "Error"))]
| ^^^^^^^ the trait `From<UninitializedFieldError>` is not implemented for `Error`
|
= note: required because of the requirements on the impl of `Into<Error>` for `UninitializedFieldError`
@@ -0,0 +1,12 @@
#[macro_use]
extern crate derive_builder;
// deny `#[builder(default = "")]`, because we don't want to define a meaning (yet)! :-)
#[allow(dead_code)]
#[derive(Builder)]
struct Lorem {
#[builder(default = "")]
ipsum: String,
}
fn main() {}
@@ -0,0 +1,5 @@
error: Unknown literal value ``
--> $DIR/deny_empty_default.rs:8:25
|
8 | #[builder(default = "")]
| ^^
@@ -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);
}
@@ -0,0 +1,16 @@
warning: unused import: `Lorem`
--> tests/compile-fail/private_build_fn.rs:23:21
|
23 | use container::{Lorem, LoremBuilder};
| ^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0624]: associated function `build` is private
--> tests/compile-fail/private_build_fn.rs:27:42
|
7 | #[derive(Debug, Default, Builder)]
| ------- private associated function defined here
...
27 | let lorem2 = LoremBuilder::default().build().unwrap();
| ^^^^^ private associated function
@@ -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());
}
@@ -0,0 +1,21 @@
error[E0603]: struct `LoremBuilder` is private
--> tests/compile-fail/private_builder.rs:17:18
|
17 | let x = foo::LoremBuilder::default()
| ^^^^^^^^^^^^ private struct
|
note: the struct `LoremBuilder` is defined here
--> tests/compile-fail/private_builder.rs:7:41
|
7 | #[derive(Debug, PartialEq, Default, Builder, Clone)]
| ^^^^^^^
= note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0624]: associated function `build` is private
--> tests/compile-fail/private_builder.rs:19:10
|
7 | #[derive(Debug, PartialEq, Default, Builder, Clone)]
| ------- private associated function defined here
...
19 | .build()
| ^^^^^ private associated function
@@ -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
}
@@ -0,0 +1,5 @@
error[E0616]: field `dolor` of struct `LoremBuilder` is private
--> tests/compile-fail/private_fields.rs:25:11
|
25 | lorem.dolor = Some(0); // <-- private
| ^^^^^ private field
@@ -0,0 +1,25 @@
#[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",
}
);
}
@@ -0,0 +1,11 @@
error: Unknown field: `name`
--> tests/compile-fail/rename_setter_struct_level.rs:5:18
|
5 | #[builder(setter(name = "foo"))]
| ^^^^
error[E0433]: failed to resolve: use of undeclared type `LoremBuilder`
--> tests/compile-fail/rename_setter_struct_level.rs:12:13
|
12 | let x = LoremBuilder::default()
| ^^^^^^^^^^^^ use of undeclared type `LoremBuilder`
@@ -0,0 +1,21 @@
#[macro_use]
extern crate derive_builder;
#[derive(Builder)]
#[builder(public, vis = "pub(crate)")]
pub struct Example {
#[builder(public, private)]
field: String,
}
#[derive(Builder)]
#[builder(public, vis = "pub(crate)", build_fn(private, public))]
pub struct SecondExample {
#[builder(private, vis = "pub")]
a_field: String,
}
fn main() {
ExampleBuilder::default().build();
SecondExampleBuilder::default().build();
}
@@ -0,0 +1,29 @@
error: `public` and `vis` cannot be used together
--> tests/compile-fail/vis_conflict.rs:5:25
|
5 | #[builder(public, vis = "pub(crate)")]
| ^^^^^^^^^^^^
error: `public` and `private` cannot be used together
--> tests/compile-fail/vis_conflict.rs:12:48
|
12 | #[builder(public, vis = "pub(crate)", build_fn(private, public))]
| ^^^^^^^
error: `public` and `vis` cannot be used together
--> tests/compile-fail/vis_conflict.rs:12:25
|
12 | #[builder(public, vis = "pub(crate)", build_fn(private, public))]
| ^^^^^^^^^^^^
error[E0433]: failed to resolve: use of undeclared type `ExampleBuilder`
--> tests/compile-fail/vis_conflict.rs:19:5
|
19 | ExampleBuilder::default().build();
| ^^^^^^^^^^^^^^ use of undeclared type `ExampleBuilder`
error[E0433]: failed to resolve: use of undeclared type `SecondExampleBuilder`
--> tests/compile-fail/vis_conflict.rs:20:5
|
20 | SecondExampleBuilder::default().build();
| ^^^^^^^^^^^^^^^^^^^^ use of undeclared type `SecondExampleBuilder`