Skip to content

#[verus_spec] misuse error after formatting by verusfmt #1918

@Marsman1996

Description

@Marsman1996

Verusfmt may introduce verification errors when formatting code that uses the #[verus_spec] attribute.

Description

Original code:

        let ptr = vstd_extra::array_ptr::ArrayPtr::<C::E, CONST_NR_ENTRIES>::from_addr(
            paddr_to_vaddr(
                #[verus_spec(with Tracked(&slot_own), Tracked(slot_perm))]
                self.start_paddr()
            ),
        );

Formatted code:

        let ptr = vstd_extra::array_ptr::ArrayPtr::<C::E, CONST_NR_ENTRIES>::from_addr(
            paddr_to_vaddr(
                #[verus_spec(with Tracked(&slot_own), Tracked(slot_perm))]
                self.start_paddr(),
            ),
        );

The extra comma in self.start_paddr(), introduces the error

error: macro expansion ignores `;` and any tokens following
   --> /home/yuwei/ruzykaller/kverus/database/verified/code/ostd/src/mm/page_table/node/mod.rs:322:35
    |
321 |                 #[verus_spec(with Tracked(&slot_own), Tracked(slot_perm))]
    |                 ---------------------------------------------------------- caused by the macro expansion here
322 |                 self.start_paddr(),
    |                                   ^
    |
    = note: the usage of `verus_spec!` is likely invalid in expression context
help: you might be missing a semicolon here
    |
321 |                 #[verus_spec(with Tracked(&slot_own), Tracked(slot_perm))];
    |                                                                           +

error: Misuse of #[verus_spec]
   --> /home/yuwei/ruzykaller/kverus/database/verified/code/ostd/src/mm/page_table/node/mod.rs:322:35
    |
322 |                 self.start_paddr(),
    |                                   ^

error: aborting due to 2 previous errors

More details can be referred to the GitHub workflow here
https://github.com/Marsman1996/vostd/actions/runs/18524524440/job/52792021540

The code can be referred in
Marsman1996/vostd@d94c101

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions