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

Fix and circumvent new Rust 1.83 lints #967

Merged
merged 1 commit into from
Dec 3, 2024
Merged

Fix and circumvent new Rust 1.83 lints #967

merged 1 commit into from
Dec 3, 2024

Conversation

MarijnS95
Copy link
Collaborator

Rust 1.83 now detects when we unnecessarily specify lifetimes that can be omitted in impl blocks:

warning: the following explicit lifetimes could be elided: 'r
  --> ash/src/lib.rs:85:6
   |
85 | impl<'r, T> RawPtr<T> for Option<&'r T> {
   |      ^^                           ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
   |
85 - impl<'r, T> RawPtr<T> for Option<&'r T> {
85 + impl<T> RawPtr<T> for Option<&T> {
   |

Simple manual cases are solved but autogenerated code is omitted via allow(clippy::needless_lifetimes) because they are incredibly hard to track correctly; we might solve these individually in followup PRs. The main cause of these violations is structs with only a reference via their pNext pointer, but no known structextends and hence no push_next() in the builder impl block. In this case clippy suggests to replace the otherwise-unused forwarding of 'a in impl<'a> StructName<'a> to impl StructName<'_>.

Then there is one special case remaining in AllocationCallbacks which only holds an opaque p_user_data: *mut c_void pointer but we still assign a lifetime and PhantomData to it. We don't track/update the lifetime in the builder at all and might as well strip the lifetime away from this structure entirely.

Finally, clippy detects that our ash-examples crate doesn't have an MSRV and suggests to use C-string literals which are stable since Rust 1.77.

Rust 1.83 now detects when we unnecessarily specify lifetimes that
can be omitted in `impl` blocks:

    warning: the following explicit lifetimes could be elided: 'r
      --> ash/src/lib.rs:85:6
       |
    85 | impl<'r, T> RawPtr<T> for Option<&'r T> {
       |      ^^                           ^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
    help: elide the lifetimes
       |
    85 - impl<'r, T> RawPtr<T> for Option<&'r T> {
    85 + impl<T> RawPtr<T> for Option<&T> {
       |

Simple manual cases are solved but autogenerated code is omitted via
`allow(clippy::needless_lifetimes)` because they are incredibly hard
to track correctly; we might solve these individually in followup PRs.
The main cause of these violations is structs with only a reference
via their `pNext` pointer, but no known `structextends` and hence
no `push_next()` in the builder `impl` block.  In this case clippy
suggests to replace the otherwise-unused forwarding of `'a` in `impl<'a>
StructName<'a>` to `impl StructName<'_>`.

Then there is one special case remaining in `AllocationCallbacks` which
only holds an opaque `p_user_data: *mut c_void` pointer but we still
assign a lifetime and `PhantomData` to it.  We don't track/update the
lifetime in the builder at all and might as well strip the lifetime away
from this structure entirely.

Finally, clippy detects that our `ash-examples` crate doesn't have an
MSRV and suggests to use C-string literals which are stable since Rust
1.77.
@MarijnS95 MarijnS95 merged commit 05bb6b0 into master Dec 3, 2024
20 checks passed
@MarijnS95 MarijnS95 deleted the rust-1.83 branch December 3, 2024 23:41
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