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

Work around unused_qualifications lint for Rust 1.80 prelude extension #931

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

MarijnS95
Copy link
Collaborator

@MarijnS95 MarijnS95 commented Aug 7, 2024

size_of(_val)() was added to the prelude in Rust 1.80, causing unused_qualifications warnings whenever we import mem in scope and call it with mem:: prefix.

The easiest workaround is to remove the prefix and explicitly import the function(s) in scope, which was already done in a few places. We annotate the import with a TODO to remove it once bumping our MSRV on or past 1.80.

@MarijnS95
Copy link
Collaborator Author

Never mind, size_of(_val)() seems to have only been added to the prelude in 1.80: https://doc.rust-lang.org/src/std/prelude/common.rs.html#17-19. It explains my confusion as I don't recall accessing these functions without qualification before.

The documentation is to blame here. https://doc.rust-lang.org/std/prelude/v1/index.html specifically mentions:

The first version of the prelude of The Rust Standard Library.

See the module-level documentation for more.

Followed by a list including size_of(_val)().

And the module-level docs say:

The first version of the prelude is used in Rust 2015 and Rust 2018, and lives in std::prelude::v1. std::prelude::rust_2015 and std::prelude::rust_2018 re-export this prelude. It re-exports the following:

Falsely giving the sense that this has always been in the prelude.

@MarijnS95 MarijnS95 force-pushed the rust-1.80 branch 2 times, most recently from 4d2c612 to e416ccd Compare August 20, 2024 09:54
`size_of(_val)()` was added to the prelude in Rust 1.80, causing
`unused_qualifications` warnings whenever we import `mem` in scope and
call it with `mem::` prefix.

The easiest workaround is to remove the prefix and explicitly import
the function(s) in scope, which was already done in a few places.  We
annotate the import with a `TODO` to remove it once bumping our MSRV
on or past 1.80.
@MarijnS95 MarijnS95 changed the title Fix unused_qualifications lint (more strict since Rust 1.80) Work around unused_qualifications lint for Rust 1.80 prelude extension Aug 20, 2024
@MarijnS95 MarijnS95 merged commit 0b3a134 into master Aug 20, 2024
20 checks passed
@MarijnS95 MarijnS95 deleted the rust-1.80 branch August 20, 2024 10:05
MarijnS95 added a commit that referenced this pull request Oct 15, 2024
In #931 we worked around "unnecessary import" warnings for the
`size_of(_val)()` functions being added to the prelude in Rust 1.80
while maintaining some form of MSRV back-compatibility (despite not
testing the examples against this), but forgot about `align_of()`.
This means the examples still build on Rust 1.80 or higher because
`align_of()` is always in scope via the prelude there, but not on older
compilers.  Fix this by adding it to the import that's tagged to be
removed when we bump all of `ash` to MSRV 1.80.
MarijnS95 added a commit that referenced this pull request Oct 16, 2024
…955)

In #931 we worked around "unnecessary import" warnings for the
`size_of(_val)()` functions being added to the prelude in Rust 1.80
while maintaining some form of MSRV back-compatibility (despite not
testing the examples against this), but forgot about `align_of()`.
This means the examples still build on Rust 1.80 or higher because
`align_of()` is always in scope via the prelude there, but not on older
compilers.  Fix this by adding it to the import that's tagged to be
removed when we bump all of `ash` to MSRV 1.80.
@MarijnS95 MarijnS95 added this to the Ash 0.39 with Vulkan 1.4 milestone Dec 3, 2024
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.

1 participant