Skip to content

Commit

Permalink
Update to derive_more v1.0 (#127)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #127

Reviewed By: zertosh, dtolnay

Differential Revision: D61429211

Pulled By: ndmitchell

fbshipit-source-id: 90fef0f102791d83a3c46432d6260e8882379abd
  • Loading branch information
jayvdb authored and facebook-github-bot committed Aug 26, 2024
1 parent 68ce5bc commit 7d5bc11
Show file tree
Hide file tree
Showing 43 changed files with 78 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ starlark_syntax = { version = "0.9", path = "starlark_syntax" }
anyhow = "1.0.65"
ctor = "0.1.26"
derivative = "2.2"
derive_more = "0.99.3"
derive_more = { version = "1.0.0", features = ["full"] }
either = "1.8"
equivalent = "1.0.0"
indenter = "0.3.3"
Expand Down
2 changes: 1 addition & 1 deletion starlark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ anyhow = "1.0.65"
bumpalo = "3.8"
debugserver-types = "0.5.0"
derivative = "2.2"
derive_more = "0.99"
derive_more.workspace = true
display_container = { workspace = true }
dupe = { workspace = true }
either = "1.8"
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/environment/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ mod tests {
#[test]
fn test_set_attribute() {
#[derive(Debug, Display, ProvidesStaticType, NoSerialize, Allocative)]
#[display(fmt = "Magic")]
#[display("Magic")]
struct Magic;
starlark_simple_value!(Magic);

Expand Down
2 changes: 1 addition & 1 deletion starlark/src/eval/bc/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::eval::bc::repr::BC_INSTR_ALIGN;
#[derive(
Eq, PartialEq, Copy, Clone, Dupe, Debug, PartialOrd, Ord, Display, Hash, Default
)]
#[display(fmt = "@{}", _0)]
#[display("@{}", _0)]
pub(crate) struct BcAddr(pub(crate) u32);

impl BcAddr {
Expand Down
6 changes: 3 additions & 3 deletions starlark/src/eval/bc/stack_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use dupe::Dupe;
Hash,
derive_more::Display
)]
#[display(fmt = "&{}", _0)]
#[display("&{}", _0)]
pub(crate) struct BcSlot(pub(crate) u32);

impl BcSlot {
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<const N: usize> BcSlotsN<N> {
}

#[derive(Copy, Clone, Dupe, Debug, derive_more::Display)]
#[display(fmt = "{}..{}", start, end)]
#[display("{}..{}", start, end)]
pub(crate) struct BcSlotRange {
pub(crate) start: BcSlot,
pub(crate) end: BcSlot,
Expand Down Expand Up @@ -129,7 +129,7 @@ impl BcSlotIn {
}

#[derive(Copy, Clone, Dupe, Debug, derive_more::Display)]
#[display(fmt = "{}..{}", start, end)]
#[display("{}..{}", start, end)]
pub(crate) struct BcSlotInRange {
pub(crate) start: BcSlotIn,
pub(crate) end: BcSlotIn,
Expand Down
3 changes: 1 addition & 2 deletions starlark/src/eval/compiler/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use std::cell::UnsafeCell;
use std::collections::HashMap;
use std::fmt;
use std::fmt::Display;
use std::fmt::Write;
use std::ptr;

Expand Down Expand Up @@ -300,7 +299,7 @@ pub(crate) struct CopySlotFromParent {
/// Static info for `def`, `lambda` or module.
#[derive(Derivative, Display)]
#[derivative(Debug)]
#[display(fmt = "DefInfo")]
#[display("DefInfo")]
pub(crate) struct DefInfo {
pub(crate) name: FrozenStringValue,
/// Span of function signature.
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/eval/compiler/def_inline/local_as_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::values::StarlarkValue;
NoSerialize,
Allocative
)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
pub(crate) struct LocalAsValue {
#[allocative(skip)]
pub(crate) local: LocalSlotId,
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/tests/derive/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_derive_attrs() {
NoSerialize,
Allocative
)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
struct Example {
hello: String,
#[starlark(skip)]
Expand All @@ -64,7 +64,7 @@ fn test_derive_attrs() {
NoSerialize,
Allocative
)]
#[display(fmt = "{}", foo)]
#[display("{}", foo)]
struct Nested {
foo: String,
}
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/tests/derive/module/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::values::ValueLike;
NoSerialize,
Allocative
)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
struct Applaud {
value: i32,
}
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/tests/derive/module/type_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::values::StarlarkValue;
NoSerialize,
Allocative
)]
#[display(fmt = "foo")]
#[display("foo")]
struct Foo;

#[starlark_value(type = "Foo")]
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/tests/derive/unpack_value_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::values::Value;
ProvidesStaticType,
Allocative
)]
#[display(fmt = "ValueWithLifetimeParam")]
#[display("ValueWithLifetimeParam")]
struct ValueWithLifetimeParam<'v>(Value<'v>);
#[derive(
Debug,
Expand All @@ -42,7 +42,7 @@ struct ValueWithLifetimeParam<'v>(Value<'v>);
ProvidesStaticType,
Allocative
)]
#[display(fmt = "ValueWithoutParam")]
#[display("ValueWithoutParam")]
struct ValueWithoutParam(String);

#[starlark_value(type = "ValueWithLifetimeParam", StarlarkTypeRepr, UnpackValue)]
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/tests/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _do_not_export():
Allocative,
NoSerialize
)]
#[display(fmt = "magic")]
#[display("magic")]
struct Magic;

#[starlark_value(type = "magic")]
Expand Down Expand Up @@ -183,7 +183,7 @@ fn module(builder: &mut GlobalsBuilder) {
}

#[derive(ProvidesStaticType, Debug, Display, Allocative, Serialize)]
#[display(format = "obj")]
#[display("obj")]
struct Obj;

#[starlark_value(type = "obj")]
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/tests/docs/rustdocs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use crate::values::ValueOfUnchecked;
NoSerialize,
ProvidesStaticType
)]
#[display(fmt = "input")]
#[display("input")]
struct InputTypeRepr;
#[derive(
Debug,
Expand All @@ -56,7 +56,7 @@ struct InputTypeRepr;
NoSerialize,
ProvidesStaticType
)]
#[display(fmt = "output")]
#[display("output")]
struct OutputTypeRepr;

#[starlark_value(type = "input")]
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/tests/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn test_load_symbols_extra() -> crate::Result<()> {
NoSerialize,
Allocative
)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
struct Extra<'v>(Arc<Mutex<SmallMap<String, Value<'v>>>>);

#[starlark_value(type = "Extra")]
Expand Down Expand Up @@ -224,7 +224,7 @@ fn test_load_symbols_extra() -> crate::Result<()> {
#[test]
fn test_repr_str() {
#[derive(ProvidesStaticType, Debug, Display)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
struct Foo(Option<usize>);

#[starlark_module]
Expand Down
5 changes: 2 additions & 3 deletions starlark/src/tests/opt/if_rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use std::cell::Cell;
use std::fmt;
use std::fmt::Display;

use derive_more::Display;
use dupe::Dupe;
Expand Down Expand Up @@ -76,9 +75,9 @@ fn bool_fns(globals: &mut GlobalsBuilder) {

#[derive(Display, Debug, Copy, Clone, Dupe)]
enum TestBinOp {
#[display(fmt = "and")]
#[display("and")]
And,
#[display(fmt = "or")]
#[display("or")]
Or,
}

Expand Down
6 changes: 3 additions & 3 deletions starlark/src/tests/uncategorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ fn test_radd() {
// We want select append to always produce a select, much like the
// Bazel/Buck `select` function.
#[derive(Debug, Display, Clone, ProvidesStaticType, NoSerialize, Allocative)]
#[display(fmt = "${:?}", _0)]
#[display("${:?}", _0)]
struct Select(Vec<i32>);
starlark_simple_value!(Select);

Expand Down Expand Up @@ -757,7 +757,7 @@ fn test_label_assign() {
// No builtin Starlark types support it, so we have to define a custom type (wapping a dictionary)

#[derive(Debug, Trace, ProvidesStaticType, Display, NoSerialize, Allocative)]
#[display(fmt = "{:?}", self)]
#[display("{:?}", self)]
struct Wrapper<'v>(RefCell<SmallMap<String, Value<'v>>>);

#[starlark_value(type = "wrapper")]
Expand All @@ -773,7 +773,7 @@ fn test_label_assign() {
}

#[derive(Debug, ProvidesStaticType, Display, NoSerialize, Allocative)]
#[display(fmt = "FrozenWrapper")]
#[display("FrozenWrapper")]
struct FrozenWrapper;

#[starlark_value(type = "wrapper")]
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::values::ValueLike;
ProvidesStaticType,
NoSerialize
)]
#[display(fmt = "TestComplexValue<{}>", "_0")]
#[display("TestComplexValue<{}>", _0)]
pub(crate) struct TestComplexValue<V: ValueLifetimeless>(pub(crate) V);

#[starlark_value(type = "TestComplexValue")]
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/typing/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait TyCustomFunctionImpl:
Debug,
derive_more::Display
)]
#[display(fmt = "\"function\"")]
#[display("\"function\"")]
pub struct TyCustomFunction<F: TyCustomFunctionImpl>(pub F);

