Skip to content

Conversation

@royAmmerschuber
Copy link
Contributor

All the perform_access functions take 5 parameters that are purely used for diagnostic purposes. This puts them all into a single struct and passes them by reference.

@rustbot
Copy link
Collaborator

rustbot commented Dec 4, 2025

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Dec 4, 2025
Copy link
Member

@RalfJung RalfJung left a 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.

View changes since this review

/// 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "extra"?

Copy link
Contributor Author

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.

Copy link
Member

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,
Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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.

/// Used to create history events and errors.
#[derive(Clone, Debug)]
pub struct DiagnosticsExtra {
pub struct AccessDiagnostics {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this name -- "diagnostic" is the term used in the Rust compiler for a fully computed warning/error output, and that's not what this is.

What about "DiagnosticInfo"?

@rustbot
Copy link
Collaborator

rustbot commented Dec 6, 2025

☔ The latest upstream changes (possibly 56a3765) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting for a review to complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants