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

Upgrade CORE_MSRV to 1.82 and take advantage of some new features #7043

Draft
wants to merge 12 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ env:
REPO_MSRV: "1.83"
# This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates,
# to ensure that they can be used with firefox.
CORE_MSRV: "1.76"
CORE_MSRV: "1.82.0"

#
# Environment variables
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ default-members = [
]

[workspace.lints.clippy]
manual_c_str_literals = "allow"
ref_as_ptr = "warn"
# NOTE: disallowed-types is configured in other file: clippy.toml

Expand Down
10 changes: 4 additions & 6 deletions naga-cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(clippy::manual_strip)]
use anyhow::{anyhow, Context as _};
#[allow(unused_imports)]
use std::fs;
use std::{error::Error, fmt, io::Read, path::Path, str::FromStr};

Expand Down Expand Up @@ -227,10 +225,10 @@ impl FromStr for GlslProfileArg {

fn from_str(s: &str) -> Result<Self, Self::Err> {
use naga::back::glsl::Version;
Ok(Self(if s.starts_with("core") {
Version::Desktop(s[4..].parse().unwrap_or(330))
} else if s.starts_with("es") {
Version::new_gles(s[2..].parse().unwrap_or(310))
Ok(Self(if let Some(s) = s.strip_prefix("core") {
Version::Desktop(s.parse().unwrap_or(330))
} else if let Some(s) = s.strip_prefix("es") {
Version::new_gles(s.parse().unwrap_or(310))
} else {
return Err(format!("Unknown profile: {s}"));
}))
Expand Down
2 changes: 1 addition & 1 deletion naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ autotests = false
# copy the crates it actually uses out of the workspace, so it's meaningful for
# them to have less restrictive MSRVs individually than the workspace as a
# whole, if their code permits. See `../README.md` for details.
rust-version = "1.76"
rust-version = "1.82.0"

[[test]]
name = "naga-test"
Expand Down
4 changes: 3 additions & 1 deletion naga/src/arena/handlevec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl<T, U> Default for HandleVec<T, U> {
}
}

#[allow(dead_code)]
impl<T, U> HandleVec<T, U> {
pub(crate) const fn new() -> Self {
Self {
Expand Down Expand Up @@ -65,7 +64,10 @@ impl<T, U> HandleVec<T, U> {
assert_eq!(handle.index(), self.inner.len());
self.inner.push(value);
}
}

#[cfg_attr(not(any(glsl_out, spv_out, msl_out)), expect(dead_code))]
impl<T, U> HandleVec<T, U> {
pub(crate) fn get(&self, handle: Handle<T>) -> Option<&U> {
self.inner.get(handle.index())
}
Expand Down
1 change: 0 additions & 1 deletion naga/src/arena/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl<T> Arena<T> {
}

/// Extracts the inner vector.
#[allow(clippy::missing_const_for_fn)] // ignore due to requirement of #![feature(const_precise_live_drops)]
pub fn into_inner(self) -> Vec<T> {
self.data
}
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4200,7 +4200,7 @@ impl<'a, W: Write> Writer<'a, W> {
}

/// Helper method for writing an `ImageLoad` expression.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn write_image_load(
&mut self,
handle: Handle<crate::Expression>,
Expand Down
1 change: 0 additions & 1 deletion naga/src/back/hlsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ pub struct OffsetsBindTarget {
pub type BindingMap = std::collections::BTreeMap<crate::ResourceBinding, BindTarget>;

/// A HLSL shader model version.
#[allow(non_snake_case, non_camel_case_types)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
Expand Down
1 change: 0 additions & 1 deletion naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,5 @@ pub fn write_string(

#[test]
fn test_error_size() {
use std::mem::size_of;
assert_eq!(size_of::<Error>(), 32);
}
2 changes: 0 additions & 2 deletions naga/src/back/msl/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ pub struct InlineSampler {

impl Eq for InlineSampler {}

#[allow(renamed_and_removed_lints)]
#[allow(clippy::derive_hash_xor_eq)]
impl std::hash::Hash for InlineSampler {
fn hash<H: std::hash::Hasher>(&self, hasher: &mut H) {
self.coord.hash(hasher);
Expand Down
4 changes: 1 addition & 3 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ impl<W: Write> Writer<W> {

/// Finishes writing and returns the output.
// See https://github.com/rust-lang/rust-clippy/issues/4979.
#[allow(clippy::missing_const_for_fn)]
pub fn finish(self) -> W {
self.out
}
Expand Down Expand Up @@ -1404,7 +1403,7 @@ impl<W: Write> Writer<W> {
)
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn put_possibly_const_expression<C, I, E>(
&mut self,
expr_handle: Handle<crate::Expression>,
Expand Down Expand Up @@ -2505,7 +2504,6 @@ impl<W: Write> Writer<W> {
/// [`ReadZeroSkipWrite`]: index::BoundsCheckPolicy::ReadZeroSkipWrite
/// [`Store`]: crate::Statement::Store
/// [`Load`]: crate::Expression::Load
#[allow(unused_variables)]
fn put_bounds_checks(
&mut self,
mut chain: Handle<crate::Expression>,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/spv/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ impl BlockContext<'_> {
}

/// Build the instructions for matrix - matrix column operations
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn write_matrix_matrix_column_op(
&mut self,
block: &mut Block,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/spv/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(super) fn str_bytes_to_words(bytes: &[u8]) -> Vec<Word> {
}

/// split a string into chunks and keep utf8 valid
#[allow(unstable_name_collisions)]
#[expect(unstable_name_collisions)]
pub(super) fn string_to_byte_chunks(input: &str, limit: usize) -> Vec<&[u8]> {
let mut offset: usize = 0;
let mut start: usize = 0;
Expand Down
4 changes: 2 additions & 2 deletions naga/src/back/spv/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl BlockContext<'_> {
/// Generate code for an `ImageLoad` expression.
///
/// The arguments are the components of an `Expression::ImageLoad` variant.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub(super) fn write_image_load(
&mut self,
result_type_id: Word,
Expand Down Expand Up @@ -807,7 +807,7 @@ impl BlockContext<'_> {
/// Generate code for an `ImageSample` expression.
///
/// The arguments are the components of an `Expression::ImageSample` variant.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub(super) fn write_image_sample(
&mut self,
result_type_id: Word,
Expand Down
3 changes: 1 addition & 2 deletions naga/src/back/spv/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ impl super::Instruction {
instruction
}

#[allow(clippy::too_many_arguments)]
pub(super) fn type_image(
id: Word,
sampled_type_id: Word,
Expand Down Expand Up @@ -748,7 +747,7 @@ impl super::Instruction {
//
// Ray Query Instructions
//
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub(super) fn ray_query_initialize(
query: Word,
acceleration_structure: Word,
Expand Down
2 changes: 0 additions & 2 deletions naga/src/back/spv/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ impl Instruction {
}
}

#[allow(clippy::panic)]
pub(super) fn set_type(&mut self, id: Word) {
assert!(self.type_id.is_none(), "Type can only be set once");
self.type_id = Some(id);
self.wc += 1;
}

#[allow(clippy::panic)]
pub(super) fn set_result(&mut self, id: Word) {
assert!(self.result_id.is_none(), "Result can only be set once");
self.result_id = Some(id);
Expand Down
1 change: 0 additions & 1 deletion naga/src/back/wgsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,6 @@ impl<W: Write> Writer<W> {
}

// See https://github.com/rust-lang/rust-clippy/issues/4979.
#[allow(clippy::missing_const_for_fn)]
pub fn finish(self) -> W {
self.out
}
Expand Down
1 change: 0 additions & 1 deletion naga/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl Block {
}
}

#[allow(unused_variables)]
pub fn push(&mut self, end: Statement, span: Span) {
self.body.push(end);
self.span_info.push(span);
Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/glsl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl<'a> Context<'a> {
vector = pointer;
}

#[allow(clippy::needless_range_loop)]
#[expect(clippy::needless_range_loop)]
for index in 0..size {
let dst = self.add_expression(
Expression::AccessIndex {
Expand Down
6 changes: 2 additions & 4 deletions naga/src/front/glsl/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl Frontend {
})
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn matrix_one_arg(
&mut self,
ctx: &mut Context,
Expand Down Expand Up @@ -348,7 +348,6 @@ impl Frontend {
ctx.add_expression(Expression::Compose { ty, components }, meta)
}

#[allow(clippy::too_many_arguments)]
fn vector_constructor(
&mut self,
ctx: &mut Context,
Expand Down Expand Up @@ -506,7 +505,6 @@ impl Frontend {
ctx.add_expression(Expression::Compose { ty, components }, meta)
}

#[allow(clippy::too_many_arguments)]
fn function_call(
&mut self,
ctx: &mut Context,
Expand Down Expand Up @@ -868,7 +866,7 @@ impl Frontend {

/// Processes a function call argument that appears in place of an output
/// parameter.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn process_lhs_argument(
&mut self,
ctx: &mut Context,
Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/spv/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ impl<I: Iterator<Item = u32>> super::Frontend<I> {
Ok(())
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub(super) fn parse_image_sample(
&mut self,
mut words_left: u16,
Expand Down
13 changes: 5 additions & 8 deletions naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
/// A more complicated version of the binary op,
/// where we force the operand to have the same type as the result.
/// This is mostly needed for "i++" and "i--" coming from GLSL.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn parse_expr_binary_op_sign_adjusted(
&mut self,
ctx: &mut BlockContext,
Expand Down Expand Up @@ -1117,7 +1117,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
/// A version of the binary op where one or both of the arguments might need to be casted to a
/// specific integer kind (unsigned or signed), used for operations like OpINotEqual or
/// OpUGreaterThan.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn parse_expr_int_comparison(
&mut self,
ctx: &mut BlockContext,
Expand Down Expand Up @@ -1265,7 +1265,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
Ok(())
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn insert_composite(
&self,
root_expr: Handle<crate::Expression>,
Expand Down Expand Up @@ -1389,7 +1389,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
Ok((p_lexp_handle, p_base_ty.handle))
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn parse_atomic_expr_with_value(
&mut self,
inst: Instruction,
Expand Down Expand Up @@ -4390,10 +4390,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
overrides: &Arena<crate::Override>,
) -> Arena<crate::Expression> {
let mut expressions = Arena::new();
#[allow(clippy::panic)]
{
assert!(self.lookup_expression.is_empty());
}
assert!(self.lookup_expression.is_empty());
// register global variables
for (&id, var) in self.lookup_variable.iter() {
let span = globals.get_span(var.handle);
Expand Down
5 changes: 1 addition & 4 deletions naga/src/front/wgsl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ use std::ops::Range;
use termcolor::{ColorChoice, NoColor, StandardStream};
use thiserror::Error;

#[cfg(test)]
use std::mem::size_of;

#[derive(Clone, Debug)]
pub struct ParseError {
message: String,
Expand Down Expand Up @@ -1020,7 +1017,7 @@ impl<'a> Error<'a> {
)
.into(),
)],
#[allow(irrefutable_let_patterns)]
#[expect(irrefutable_let_patterns)]
notes: if let EnableExtension::Unimplemented(kind) = kind {
vec![format!(
concat!(
Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub struct ExpressionContext<'source, 'temp, 'out> {
}

impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
#[allow(dead_code)]
#[expect(dead_code)]
fn as_const(&mut self) -> ExpressionContext<'source, '_, '_> {
ExpressionContext {
globals: self.globals,
Expand Down
6 changes: 3 additions & 3 deletions naga/src/front/wgsl/parse/directive/enable_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ impl EnableExtensions {
}

/// Add an enable-extension to the set requested by a module.
#[allow(unreachable_code)]
#[expect(unreachable_code)]
pub(crate) fn add(&mut self, ext: ImplementedEnableExtension) {
let _field: &mut bool = match ext {};
*_field = true;
}

/// Query whether an enable-extension tracked here has been requested.
#[allow(unused)]
#[expect(unused)]
pub(crate) const fn contains(&self, ext: ImplementedEnableExtension) -> bool {
match ext {}
}
Expand All @@ -37,7 +37,7 @@ impl Default for EnableExtensions {
/// WGSL spec.: <https://www.w3.org/TR/WGSL/#enable-extensions-sec>
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum EnableExtension {
#[allow(unused)]
#[expect(unused)]
Implemented(ImplementedEnableExtension),
Unimplemented(UnimplementedEnableExtension),
}
Expand Down
1 change: 0 additions & 1 deletion naga/src/front/wgsl/parse/directive/language_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use strum::VariantArray;
/// WGSL spec.: <https://www.w3.org/TR/WGSL/#language-extensions-sec>
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum LanguageExtension {
#[allow(unused)]
Implemented(ImplementedLanguageExtension),
Unimplemented(UnimplementedLanguageExtension),
}
Expand Down
1 change: 0 additions & 1 deletion naga/src/front/wgsl/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ pub(in crate::front::wgsl) struct Lexer<'a> {
/// statements.
last_end_offset: usize,

#[allow(dead_code)]
pub(in crate::front::wgsl) enable_extensions: EnableExtensions,
}

Expand Down
Loading
Loading