Skip to content

Commit 2bf0c2d

Browse files
Make printing define_opaque less goofy
1 parent 48994b1 commit 2bf0c2d

File tree

1 file changed

+19
-7
lines changed
  • compiler/rustc_ast_pretty/src/pprust/state

1 file changed

+19
-7
lines changed

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -652,13 +652,7 @@ impl<'a> State<'a> {
652652
) {
653653
let ast::Fn { defaultness, generics, sig, contract, body, define_opaque } = func;
654654

655-
if let Some(define_opaque) = define_opaque {
656-
for (_, path) in define_opaque {
657-
self.word("define opaques from ");
658-
self.print_path(path, false, 0);
659-
self.word(",");
660-
}
661-
}
655+
self.print_define_opaques(define_opaque);
662656

663657
if body.is_some() {
664658
self.head("");
@@ -678,6 +672,24 @@ impl<'a> State<'a> {
678672
}
679673
}
680674

675+
fn print_define_opaques(
676+
&mut self,
677+
define_opaque: Option<&[(ast::NodeId, ast::Path)]>,
678+
) {
679+
if let Some(define_opaque) = define_opaque {
680+
self.word("#[define_opaque(");
681+
for (i, (_, path)) in define_opaque.iter().enumerate() {
682+
if i != 0 {
683+
self.word_space(",");
684+
}
685+
686+
self.print_path(path, false, 0);
687+
}
688+
self.word(")]");
689+
}
690+
self.hardbreak_if_not_bol();
691+
}
692+
681693
fn print_contract(&mut self, contract: &ast::FnContract) {
682694
if let Some(pred) = &contract.requires {
683695
self.word("rustc_requires");

0 commit comments

Comments
 (0)