Skip to content

Commit 3ae3700

Browse files
committed
fix
1 parent 416245d commit 3ae3700

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎cpp2rust/converter/models/converter_refcount.cpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ bool ConverterRefCount::RecordDerivesClone(const clang::RecordDecl *decl) {
518518
}
519519
PushConversionKind push(*this, ConversionKind::Pointee);
520520
return std::ranges::none_of(decl->fields(), [&](auto *field) {
521-
return IsValueField(ctx_, field) || ToString(field->getType()).contains("Value<");
521+
return IsValueField(ctx_, field) ||
522+
ToString(field->getType()).contains("Value<");
522523
});
523524
}
524525

@@ -553,8 +554,8 @@ void ConverterRefCount::AddCloneTrait(const clang::RecordDecl *decl) {
553554
auto name = GetNamedDeclAsString(field);
554555
auto value = std::format("self.{}.clone()", name);
555556
if (IsValueField(ctx_, field)) {
556-
value = std::format("Rc::new(RefCell::new((*self.{}.borrow()).clone()))",
557-
name);
557+
value = std::format(
558+
"Rc::new(RefCell::new((*self.{}.borrow()).clone()))", name);
558559
}
559560
StrCat(std::format("{}: {},", name, value));
560561
}
@@ -3209,8 +3210,8 @@ ConverterRefCount::DestroyMembers(const clang::CXXRecordDecl *decl) {
32093210
"0..__p.len() {{ {2}::{1}(&__p.offset(__i as isize)); }} }}\n",
32103211
name, kDestructorName, TraitName(elem));
32113212
} else {
3212-
out += std::format("field_ptr!(self, {0}).{1}();\n", name,
3213-
kDestructorName);
3213+
out +=
3214+
std::format("field_ptr!(self, {0}).{1}();\n", name, kDestructorName);
32143215
}
32153216
}
32163217
return out;

‎docs/src/codegen/types/pointers.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ of the dereference:
8888
and so is a whole record, `*p`. A field of a record pointee is copied out in a
8989
closure that borrows the record for its duration: `p->x` is
9090
`p.with(|__s| __s.x)`, and `p->a.b` is `p.with(|__s| __s.a.b)`; `ReadField`
91-
converts the record with `record_ptr_` set, so that its dereference is
92-
emitted as `__s`. A field that is a [`Value` of its own](boxing.md), or a
91+
converts the record with `record_ptr_` set, so that its dereference is emitted
92+
as `__s`. A field that is a [`Value` of its own](boxing.md), or a
9393
`std::unique_ptr`, is copied out as well, i.e., its `Rc`: `p->v.size()` is
9494
`(*p.with(|__s| __s.v.clone()).borrow()).len()`. When the record is not
9595
reached through a pointer, the copy is in a block, `{ (*s.borrow()).x }`. In
@@ -106,7 +106,8 @@ of the dereference:
106106
pointee is a pending dereference too, of `field!(p, x)`, which projects the
107107
pointer to the field (see
108108
[Pointers to fields](../../runtime/rc.md#pointers-to-fields)): `p->x = v` is
109-
`field!(p, x).write(v)`, and `p->a.b = v` is `field!(field!(p, a), b).write(v)`.
109+
`field!(p, x).write(v)`, and `p->a.b = v` is
110+
`field!(field!(p, a), b).write(v)`.
110111

111112
`with` and `with_mut` work on any pointer, including a
112113
[reinterpreted](../../runtime/reinterpret.md) one, whose pointee is decoded from

0 commit comments

Comments
 (0)