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

Dedup Fluent invalid ptr errors in const eval #116777

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

workingjubilee
Copy link
Contributor

I believe these forms aren't unbearable to work with, and Fluent's ability to use selectors allows us to avoid enumerating every case laboriously.

Closes #116764 if accepted.

r? @fee1-dead

I believe these forms aren't unbearable to work with, and Fluent's ability
to use selectors allows us to avoid enumerating every case laboriously.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2023
@workingjubilee
Copy link
Contributor Author

workingjubilee commented Oct 16, 2023

This is an extremely conservative refactor to achieve the goal, admittedly, so perhaps @RalfJung would want further changes along these lines. In any case, this is the kind of thing that is permissible in Fluent, so we don't have to buckle under having a thousand little messages for the same thing, and this way the translator can retain the full context.

@workingjubilee
Copy link
Contributor Author

Apparently this kind of form is the kind of thing Project Fluent prefers?

@RalfJung
Copy link
Member

RalfJung commented Oct 16, 2023

There are 7 more messages that duplicate the box/ref cases:

const_eval_validation_box_to_mut = {$front_matter}: encountered a box pointing to mutable memory in a constant
const_eval_validation_box_to_static = {$front_matter}: encountered a box pointing to a static variable in a constant
const_eval_validation_box_to_uninhabited = {$front_matter}: encountered a box pointing to uninhabited type {$ty}

const_eval_validation_ref_to_mut = {$front_matter}: encountered a reference pointing to mutable memory in a constant
const_eval_validation_ref_to_static = {$front_matter}: encountered a reference pointing to a static variable in a constant
const_eval_validation_ref_to_uninhabited = {$front_matter}: encountered a reference pointing to uninhabited type {$ty}

const_eval_validation_unaligned_box = {$front_matter}: encountered an unaligned box (required {$required_bytes} byte alignment but found {$found_bytes})
const_eval_validation_unaligned_ref = {$front_matter}: encountered an unaligned reference (required {$required_bytes} byte alignment but found {$found_bytes})

const_eval_validation_null_box = {$front_matter}: encountered a null box
const_eval_validation_null_ref = {$front_matter}: encountered a null reference

const_eval_validation_invalid_box_meta = {$front_matter}: encountered invalid box metadata: total size is bigger than largest supported object
const_eval_validation_invalid_ref_meta = {$front_matter}: encountered invalid reference metadata: total size is bigger than largest supported object

const_eval_validation_invalid_box_slice_meta = {$front_matter}: encountered invalid box metadata: slice is bigger than largest supported object
const_eval_validation_invalid_ref_slice_meta = {$front_matter}: encountered invalid reference metadata: slice is bigger than largest supported object

This affects all ValidationError variants that take a PtrKind.

@crlf0710 crlf0710 added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Oct 16, 2023
@workingjubilee
Copy link
Contributor Author

It could use a selector, but it's not clear defaulting between "box" and "reference" yields a correct result, and selectors require defaults.

@RalfJung
Copy link
Member

RalfJung commented Oct 16, 2023 via email

@fee1-dead
Copy link
Member

Also we'd have to repeat the selector 7 times, no? That's still O(n*m) for what should be O(n+m)

Then we'd need to create an identifier for "reference", and another for "box", and then we pass that as a parameter to these messages

@fee1-dead
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2023
@bors
Copy link
Contributor

bors commented Jan 5, 2024

☔ The latest upstream changes (presumably #119621) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC
Copy link
Member

@workingjubilee any updates on this? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Const validation error messages have lots of duplication
7 participants