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

Further improve slice typecheck #84

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Mar 6, 2024

Follow-up to #83. There's two minor motivations to the change here:

  • Protect against future changes to coercion/inference. By fully specifying the function pointer type, we can ensure that no coercion happens before the closure captures &#ty.
    • e.g. inserting an explicit coercion point with (|| &#ident as _) causes the current tyck to fail.
  • Improve the error message by populating 'static lifetimes, making the type mismatch more directly comparable.

Also removes linkme::__private::value, as that helper function is no longer used.

The chance that a coercion could break the check done by #83 is reasonably low and would be caught on CI, and the error improvement is debatable at best, so it's a judgement call on whether these changes should be merged.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you. I think the error is better like this.

@dtolnay dtolnay merged commit ebfb0a7 into dtolnay:master Mar 7, 2024
13 checks passed
@CAD97 CAD97 deleted the improve-typeck-error branch March 7, 2024 18:11
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

Successfully merging this pull request may close these issues.

2 participants