Skip to content

Commit 0a92eda

Browse files
authored
transpile: refactor single_attr and call_attr to just use mk().meta_namevalue() and mk().meta_path() instead of creating structure itself (#1343)
refactor `single_attr` and `call_attr` so Meta creation is unified in `mk().meta_*` function
2 parents 834db06 + aeb5938 commit 0a92eda

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

c2rust-ast-builder/src/builder.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -631,32 +631,15 @@ impl Builder {
631631
K: Make<Path>,
632632
V: Make<Lit>,
633633
{
634-
let key = key.make(&self);
635-
let value = value.make(&self);
636-
637-
let mnv = MetaNameValue {
638-
path: key,
639-
eq_token: Token![=](self.span),
640-
value: Expr::Lit(ExprLit {
641-
attrs: vec![],
642-
lit: value,
643-
}),
644-
};
645-
self.prepared_attr(Meta::NameValue(mnv))
634+
let meta = mk().meta_namevalue(key, value);
635+
self.prepared_attr(meta)
646636
}
647637

648638
pub fn single_attr<K>(self, key: K) -> Self
649639
where
650-
K: Make<PathSegment>,
640+
K: Make<Path>,
651641
{
652-
let mut segments = Punctuated::new();
653-
segments.push(key.make(&self));
654-
655-
let meta = Meta::Path(Path {
656-
leading_colon: None,
657-
segments,
658-
});
659-
642+
let meta = mk().meta_path(key);
660643
self.prepared_attr(meta)
661644
}
662645

@@ -665,7 +648,7 @@ impl Builder {
665648
K: Make<Path>,
666649
V: Make<TokenStream>,
667650
{
668-
let meta = self.clone().meta_list(func, arguments);
651+
let meta = mk().meta_list(func, arguments);
669652
self.prepared_attr(meta)
670653
}
671654

0 commit comments

Comments
 (0)