1
Fork 0

Make printing define_opaque less goofy

This commit is contained in:
Michael Goulet 2025-03-24 22:43:44 +00:00
parent 48994b1674
commit 2bf0c2df14

View file

@ -652,13 +652,7 @@ impl<'a> State<'a> {
) {
let ast::Fn { defaultness, generics, sig, contract, body, define_opaque } = func;
if let Some(define_opaque) = define_opaque {
for (_, path) in define_opaque {
self.word("define opaques from ");
self.print_path(path, false, 0);
self.word(",");
}
}
self.print_define_opaques(define_opaque);
if body.is_some() {
self.head("");
@ -678,6 +672,24 @@ impl<'a> State<'a> {
}
}
fn print_define_opaques(
&mut self,
define_opaque: Option<&[(ast::NodeId, ast::Path)]>,
) {
if let Some(define_opaque) = define_opaque {
self.word("#[define_opaque(");
for (i, (_, path)) in define_opaque.iter().enumerate() {
if i != 0 {
self.word_space(",");
}
self.print_path(path, false, 0);
}
self.word(")]");
}
self.hardbreak_if_not_bol();
}
fn print_contract(&mut self, contract: &ast::FnContract) {
if let Some(pred) = &contract.requires {
self.word("rustc_requires");