impl<F: TyCustomFunctionImpl> TyCustomImpl for TyCustomFunction<F> {
Expand Down
32 changes: 16 additions & 16 deletions starlark/src/typing/oracle/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,57 @@ use dupe::Dupe;
#[derive(Copy, Clone, Dupe, Eq, PartialEq, derive_more::Display, Debug)]
pub enum TypingUnOp {
/// `+`.
#[display(fmt = "+")]
#[display("+")]
Plus,
/// `+`.
#[display(fmt = "-")]
#[display("-")]
Minus,
/// `~`.
#[display(fmt = "~")]
#[display("~")]
BitNot,
}

/// Binary operator for typechecker.
#[derive(Copy, Clone, Dupe, Eq, PartialEq, derive_more::Display, Debug)]
pub enum TypingBinOp {
/// `+`.
#[display(fmt = "+")]
#[display("+")]
Add,
/// `-`.
#[display(fmt = "-")]
#[display("-")]
Sub,
/// `/`.
#[display(fmt = "/")]
#[display("/")]
Div,
/// `//`.
#[display(fmt = "/")]
#[display("/")]
FloorDiv,
/// `*`.
#[display(fmt = "*")]
#[display("*")]
Mul,
/// `%`.
#[display(fmt = "%")]
#[display("%")]
Percent,
/// `y in x`.
#[display(fmt = "in")]
#[display("in")]
In,
/// `|`.
#[display(fmt = "|")]
#[display("|")]
BitOr,
/// `^`.
#[display(fmt = "^")]
#[display("^")]
BitXor,
/// `&`.
#[display(fmt = "&")]
#[display("&")]
BitAnd,
/// `<`.
#[display(fmt = "<")]
#[display("<")]
Less,
/// `<<`.
#[display(fmt = "<<")]
#[display("<<")]
LeftShift,
/// `>>`.
#[display(fmt = ">>")]
#[display(">>")]
RightShift,
}

Expand Down
6 changes: 3 additions & 3 deletions starlark/src/typing/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct TyUserParams {

/// Type description for arbitrary type.
#[derive(Allocative, Debug, derive_more::Display)]
#[display(fmt = "{}", name)]
#[display("{}", name)]
pub struct TyUser {
name: String,
/// Base type for this custom type, e.g. generic record for record with known fields.
Expand Down Expand Up @@ -318,7 +318,7 @@ mod tests {
Allocative,
NoSerialize
)]
#[display(fmt = "plant")]
#[display("plant")]
enum AbstractPlant {}

#[starlark_value(type = "plant")]
Expand All @@ -335,7 +335,7 @@ mod tests {
Allocative,
NoSerialize
)]
#[display(fmt = "fruit_callable")]
#[display("fruit_callable")]
struct FruitCallable {
name: String,
ty_fruit_callable: Ty,
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/values/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod tests {
NoSerialize,
Allocative
)]
#[display(fmt = "SomeType")]
#[display("SomeType")]
struct MyValue {
payload: u32,
}
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/values/layout/alloc_static_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {
NoSerialize,
Allocative
)]
#[display(fmt = "MySimpleValue")]
#[display("MySimpleValue")]
struct MySimpleValue(u32);

#[starlark_value(type = "MySimpleValue")]
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/values/layout/avalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ where
}

#[derive(Debug, Display, ProvidesStaticType, Allocative)]
#[display(fmt = "BlackHole")]
#[display("BlackHole")]
pub(crate) struct BlackHole(pub(crate) ValueAllocSize);

#[cfg(test)]
Expand Down
Loading

0 comments on commit 7d5bc11

Please sign in to comment.