Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maybe bogus: cannot access any field of a datatype where one or more fields are private #957

Closed
jonhnet opened this issue Jan 9, 2024 · 2 comments

Comments

@jonhnet
Copy link
Collaborator

jonhnet commented Jan 9, 2024

I can't figure out what the visibility complaint here means.

+ /home/jonh/verus/source/target-verus/release/verus --time src/bundle.rs
error: in pub open spec function, cannot access any field of a datatype where one or more fields are private
   --> src/marshalling/SeqMarshalling_v.rs:358:11
    |
358 | ...   ((self.total_size - Self::spec_size_of_length_field()) / (self.config.spec_uni...
    |         ^^^^^^^^^^^^^^^

2024-01-08-16-29-29.zip

I am presently working around this by closing all the spec fns it's complaining about, but that may make verification an undue burden.

Note the enclosed code requires the trait-default branch of Verus.

@jonhnet
Copy link
Collaborator Author

jonhnet commented Jan 9, 2024

This was user error. I had the struct pub, but forgot that (unlike traits and enums) I had an obligation to also put pub adjectives on the fields of the struct. Thank you.

However, it might be helpful to enhance this error message to identify one or more non-pub fields. Something like "struct Foo has non-pub fields x, y, z, ...". In the fullness of time, perhaps a Rust-like suggestion inserting 'pub' into the field declaration.

@utaal-b
Copy link
Contributor

utaal-b commented Feb 23, 2024

Moved to #387 (comment)

@utaal-b utaal-b closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants