-
Notifications
You must be signed in to change notification settings - Fork 413
TreeBorrows: Put accesses diagnostic parameters into a single struct #4740
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
base: master
Are you sure you want to change the base?
TreeBorrows: Put accesses diagnostic parameters into a single struct #4740
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice cleanup. :) I just have some nits.
| /// Diagnostics data about the current access and the location we are accessing. | ||
| /// Used to create history events and errors. | ||
| #[derive(Clone, Debug)] | ||
| pub struct DiagnosticsExtra { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "extra"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be more something like AccessContext? It's just a bunch of metadata about the current access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like have "Diag(nostics)" in the name as that makes it purpose more clear.
| span: Span, //diagnostics | ||
| location_range: Range<u64>, //diagnostics | ||
| protected: bool, | ||
| diagnostics: &DiagnosticsExtra, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW in Stacked Borrows we have a lot of dcx: &mut DiagnosticCx<'_, '_, 'tcx>; would that also make sense here? (apparently mutability is currently not needed in TB)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think mutability is necessary. We could also pass it by value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing it by-ref is good, both for performance and to document that this isn't changing.
| alloc_id, | ||
| span, | ||
| ChildrenVisitMode::VisitChildrenOfAccessed, | ||
| &DiagnosticsExtra { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let-bind this before the call.
| alloc_id, | ||
| span, | ||
| ChildrenVisitMode::SkipChildrenOfAccessed, | ||
| &DiagnosticsExtra { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, please let-bind.
All the
perform_accessfunctions take 5 parameters that are purely used for diagnostic purposes. This puts them all into a single struct and passes them by reference.