diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a0735ad61..a490ffeca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 381cbb4a3b..e9554de982 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index e7d007d018..72e13a4ee0 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -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}; @@ -227,10 +225,10 @@ impl FromStr for GlslProfileArg { fn from_str(s: &str) -> Result { 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}")); })) diff --git a/naga/Cargo.toml b/naga/Cargo.toml index d325866400..9df89aa00d 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -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" diff --git a/naga/src/arena/handlevec.rs b/naga/src/arena/handlevec.rs index 2ddb65c9a4..017ae75b28 100644 --- a/naga/src/arena/handlevec.rs +++ b/naga/src/arena/handlevec.rs @@ -33,7 +33,6 @@ impl Default for HandleVec { } } -#[allow(dead_code)] impl HandleVec { pub(crate) const fn new() -> Self { Self { @@ -65,7 +64,10 @@ impl HandleVec { 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 HandleVec { pub(crate) fn get(&self, handle: Handle) -> Option<&U> { self.inner.get(handle.index()) } diff --git a/naga/src/arena/mod.rs b/naga/src/arena/mod.rs index 8bd3fb84cf..4254325f4f 100644 --- a/naga/src/arena/mod.rs +++ b/naga/src/arena/mod.rs @@ -77,7 +77,6 @@ impl Arena { } /// 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 { self.data } diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 0798fac82d..713692bf06 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -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, diff --git a/naga/src/back/hlsl/mod.rs b/naga/src/back/hlsl/mod.rs index a5c795c85e..ad53640ffb 100644 --- a/naga/src/back/hlsl/mod.rs +++ b/naga/src/back/hlsl/mod.rs @@ -153,7 +153,6 @@ pub struct OffsetsBindTarget { pub type BindingMap = std::collections::BTreeMap; /// 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))] diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index be94b26742..66a5bdc1a8 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -697,6 +697,5 @@ pub fn write_string( #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/naga/src/back/msl/sampler.rs b/naga/src/back/msl/sampler.rs index 0bf987076d..264cc6100c 100644 --- a/naga/src/back/msl/sampler.rs +++ b/naga/src/back/msl/sampler.rs @@ -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(&self, hasher: &mut H) { self.coord.hash(hasher); diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 546a8cf829..dafa0e433c 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -691,7 +691,6 @@ impl Writer { /// 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 } @@ -1404,7 +1403,7 @@ impl Writer { ) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn put_possibly_const_expression( &mut self, expr_handle: Handle, @@ -2505,7 +2504,6 @@ impl Writer { /// [`ReadZeroSkipWrite`]: index::BoundsCheckPolicy::ReadZeroSkipWrite /// [`Store`]: crate::Statement::Store /// [`Load`]: crate::Expression::Load - #[allow(unused_variables)] fn put_bounds_checks( &mut self, mut chain: Handle, diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 1e87e2e6d1..0a74a420f5 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -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, diff --git a/naga/src/back/spv/helpers.rs b/naga/src/back/spv/helpers.rs index 63144abc02..250d740b7b 100644 --- a/naga/src/back/spv/helpers.rs +++ b/naga/src/back/spv/helpers.rs @@ -25,7 +25,7 @@ pub(super) fn str_bytes_to_words(bytes: &[u8]) -> Vec { } /// 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; diff --git a/naga/src/back/spv/image.rs b/naga/src/back/spv/image.rs index fe4001060e..b69e0d0e77 100644 --- a/naga/src/back/spv/image.rs +++ b/naga/src/back/spv/image.rs @@ -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, @@ -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, diff --git a/naga/src/back/spv/instructions.rs b/naga/src/back/spv/instructions.rs index 38aed8c351..c4dedb25f7 100644 --- a/naga/src/back/spv/instructions.rs +++ b/naga/src/back/spv/instructions.rs @@ -282,7 +282,6 @@ impl super::Instruction { instruction } - #[allow(clippy::too_many_arguments)] pub(super) fn type_image( id: Word, sampled_type_id: Word, @@ -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, diff --git a/naga/src/back/spv/layout.rs b/naga/src/back/spv/layout.rs index 39117a3d2a..8e6c5ade13 100644 --- a/naga/src/back/spv/layout.rs +++ b/naga/src/back/spv/layout.rs @@ -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); diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index a7cd8f95c9..ba73abd958 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -1963,7 +1963,6 @@ impl Writer { } // See https://github.com/rust-lang/rust-clippy/issues/4979. - #[allow(clippy::missing_const_for_fn)] pub fn finish(self) -> W { self.out } diff --git a/naga/src/block.rs b/naga/src/block.rs index 2e86a928f1..d8b2403b6d 100644 --- a/naga/src/block.rs +++ b/naga/src/block.rs @@ -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); diff --git a/naga/src/front/glsl/context.rs b/naga/src/front/glsl/context.rs index b4cb1c874e..6cf9515984 100644 --- a/naga/src/front/glsl/context.rs +++ b/naga/src/front/glsl/context.rs @@ -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 { diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index 0d05c5433c..8554c879c8 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/naga/src/front/spv/image.rs b/naga/src/front/spv/image.rs index ace97d4dd5..fd47052f17 100644 --- a/naga/src/front/spv/image.rs +++ b/naga/src/front/spv/image.rs @@ -482,7 +482,7 @@ impl> super::Frontend { Ok(()) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub(super) fn parse_image_sample( &mut self, mut words_left: u16, diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index b8087fc8b0..256312d472 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -1039,7 +1039,7 @@ impl> Frontend { /// 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, @@ -1117,7 +1117,7 @@ impl> Frontend { /// 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, @@ -1265,7 +1265,7 @@ impl> Frontend { Ok(()) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn insert_composite( &self, root_expr: Handle, @@ -1389,7 +1389,7 @@ impl> Frontend { 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, @@ -4390,10 +4390,7 @@ impl> Frontend { overrides: &Arena, ) -> Arena { 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); diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 7bdbf12d2c..6c64f5cde9 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -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, @@ -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!( diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index d25eb362c1..d69f38084d 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -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, diff --git a/naga/src/front/wgsl/parse/directive/enable_extension.rs b/naga/src/front/wgsl/parse/directive/enable_extension.rs index 147ec0b5e0..006f8f1e08 100644 --- a/naga/src/front/wgsl/parse/directive/enable_extension.rs +++ b/naga/src/front/wgsl/parse/directive/enable_extension.rs @@ -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 {} } @@ -37,7 +37,7 @@ impl Default for EnableExtensions { /// WGSL spec.: #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] pub enum EnableExtension { - #[allow(unused)] + #[expect(unused)] Implemented(ImplementedEnableExtension), Unimplemented(UnimplementedEnableExtension), } diff --git a/naga/src/front/wgsl/parse/directive/language_extension.rs b/naga/src/front/wgsl/parse/directive/language_extension.rs index 4a48ccd919..2eb663ef70 100644 --- a/naga/src/front/wgsl/parse/directive/language_extension.rs +++ b/naga/src/front/wgsl/parse/directive/language_extension.rs @@ -9,7 +9,6 @@ use strum::VariantArray; /// WGSL spec.: #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum LanguageExtension { - #[allow(unused)] Implemented(ImplementedLanguageExtension), Unimplemented(UnimplementedLanguageExtension), } diff --git a/naga/src/front/wgsl/parse/lexer.rs b/naga/src/front/wgsl/parse/lexer.rs index 0b0b6edebc..02d1f5b20c 100644 --- a/naga/src/front/wgsl/parse/lexer.rs +++ b/naga/src/front/wgsl/parse/lexer.rs @@ -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, } diff --git a/naga/src/lib.rs b/naga/src/lib.rs index 04f3f52bba..fb5a68d12e 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -233,6 +233,7 @@ An override expression can be evaluated at pipeline creation time. trivial_numeric_casts, unused_extern_crates, unused_qualifications, + clippy::allow_attributes, clippy::pattern_type_mismatch, clippy::missing_const_for_fn, clippy::rest_pat_in_fully_bound_structs, @@ -365,7 +366,7 @@ pub enum ConservativeDepth { #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -#[allow(missing_docs)] // The names are self evident +#[expect(missing_docs)] // The names are self evident pub enum ShaderStage { Vertex, Fragment, @@ -1758,7 +1759,7 @@ pub enum RayQueryFunction { /// [`AccelerationStructure`]: TypeInner::AccelerationStructure acceleration_structure: Handle, - #[allow(rustdoc::private_intra_doc_links)] + #[expect(rustdoc::private_intra_doc_links)] /// A struct of detailed parameters for the ray query. /// /// This expression should have the struct type given in diff --git a/naga/src/non_max_u32.rs b/naga/src/non_max_u32.rs index 2ad402e497..7cb641b4e9 100644 --- a/naga/src/non_max_u32.rs +++ b/naga/src/non_max_u32.rs @@ -140,6 +140,5 @@ impl<'de> serde::Deserialize<'de> for NonMaxU32 { #[test] fn size() { - use core::mem::size_of; assert_eq!(size_of::>(), size_of::()); } diff --git a/naga/src/proc/constant_evaluator.rs b/naga/src/proc/constant_evaluator.rs index c8911077b7..7c2fd24b4d 100644 --- a/naga/src/proc/constant_evaluator.rs +++ b/naga/src/proc/constant_evaluator.rs @@ -164,7 +164,7 @@ macro_rules! gen_component_wise_extractor { with_dollar_sign! { ($d:tt) => { - #[allow(unused)] + #[allow(clippy::allow_attributes, unused)] #[doc = concat!( "A convenience macro for using the same RHS for each [`", stringify!($target), @@ -1259,7 +1259,7 @@ impl<'a> ConstantEvaluator<'a> { // bits crate::MathFunction::CountTrailingZeros => { component_wise_concrete_int!(self, span, [arg], |e| { - #[allow(clippy::useless_conversion)] + #[allow(clippy::allow_attributes, clippy::useless_conversion)] Ok([e .trailing_zeros() .try_into() @@ -1268,7 +1268,7 @@ impl<'a> ConstantEvaluator<'a> { } crate::MathFunction::CountLeadingZeros => { component_wise_concrete_int!(self, span, [arg], |e| { - #[allow(clippy::useless_conversion)] + #[allow(clippy::allow_attributes, clippy::useless_conversion)] Ok([e .leading_zeros() .try_into() @@ -1277,7 +1277,7 @@ impl<'a> ConstantEvaluator<'a> { } crate::MathFunction::CountOneBits => { component_wise_concrete_int!(self, span, [arg], |e| { - #[allow(clippy::useless_conversion)] + #[allow(clippy::allow_attributes, clippy::useless_conversion)] Ok([e .count_ones() .try_into() diff --git a/naga/src/proc/emitter.rs b/naga/src/proc/emitter.rs index 0df804fff2..6778dae8d6 100644 --- a/naga/src/proc/emitter.rs +++ b/naga/src/proc/emitter.rs @@ -1,13 +1,11 @@ use crate::arena::Arena; /// Helper class to emit expressions -#[allow(dead_code)] #[derive(Default, Debug)] pub struct Emitter { start_len: Option, } -#[allow(dead_code)] impl Emitter { pub fn start(&mut self, arena: &Arena) { if self.start_len.is_some() { @@ -25,7 +23,6 @@ impl Emitter { ) -> Option<(crate::Statement, crate::span::Span)> { let start_len = self.start_len.take().unwrap(); if start_len != arena.len() { - #[allow(unused_mut)] let mut span = crate::span::Span::default(); let range = arena.range_from(start_len); for handle in range.clone() { diff --git a/naga/src/proc/layouter.rs b/naga/src/proc/layouter.rs index 82b1be094a..bb9e68e47a 100644 --- a/naga/src/proc/layouter.rs +++ b/naga/src/proc/layouter.rs @@ -162,7 +162,7 @@ impl Layouter { /// end can call this function at any time, passing its current type and /// constant arenas, and then assume that layouts are available for all /// types. - #[allow(clippy::or_fun_call)] + #[expect(clippy::or_fun_call)] pub fn update(&mut self, gctx: super::GlobalCtx) -> Result<(), LayoutError> { use crate::TypeInner as Ti; diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index a6a19f70ed..80a1982f76 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -411,7 +411,10 @@ pub struct GlobalCtx<'a> { impl GlobalCtx<'_> { /// Try to evaluate the expression in `self.global_expressions` using its `handle` and return it as a `u32`. - #[allow(dead_code)] + #[cfg_attr( + not(any(feature = "spv-in", feature = "glsl-in", feature = "wgsl-in")), + expect(dead_code) + )] pub(super) fn eval_expr_to_u32( &self, handle: crate::Handle, @@ -435,7 +438,10 @@ impl GlobalCtx<'_> { } /// Try to evaluate the expression in the `arena` using its `handle` and return it as a `bool`. - #[allow(dead_code)] + #[cfg_attr( + not(any(feature = "spv-in", feature = "glsl-in", feature = "wgsl-in")), + expect(dead_code) + )] pub(super) fn eval_expr_to_bool_from( &self, handle: crate::Handle, @@ -447,7 +453,10 @@ impl GlobalCtx<'_> { } } - #[allow(dead_code)] + #[cfg_attr( + not(any(feature = "spv-in", feature = "glsl-in", feature = "wgsl-in")), + expect(dead_code) + )] pub(crate) fn eval_expr_to_literal( &self, handle: crate::Handle, diff --git a/naga/src/proc/typifier.rs b/naga/src/proc/typifier.rs index 1359289900..d813bc9eae 100644 --- a/naga/src/proc/typifier.rs +++ b/naga/src/proc/typifier.rs @@ -908,6 +908,5 @@ impl<'a> ResolveContext<'a> { #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/naga/src/span.rs b/naga/src/span.rs index 0256e19dc4..713e6a4052 100644 --- a/naga/src/span.rs +++ b/naga/src/span.rs @@ -171,7 +171,6 @@ impl WithSpan { } /// Reverse of [`Self::new`], discards span information and returns an inner error. - #[allow(clippy::missing_const_for_fn)] // ignore due to requirement of #![feature(const_precise_live_drops)] pub fn into_inner(self) -> E { self.inner } diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index 8417bf77be..73ab565b03 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -233,7 +233,6 @@ struct Sampling { #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] pub struct FunctionInfo { /// Validation flags. - #[allow(dead_code)] flags: ValidationFlags, /// Set of shader stages where calling this function is valid. pub available_stages: ShaderStages, @@ -506,7 +505,7 @@ impl FunctionInfo { /// [`sampling_set`]: FunctionInfo::sampling_set /// [`sampling`]: FunctionInfo::sampling /// [`global_uses`]: FunctionInfo::global_uses - #[allow(clippy::or_fun_call)] + #[expect(clippy::or_fun_call)] fn process_expression( &mut self, handle: Handle, @@ -827,7 +826,7 @@ impl FunctionInfo { /// /// Returns a `NonUniformControlFlow` error if any of the expressions in the block /// require uniformity, but the current flow is non-uniform. - #[allow(clippy::or_fun_call)] + #[expect(clippy::or_fun_call)] fn process_block( &mut self, statements: &crate::Block, diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index 9ef3a9edfb..b80c2cf877 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -180,7 +180,7 @@ struct ExpressionTypeResolver<'a> { impl std::ops::Index> for ExpressionTypeResolver<'_> { type Output = crate::TypeInner; - #[allow(clippy::panic)] + #[expect(clippy::panic)] fn index(&self, handle: Handle) -> &Self::Output { if handle < self.root { self.info[handle].ty.inner_with(self.types) @@ -234,7 +234,7 @@ impl super::Validator { Ok(()) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub(super) fn validate_expression( &self, root: Handle, diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 9f92e708ce..9bc01297da 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -1138,10 +1138,10 @@ impl super::Validator { }; // The `coordinate` operand must be a vector of the appropriate size. - if !context + if context .resolve_type(coordinate, &self.valid_expression_set)? .image_storage_coordinates() - .is_some_and(|coord_dim| coord_dim == dim) + .is_none_or(|coord_dim| coord_dim != dim) { return Err(FunctionError::InvalidImageStore( ExpressionError::InvalidImageCoordinateType(dim, coordinate), diff --git a/naga/src/valid/handles.rs b/naga/src/valid/handles.rs index 260d442c79..6fb4b6df74 100644 --- a/naga/src/valid/handles.rs +++ b/naga/src/valid/handles.rs @@ -380,7 +380,7 @@ impl super::Validator { Ok(max_type) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn validate_expression_handles( (handle, expression): (Handle, &crate::Expression), constants: &Arena, diff --git a/naga/src/valid/mod.rs b/naga/src/valid/mod.rs index 906d449362..3f084b40be 100644 --- a/naga/src/valid/mod.rs +++ b/naga/src/valid/mod.rs @@ -269,7 +269,6 @@ pub struct Validator { layouter: Layouter, location_mask: BitSet, ep_resource_bindings: FastHashSet, - #[allow(dead_code)] switch_values: FastHashSet, valid_expression_list: Vec>, valid_expression_set: HandleSet, diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index 829019d99b..13b743066a 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -265,7 +265,7 @@ type FragmentEntryPoint<'a> = naga::back::hlsl::FragmentEntryPoint<'a>; #[cfg(not(hlsl_out))] type FragmentEntryPoint<'a> = (); -#[allow(unused_variables)] +#[expect(unused_variables)] fn check_targets( input: &Input, module: &mut naga::Module, @@ -562,7 +562,7 @@ fn write_output_msl( } #[cfg(glsl_out)] -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn write_output_glsl( input: &Input, module: &naga::Module, @@ -1126,7 +1126,6 @@ fn convert_glsl_variations_check() { } #[cfg(feature = "glsl-in")] -#[allow(unused_variables)] #[test] fn convert_glsl_folder() { let _ = env_logger::try_init(); diff --git a/naga/tests/validation.rs b/naga/tests/validation.rs index 3ffb231e25..b298e2af59 100644 --- a/naga/tests/validation.rs +++ b/naga/tests/validation.rs @@ -497,7 +497,6 @@ fn main(input: VertexOutput) {{ } } -#[allow(dead_code)] struct BindingArrayFixture { module: naga::Module, span: naga::Span, diff --git a/naga/tests/wgsl_errors.rs b/naga/tests/wgsl_errors.rs index a23eaf7047..93e4ec4de9 100644 --- a/naga/tests/wgsl_errors.rs +++ b/naga/tests/wgsl_errors.rs @@ -833,7 +833,7 @@ macro_rules! check_one_validation { ( $source:expr, $pattern:pat $( if $guard:expr )? ) => { let source = $source; let error = validation_error($source, naga::valid::Capabilities::default()); - #[allow(clippy::redundant_pattern_matching)] + #[allow(clippy::allow_attributes, clippy::redundant_pattern_matching)] if ! matches!(&error, $pattern $( if $guard )? ) { eprintln!("validation error does not match pattern:\n\ source code: {}\n\ @@ -853,7 +853,7 @@ macro_rules! check_one_validation { ( $source:expr, $pattern:pat $( if $guard:expr )?, $capabilities:expr ) => { let source = $source; let error = validation_error($source, $capabilities); - #[allow(clippy::redundant_pattern_matching)] + #[allow(clippy::allow_attributes, clippy::redundant_pattern_matching)] if ! matches!(&error, $pattern $( if $guard )? ) { eprintln!("validation error does not match pattern:\n\ source code: {}\n\ diff --git a/tests/src/expectations.rs b/tests/src/expectations.rs index b6e0beaeff..e49dfebb6a 100644 --- a/tests/src/expectations.rs +++ b/tests/src/expectations.rs @@ -305,7 +305,7 @@ impl FailureReason { }; /// Match a validation error. - #[allow(dead_code)] // Not constructed on wasm + #[cfg_attr(target_arch = "wasm32", expect(dead_code))] pub fn validation_error() -> Self { Self { kind: Some(FailureResultKind::ValidationError), @@ -350,7 +350,7 @@ pub enum FailureBehavior { #[derive(Debug, Clone, Copy, PartialEq)] pub(crate) enum FailureResultKind { - #[allow(dead_code)] // Not constructed on wasm + #[cfg_attr(target_arch = "wasm32", expect(dead_code))] ValidationError, Panic, } @@ -380,7 +380,7 @@ impl FailureResult { } /// Failure result is a validation error. - #[allow(dead_code)] // Not constructed on wasm + #[cfg_attr(target_arch = "wasm32", expect(dead_code))] pub(super) fn validation_error() -> Self { Self { kind: FailureResultKind::ValidationError, diff --git a/tests/src/init.rs b/tests/src/init.rs index 60639f67a6..79e56d77ff 100644 --- a/tests/src/init.rs +++ b/tests/src/init.rs @@ -57,11 +57,11 @@ pub async fn initialize_adapter( .unwrap_or_default(); let instance = initialize_instance(backends, force_fxc); - #[allow(unused_variables)] + #[expect(unused_variables)] let surface: Option; let surface_guard: Option; - #[allow(unused_assignments)] + #[expect(unused_assignments)] // Create a canvas if we need a WebGL2RenderingContext to have a working device. #[cfg(not(all( target_arch = "wasm32", @@ -160,7 +160,7 @@ pub fn initialize_html_canvas() -> web_sys::HtmlCanvasElement { pub struct SurfaceGuard { #[cfg(target_arch = "wasm32")] - #[allow(unused)] + #[expect(unused)] canvas: web_sys::HtmlCanvasElement, } diff --git a/tests/src/report.rs b/tests/src/report.rs index b26bdbfaf3..326fdcea15 100644 --- a/tests/src/report.rs +++ b/tests/src/report.rs @@ -10,12 +10,12 @@ use wgpu::{ /// Must be synchronized with the definition on wgpu-info/src/report.rs. #[derive(Deserialize)] pub(crate) struct GpuReport { - #[cfg_attr(target_arch = "wasm32", allow(unused))] + #[cfg_attr(target_arch = "wasm32", expect(unused))] pub devices: Vec, } impl GpuReport { - #[cfg_attr(target_arch = "wasm32", allow(unused))] + #[cfg_attr(target_arch = "wasm32", expect(unused))] pub(crate) fn from_json(file: &str) -> serde_json::Result { profiling::scope!("Parsing .gpuconfig"); serde_json::from_str(file) @@ -31,7 +31,6 @@ pub struct AdapterReport { pub features: Features, pub limits: Limits, pub downlevel_caps: DownlevelCapabilities, - #[allow(unused)] pub texture_format_features: HashMap, } diff --git a/tests/tests/create_surface_error.rs b/tests/tests/create_surface_error.rs index 75c8b90201..9af0bcecca 100644 --- a/tests/tests/create_surface_error.rs +++ b/tests/tests/create_surface_error.rs @@ -13,7 +13,7 @@ fn canvas_get_context_returned_null() { // Using a context id that is not "webgl2" or "webgpu" will render the canvas unusable by wgpu. canvas.get_context("2d").unwrap(); - #[allow(clippy::redundant_clone)] // false positive — can't and shouldn't move out. + #[expect(clippy::redundant_clone)] let error = instance .create_surface(wgpu::SurfaceTarget::Canvas(canvas.clone())) .unwrap_err(); diff --git a/tests/tests/encoder.rs b/tests/tests/encoder.rs index c832edd973..822ce4a069 100644 --- a/tests/tests/encoder.rs +++ b/tests/tests/encoder.rs @@ -144,7 +144,7 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) { let target_tex = ctx.device.create_texture(&target_desc); let color_attachment_view = target_tex.create_view(&wgpu::TextureViewDescriptor::default()); - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] let recording_ops: Vec<(_, Box)> = vec![ ( "begin_compute_pass", diff --git a/tests/tests/regression/issue_6827.rs b/tests/tests/regression/issue_6827.rs index a1e727119b..03d9dabafc 100644 --- a/tests/tests/regression/issue_6827.rs +++ b/tests/tests/regression/issue_6827.rs @@ -86,7 +86,6 @@ async fn run_test(ctx: TestingContext, use_many_writes: bool) { let mut wrong_texels = Vec::new(); for (zyx_index, cube) in texel_iter(&texture).enumerate() { - #[allow(clippy::cast_possible_wrap)] let expected = texel_for_cube(cube); let actual = light_texels[zyx_index]; if expected != actual { diff --git a/tests/tests/shader/data_builtins.rs b/tests/tests/shader/data_builtins.rs index f6f24f3241..484dd24062 100644 --- a/tests/tests/shader/data_builtins.rs +++ b/tests/tests/shader/data_builtins.rs @@ -3,7 +3,7 @@ use wgpu::{DownlevelFlags, Limits}; use crate::shader::{shader_input_output_test, InputStorageType, ShaderTest}; use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters}; -#[allow(non_snake_case)] +#[expect(non_snake_case)] fn create_unpack4xU8_test() -> Vec { let mut tests = Vec::new(); @@ -40,7 +40,7 @@ static UNPACK4xU8: GpuTestConfiguration = GpuTestConfiguration::new() shader_input_output_test(ctx, InputStorageType::Storage, create_unpack4xU8_test()) }); -#[allow(non_snake_case)] +#[expect(non_snake_case)] fn create_unpack4xI8_test() -> Vec { let mut tests = Vec::with_capacity(2); @@ -84,7 +84,7 @@ static UNPACK4xI8: GpuTestConfiguration = GpuTestConfiguration::new() shader_input_output_test(ctx, InputStorageType::Storage, create_unpack4xI8_test()) }); -#[allow(non_snake_case)] +#[expect(non_snake_case)] fn create_pack4xU8_test() -> Vec { let mut tests = Vec::new(); @@ -113,7 +113,7 @@ static PACK4xU8: GpuTestConfiguration = GpuTestConfiguration::new() shader_input_output_test(ctx, InputStorageType::Storage, create_pack4xU8_test()) }); -#[allow(non_snake_case)] +#[expect(non_snake_case)] fn create_pack4xI8_test() -> Vec { let mut tests = Vec::with_capacity(2); diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 41481e3cda..784d0add2f 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # 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" [package.metadata.docs.rs] all-features = true @@ -29,9 +29,6 @@ targets = [ # Cargo machete can't check build.rs dependencies. See https://github.com/bnjbvr/cargo-machete/issues/100 ignored = ["cfg_aliases"] -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(wgpu_validate_locks)'] } - [lib] [features] diff --git a/wgpu-core/build.rs b/wgpu-core/build.rs index 4d35481678..8eb72c4e33 100644 --- a/wgpu-core/build.rs +++ b/wgpu-core/build.rs @@ -10,4 +10,5 @@ fn main() { metal: { all(target_vendor = "apple", feature = "metal") }, vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") } } + println!("cargo::rustc-check-cfg=cfg(wgpu_validate_locks)"); } diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 3ab652abce..f733eb77fa 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -542,7 +542,6 @@ pub struct BindGroupLayout { /// (derived BGLs) must not be removed. pub(crate) origin: bgl::Origin, pub(crate) exclusive_pipeline: OnceLock, - #[allow(unused)] pub(crate) binding_count_validator: BindingTypeMaxCountValidator, /// The `label` from the descriptor used to create the resource. pub(crate) label: String, diff --git a/wgpu-core/src/command/bind.rs b/wgpu-core/src/command/bind.rs index 2e1ffa030e..62d77348dd 100644 --- a/wgpu-core/src/command/bind.rs +++ b/wgpu-core/src/command/bind.rs @@ -250,7 +250,7 @@ mod compat { .filter_map(|(i, e)| if e.is_active() { Some(i) } else { None }) } - #[allow(clippy::result_large_err)] + #[expect(clippy::result_large_err)] pub fn get_invalid(&self) -> Result<(), (usize, Error)> { for (index, entry) in self.entries.iter().enumerate() { entry.check().map_err(|e| (index, e))?; diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 23e4532c39..f412c0cd83 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -103,7 +103,7 @@ use crate::{ }; use arrayvec::ArrayVec; -use std::{borrow::Cow, mem::size_of, num::NonZeroU32, ops::Range, sync::Arc}; +use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc}; use thiserror::Error; use super::{ diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index d9b0b19052..576417ea48 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -30,7 +30,7 @@ use wgt::{BufferAddress, DynamicOffset}; use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions}; use crate::ray_tracing::TlasAction; -use std::{fmt, mem::size_of, str, sync::Arc}; +use std::{fmt, str, sync::Arc}; pub struct ComputePass { /// All pass data & records is stored here. diff --git a/wgpu-core/src/command/compute_command.rs b/wgpu-core/src/command/compute_command.rs index e8c9ad9974..62ac19f0e1 100644 --- a/wgpu-core/src/command/compute_command.rs +++ b/wgpu-core/src/command/compute_command.rs @@ -228,7 +228,7 @@ pub enum ArcComputeCommand { }, PushDebugGroup { - #[cfg_attr(not(any(feature = "serde", feature = "replay")), allow(dead_code))] + #[cfg_attr(not(any(feature = "serde", feature = "replay")), expect(dead_code))] color: u32, len: usize, }, @@ -236,7 +236,7 @@ pub enum ArcComputeCommand { PopDebugGroup, InsertDebugMarker { - #[cfg_attr(not(any(feature = "serde", feature = "replay")), allow(dead_code))] + #[cfg_attr(not(any(feature = "serde", feature = "replay")), expect(dead_code))] color: u32, len: usize, }, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 58f7f126b3..827738f200 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -45,7 +45,7 @@ use serde::Deserialize; #[cfg(feature = "serde")] use serde::Serialize; -use std::{borrow::Cow, fmt, iter, mem::size_of, num::NonZeroU32, ops::Range, str, sync::Arc}; +use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str, sync::Arc}; use super::render_command::ArcRenderCommand; use super::{ diff --git a/wgpu-core/src/command/render_command.rs b/wgpu-core/src/command/render_command.rs index 8585f645ec..88b6589393 100644 --- a/wgpu-core/src/command/render_command.rs +++ b/wgpu-core/src/command/render_command.rs @@ -473,13 +473,13 @@ pub enum ArcRenderCommand { indexed: bool, }, PushDebugGroup { - #[cfg_attr(not(any(feature = "serde", feature = "replay")), allow(dead_code))] + #[cfg_attr(not(any(feature = "serde", feature = "replay")), expect(dead_code))] color: u32, len: usize, }, PopDebugGroup, InsertDebugMarker { - #[cfg_attr(not(any(feature = "serde", feature = "replay")), allow(dead_code))] + #[cfg_attr(not(any(feature = "serde", feature = "replay")), expect(dead_code))] color: u32, len: usize, }, diff --git a/wgpu-core/src/conv.rs b/wgpu-core/src/conv.rs index 5216ad0f69..42accb56cf 100644 --- a/wgpu-core/src/conv.rs +++ b/wgpu-core/src/conv.rs @@ -29,7 +29,7 @@ pub fn is_valid_copy_dst_texture_format( #[cfg_attr( any(not(target_arch = "wasm32"), target_os = "emscripten"), - allow(unused) + expect(unused) )] pub fn is_valid_external_image_copy_dst_texture_format(format: wgt::TextureFormat) -> bool { use wgt::TextureFormat as Tf; diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index eff2e811be..ec0bf008bb 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -242,7 +242,7 @@ impl Global { unsafe { std::ptr::copy_nonoverlapping(data.as_ptr(), mapping.ptr.as_ptr(), data.len()) }; if !mapping.is_coherent { - #[allow(clippy::single_range_in_vec_init)] + #[expect(clippy::single_range_in_vec_init)] unsafe { device .raw() @@ -941,8 +941,6 @@ impl Global { (id, Some(error)) } - // Unsafe-ness of internal calls has little to do with unsafe-ness of this. - #[allow(unused_unsafe)] /// # Safety /// /// This function passes SPIR-V binary to the backend as-is and can potentially result in a diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index e9600f72d6..8a998fb8a8 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -214,7 +214,7 @@ pub(crate) fn map_buffer( }; if !mapping.is_coherent && kind == HostMap::Read { - #[allow(clippy::single_range_in_vec_init)] + #[expect(clippy::single_range_in_vec_init)] unsafe { raw_device.invalidate_mapped_ranges(raw_buffer, &[offset..offset + size]); } diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index e4211ef2f0..f9a85bafe7 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -873,7 +873,7 @@ impl Queue { needs_flag |= matches!(source.source, wgt::ExternalImageSource::OffscreenCanvas(_)); needs_flag |= source.origin != wgt::Origin2d::ZERO; needs_flag |= destination.color_space != wgt::PredefinedColorSpace::Srgb; - #[allow(clippy::bool_comparison)] + #[expect(clippy::bool_comparison)] if matches!(source.source, wgt::ExternalImageSource::ImageBitmap(_)) { needs_flag |= source.flip_y != false; needs_flag |= destination.premultiplied_alpha != false; @@ -1096,7 +1096,7 @@ impl Queue { // Note that we are required to invalidate all command buffers in both the success and failure paths. // This is why we `continue` and don't early return via `?`. - #[allow(unused_mut)] + #[cfg_attr(not(feature = "trace"), expect(unused_mut))] let mut cmd_buf_data = command_buffer.take_finished(); #[cfg(feature = "trace")] diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 09747137ac..4e2ff35a01 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -1593,7 +1593,6 @@ impl Device { Ok(module) } - #[allow(unused_unsafe)] pub(crate) unsafe fn create_shader_module_spirv<'a>( self: &Arc, desc: &pipeline::ShaderModuleDescriptor<'a>, diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index a5f849cb8c..6c9cc2d228 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -31,7 +31,7 @@ pub(crate) fn new_render_bundle_encoder_descriptor<'a>( } } -#[allow(clippy::large_enum_variant)] +#[expect(clippy::large_enum_variant)] #[derive(Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Action<'a> { diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 15d3e3c06b..41bf919ac3 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -140,7 +140,7 @@ impl HubReport { } } -#[allow(rustdoc::private_intra_doc_links)] +#[expect(rustdoc::private_intra_doc_links)] /// All the resources tracked by a [`crate::global::Global`]. /// /// ## Locking diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 2fdfde9116..dba773abf3 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -4,7 +4,6 @@ use std::{ fmt::{self, Debug}, hash::Hash, marker::PhantomData, - mem::size_of, num::NonZeroU64, }; use wgt::WasmNotSendSync; @@ -88,7 +87,6 @@ impl RawId { pub struct Id(RawId, PhantomData); // This type represents Id in a more readable (and editable) way. -#[allow(dead_code)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] enum SerialId { // The only variant forces RON to not ignore "Id" diff --git a/wgpu-core/src/indirect_validation.rs b/wgpu-core/src/indirect_validation.rs index e16828aede..32cb7de462 100644 --- a/wgpu-core/src/indirect_validation.rs +++ b/wgpu-core/src/indirect_validation.rs @@ -1,4 +1,3 @@ -use std::mem::size_of; use std::num::NonZeroU64; use thiserror::Error; diff --git a/wgpu-core/src/init_tracker/mod.rs b/wgpu-core/src/init_tracker/mod.rs index 15a79bf520..ec0c86c608 100644 --- a/wgpu-core/src/init_tracker/mod.rs +++ b/wgpu-core/src/init_tracker/mod.rs @@ -247,7 +247,6 @@ where impl InitTracker { // Makes a single entry uninitialized if not already uninitialized - #[allow(dead_code)] pub(crate) fn discard(&mut self, pos: u32) { // first range where end>=idx let r_idx = self.uninitialized_ranges.partition_point(|r| r.end < pos); diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index c19a51d58e..279da5e6da 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -55,7 +55,6 @@ fn downlevel_default_limits_less_than_default_limits() { #[derive(Default)] pub struct Instance { - #[allow(dead_code)] pub name: String, /// List of instances per backend. /// @@ -611,7 +610,6 @@ impl Adapter { } } - #[allow(clippy::type_complexity)] fn create_device_and_queue_from_hal( self: &Arc, hal_device: hal::DynOpenDevice, diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index 47aaa87a51..05c280cb3e 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -32,15 +32,13 @@ clippy::needless_update, // Need many arguments for some core functions to be able to re-use code in many situations. clippy::too_many_arguments, - // For some reason `rustc` can warn about these in const generics even - // though they are required. - unused_braces, // It gets in the way a lot and does not prevent bugs in practice. clippy::pattern_type_mismatch, // `wgpu-core` isn't entirely user-facing, so it's useful to document internal items. rustdoc::private_intra_doc_links )] #![warn( + clippy::allow_attributes, clippy::ptr_as_ptr, trivial_casts, trivial_numeric_casts, diff --git a/wgpu-core/src/lock/mod.rs b/wgpu-core/src/lock/mod.rs index 2927bf3aaf..f52617bb98 100644 --- a/wgpu-core/src/lock/mod.rs +++ b/wgpu-core/src/lock/mod.rs @@ -33,13 +33,13 @@ pub mod rank; -#[cfg_attr(not(wgpu_validate_locks), allow(dead_code))] +#[cfg_attr(not(wgpu_validate_locks), expect(dead_code))] mod ranked; #[cfg(feature = "observe_locks")] mod observing; -#[cfg_attr(any(wgpu_validate_locks, feature = "observe_locks"), allow(dead_code))] +#[cfg_attr(any(wgpu_validate_locks, feature = "observe_locks"), expect(dead_code))] mod vanilla; #[cfg(wgpu_validate_locks)] diff --git a/wgpu-core/src/lock/observing.rs b/wgpu-core/src/lock/observing.rs index c530a56539..855d4f1dc1 100644 --- a/wgpu-core/src/lock/observing.rs +++ b/wgpu-core/src/lock/observing.rs @@ -336,7 +336,6 @@ struct ObservationLog { buffer: Vec, } -#[allow(trivial_casts)] impl ObservationLog { /// Create an observation log in `dir` for the current pid and thread. fn create(dir: impl AsRef) -> Result { diff --git a/wgpu-core/src/lock/rank.rs b/wgpu-core/src/lock/rank.rs index 652165ebda..342dc1b195 100644 --- a/wgpu-core/src/lock/rank.rs +++ b/wgpu-core/src/lock/rank.rs @@ -49,7 +49,7 @@ macro_rules! define_lock_ranks { )* } => { // An enum that assigns a unique number to each rank. - #[allow(non_camel_case_types, clippy::upper_case_acronyms)] + #[expect(non_camel_case_types, clippy::upper_case_acronyms)] enum LockRankNumber { $( $name, )* } bitflags::bitflags! { @@ -72,7 +72,7 @@ macro_rules! define_lock_ranks { } } - #[cfg_attr(not(feature = "observe_locks"), allow(dead_code))] + #[cfg_attr(not(feature = "observe_locks"), expect(dead_code))] pub fn const_name(self) -> &'static str { match self { $( @@ -132,7 +132,6 @@ define_lock_ranks! { rank BUFFER_INITIALIZATION_STATUS "Buffer::initialization_status" followed by { } rank DEVICE_DEFERRED_DESTROY "Device::deferred_destroy" followed by { } rank DEVICE_FENCE "Device::fence" followed by { } - #[allow(dead_code)] rank DEVICE_TRACE "Device::trace" followed by { } rank DEVICE_TRACKERS "Device::trackers" followed by { } rank DEVICE_LOST_CLOSURE "Device::device_lost_closure" followed by { } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 32e2378029..45a382b640 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -21,7 +21,7 @@ pub(crate) struct LateSizedBufferGroup { pub(crate) shader_sizes: Vec, } -#[allow(clippy::large_enum_variant)] +#[expect(clippy::large_enum_variant)] pub enum ShaderModuleSource<'a> { #[cfg(feature = "wgsl")] Wgsl(Cow<'a, str>), diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index e506d2cd5b..057223fb57 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -1,5 +1,3 @@ -use std::mem::size_of; - use thiserror::Error; use wgt::AdapterInfo; diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index b3349235e9..aded1a3c72 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of, sync::Arc}; +use std::sync::Arc; use crate::{ id::Id, diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 73435fc312..8af8aca9eb 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -677,7 +677,7 @@ impl Buffer { range, host, } => { - #[allow(clippy::collapsible_if)] + #[cfg_attr(not(feature = "trace"), expect(clippy::collapsible_if))] if host == HostMap::Write { #[cfg(feature = "trace")] if let Some(ref mut trace) = *device.trace.lock() { @@ -929,7 +929,7 @@ impl StagingBuffer { pub(crate) fn flush(self) -> FlushedStagingBuffer { let device = self.device.raw(); if !self.is_coherent { - #[allow(clippy::single_range_in_vec_init)] + #[expect(clippy::single_range_in_vec_init)] unsafe { device.flush_mapped_ranges(self.raw.as_ref(), &[0..self.size.get()]) }; diff --git a/wgpu-core/src/track/metadata.rs b/wgpu-core/src/track/metadata.rs index 8f03caf7b0..8e33fffa7d 100644 --- a/wgpu-core/src/track/metadata.rs +++ b/wgpu-core/src/track/metadata.rs @@ -41,7 +41,6 @@ impl ResourceMetadata { /// sanity checks of the presence of a refcount. /// /// In release mode this function is completely empty and is removed. - #[cfg_attr(not(feature = "strict_asserts"), allow(unused_variables))] pub(super) fn tracker_assert_in_bounds(&self, index: usize) { strict_assert!(index < self.owned.len()); strict_assert!(index < self.resources.len()); diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 2fd1e14959..026f0522f3 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -54,7 +54,7 @@ impl From<&BindingType> for BindingTypeName { #[derive(Debug)] struct Resource { - #[allow(unused)] + #[expect(unused)] name: Option, bind: naga::ResourceBinding, ty: ResourceType, @@ -139,7 +139,7 @@ enum Varying { BuiltIn(naga::BuiltIn), } -#[allow(unused)] +#[expect(unused)] #[derive(Debug)] struct SpecializationConstant { id: u32, @@ -151,7 +151,7 @@ struct EntryPoint { inputs: Vec, outputs: Vec, resources: Vec>, - #[allow(unused)] + #[expect(unused)] spec_constants: Vec, sampling_pairs: FastHashSet<(naga::Handle, naga::Handle)>, workgroup_size: [u32; 3], diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index e3056e2c77..2cf4e8320a 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # 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" [package.metadata.docs.rs] # Ideally we would enable all the features. diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 778cad0e0e..7a446bd744 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -14,9 +14,7 @@ use winit::{ use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; @@ -63,7 +61,7 @@ impl ExecutionContext { } } -#[allow(dead_code)] +#[expect(dead_code, reason = "Some fields are kept for `Drop`ping later.")] struct Example { instance: A::Instance, adapter: A::Adapter, diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index 79984ae43e..c6204226a4 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -8,9 +8,7 @@ use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use glam::{Affine3A, Mat4, Vec3}; use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; use wgpu_types::Dx12BackendOptions; @@ -48,7 +46,7 @@ impl std::fmt::Debug for AccelerationStructureInstance { } } -#[allow(dead_code)] +#[expect(dead_code, reason = "Some fields are kept for `Drop`ping later.")] impl AccelerationStructureInstance { const LOW_24_MASK: u32 = 0x00ff_ffff; const MAX_U24: u32 = (1u32 << 24u32) - 1u32; @@ -192,7 +190,7 @@ impl ExecutionContext { } } -#[allow(dead_code)] +#[expect(dead_code, reason = "Some fields are kept for `Drop`ping later.")] struct Example { instance: A::Instance, adapter: A::Adapter, @@ -311,7 +309,7 @@ impl Example { surface.configure(&device, &surface_config).unwrap(); }; - #[allow(dead_code)] + #[expect(dead_code)] struct Uniforms { view_inverse: glam::Mat4, proj_inverse: glam::Mat4, diff --git a/wgpu-hal/src/auxil/dxgi/time.rs b/wgpu-hal/src/auxil/dxgi/time.rs index 1b312fd651..296770074e 100644 --- a/wgpu-hal/src/auxil/dxgi/time.rs +++ b/wgpu-hal/src/auxil/dxgi/time.rs @@ -12,7 +12,7 @@ pub enum PresentationTimer { /// /// [`IPresentationManager`]: https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/Graphics/CompositionSwapchain/struct.IPresentationManager.html /// [`QueryInterruptTimePrecise()`]: https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/System/WindowsProgramming/fn.QueryInterruptTimePrecise.html - #[allow(non_snake_case)] + #[expect(non_snake_case)] IPresentationManager { fnQueryInterruptTimePrecise: unsafe extern "system" fn(*mut u64), }, @@ -62,7 +62,11 @@ impl PresentationTimer { let kernelbase = libloading::os::windows::Library::open_already_loaded("kernelbase.dll").unwrap(); // No concerns about lifetimes here as kernelbase is always there. - let ptr = unsafe { kernelbase.get(b"QueryInterruptTimePrecise\0").unwrap() }; + let ptr = unsafe { + kernelbase + .get(c"QueryInterruptTimePrecise".to_bytes()) + .unwrap() + }; Self::IPresentationManager { fnQueryInterruptTimePrecise: *ptr, } diff --git a/wgpu-hal/src/auxil/renderdoc.rs b/wgpu-hal/src/auxil/renderdoc.rs index 3879bb9545..a18c63aed5 100644 --- a/wgpu-hal/src/auxil/renderdoc.rs +++ b/wgpu-hal/src/auxil/renderdoc.rs @@ -69,7 +69,7 @@ impl RenderDoc { }; let get_api: libloading::Symbol = - match unsafe { renderdoc_lib.get(b"RENDERDOC_GetAPI\0") } { + match unsafe { renderdoc_lib.get(c"RENDERDOC_GetAPI".to_bytes()) } { Ok(api) => api, Err(e) => { return RenderDoc::NotAvailable { diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 52ec89ebb9..1d7c5bb71c 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -1,9 +1,4 @@ -use std::{ - mem::{size_of, size_of_val}, - ptr, - sync::Arc, - thread, -}; +use std::{ptr, sync::Arc, thread}; use parking_lot::Mutex; use windows::{ diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index 914eaa62a3..768fea7ede 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -743,7 +743,6 @@ impl crate::CommandEncoder for super::CommandEncoder { }); let list = self.list.as_ref().unwrap(); - #[allow(trivial_casts)] // No other clean way to write the coercion inside .map() below? unsafe { list.OMSetRenderTargets( desc.color_attachments.len() as u32, diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index e5a1b738f2..249ef47f26 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1,7 +1,6 @@ use std::{ borrow::Cow, - ffi, - mem::{self, size_of, size_of_val}, + ffi, mem, num::NonZeroU32, ptr, slice, sync::Arc, @@ -29,7 +28,7 @@ use crate::{ }; // this has to match Naga's HLSL backend, and also needs to be null-terminated -const NAGA_LOCATION_SEMANTIC: &[u8] = b"LOC\0"; +const NAGA_LOCATION_SEMANTIC: &[u8] = c"LOC".to_bytes(); impl super::Device { pub(super) fn new( diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 3a87e2617a..d20f2e1f7e 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of_val, sync::Arc}; +use std::sync::Arc; use parking_lot::RwLock; use windows::{ @@ -34,7 +34,6 @@ impl crate::Instance for super::Instance { .flags .intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION) { - #[allow(clippy::collapsible_if)] if let Ok(debug1) = debug_controller.cast::() { unsafe { debug1.SetEnableGPUBasedValidation(true) } } else { diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index d5d6843c39..aeacc80774 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -156,7 +156,8 @@ impl D3D12Lib { riid: *const windows_core::GUID, ppdevice: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"D3D12CreateDevice\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"D3D12CreateDevice".to_bytes()) }?; let mut result__: Option = None; @@ -197,7 +198,7 @@ impl D3D12Lib { pperrorblob: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; let func: libloading::Symbol = - unsafe { self.lib.get(b"D3D12SerializeRootSignature\0") }?; + unsafe { self.lib.get(c"D3D12SerializeRootSignature".to_bytes()) }?; let desc = Direct3D12::D3D12_ROOT_SIGNATURE_DESC { NumParameters: parameters.len() as _, @@ -236,7 +237,8 @@ impl D3D12Lib { riid: *const windows_core::GUID, ppvdebug: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"D3D12GetDebugInterface\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"D3D12GetDebugInterface".to_bytes()) }?; let mut result__ = None; @@ -273,7 +275,8 @@ impl DxgiLib { riid: *const windows_core::GUID, pdebug: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"DXGIGetDebugInterface1\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"DXGIGetDebugInterface1".to_bytes()) }?; let mut result__ = None; @@ -302,7 +305,8 @@ impl DxgiLib { riid: *const windows_core::GUID, ppfactory: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"CreateDXGIFactory2\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"CreateDXGIFactory2".to_bytes()) }?; let mut result__ = None; @@ -324,7 +328,8 @@ impl DxgiLib { riid: *const windows_core::GUID, ppfactory: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"CreateDXGIFactory1\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"CreateDXGIFactory1".to_bytes()) }?; let mut result__ = None; @@ -542,7 +547,7 @@ unsafe impl Sync for Surface {} #[derive(Debug, Clone, Copy)] enum MemoryArchitecture { Unified { - #[allow(unused)] + #[expect(unused)] cache_coherent: bool, }, NonUnified, @@ -551,7 +556,7 @@ enum MemoryArchitecture { #[derive(Debug, Clone, Copy)] struct PrivateCapabilities { instance_flags: wgt::InstanceFlags, - #[allow(unused)] + #[expect(unused)] heterogeneous_resource_heaps: bool, memory_architecture: MemoryArchitecture, heap_create_not_zeroed: bool, @@ -574,8 +579,7 @@ pub struct Adapter { library: Arc, private_caps: PrivateCapabilities, presentation_timer: auxil::dxgi::time::PresentationTimer, - // Note: this isn't used right now, but we'll need it later. - #[allow(unused)] + #[expect(unused, reason = "This isn't used right now, but we'll need it later.")] workarounds: Workarounds, dxc_container: Option>, } diff --git a/wgpu-hal/src/dx12/shader_compilation.rs b/wgpu-hal/src/dx12/shader_compilation.rs index 81e51b83d1..3df2f037ad 100644 --- a/wgpu-hal/src/dx12/shader_compilation.rs +++ b/wgpu-hal/src/dx12/shader_compilation.rs @@ -112,7 +112,7 @@ impl DxcLib { -> windows_core::HRESULT; let func: libloading::Symbol = - self.lib.get(b"DxcCreateInstance\0")?; + self.lib.get(c"DxcCreateInstance".to_bytes())?; dxc_create_instance::(|clsid, iid, ppv| func(clsid, iid, ppv)) } } @@ -213,7 +213,7 @@ pub(super) fn get_static_dxc_container() -> Result, } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 85bae59457..684d4aa633 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -201,7 +201,9 @@ impl super::Adapter { // emscripten doesn't enable "WEBGL_debug_renderer_info" extension by default. so, we do it manually. // See https://github.com/gfx-rs/wgpu/issues/3245 for context #[cfg(Emscripten)] - if unsafe { super::emscripten::enable_extension("WEBGL_debug_renderer_info\0") } { + if unsafe { + super::emscripten::enable_extension(c"WEBGL_debug_renderer_info".to_str().unwrap()) + } { (GL_UNMASKED_VENDOR_WEBGL, GL_UNMASKED_RENDERER_WEBGL) } else { (glow::VENDOR, glow::RENDERER) diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index b706c116e8..1f6ea5ebad 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -1,9 +1,6 @@ use super::{conv, Command as C}; use arrayvec::ArrayVec; -use std::{ - mem::{self, size_of, size_of_val}, - ops::Range, -}; +use std::{mem, ops::Range}; #[derive(Clone, Copy, Debug, Default)] struct TextureSlotDesc { @@ -226,7 +223,6 @@ impl super::CommandEncoder { } } - #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation fn set_pipeline_inner(&mut self, inner: &super::PipelineInner) { self.cmd_buffer.commands.push(C::SetProgram(inner.program)); @@ -1038,7 +1034,7 @@ impl crate::CommandEncoder for super::CommandEncoder { instance_count: u32, ) { self.prepare_draw(first_instance); - #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation + #[expect(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::Draw { topology: self.state.topology, first_vertex, @@ -1062,7 +1058,7 @@ impl crate::CommandEncoder for super::CommandEncoder { wgt::IndexFormat::Uint32 => (4, glow::UNSIGNED_INT), }; let index_offset = self.state.index_offset + index_size * first_index as wgt::BufferAddress; - #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation + #[expect(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::DrawIndexed { topology: self.state.topology, index_type, @@ -1084,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder { for draw in 0..draw_count as wgt::BufferAddress { let indirect_offset = offset + draw * size_of::() as wgt::BufferAddress; - #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation + #[expect(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::DrawIndirect { topology: self.state.topology, indirect_buf: buffer.raw.unwrap(), @@ -1107,7 +1103,7 @@ impl crate::CommandEncoder for super::CommandEncoder { for draw in 0..draw_count as wgt::BufferAddress { let indirect_offset = offset + draw * size_of::() as wgt::BufferAddress; - #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation + #[expect(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::DrawIndexedIndirect { topology: self.state.topology, index_type, diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index a9d6209afb..47443ddfcf 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -1569,7 +1569,7 @@ impl crate::Device for super::Device { self.render_doc .start_frame_capture(self.shared.context.raw_context(), ptr::null_mut()) }; - #[allow(unreachable_code)] + #[cfg(not(all(native, feature = "renderdoc")))] false } unsafe fn stop_capture(&self) { diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index b7d9868609..46b1dccde6 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,9 +1,16 @@ use glow::HasContext; use hashbrown::HashMap; -use once_cell::sync::Lazy; use parking_lot::{MappedMutexGuard, Mutex, MutexGuard, RwLock}; -use std::{ffi, mem::ManuallyDrop, os::raw, ptr, rc::Rc, sync::Arc, time::Duration}; +use std::{ + ffi, + mem::ManuallyDrop, + os::raw, + ptr, + rc::Rc, + sync::{Arc, LazyLock}, + time::Duration, +}; /// The amount of time to wait while trying to obtain a lock to the adapter context const CONTEXT_LOCK_TIMEOUT_SECS: u64 = 1; @@ -54,7 +61,7 @@ type WlEglWindowDestroyFun = unsafe extern "system" fn(window: *const raw::c_voi type EglLabel = *const raw::c_void; -#[allow(clippy::upper_case_acronyms)] +#[expect(clippy::upper_case_acronyms)] type EGLDEBUGPROCKHR = Option< unsafe extern "system" fn( error: khronos_egl::Enum, @@ -142,7 +149,7 @@ impl Drop for DisplayOwner { match self.display { DisplayRef::X11(ptr) => unsafe { let func: libloading::Symbol = - self.library.get(b"XCloseDisplay\0").unwrap(); + self.library.get(c"XCloseDisplay".to_bytes()).unwrap(); func(ptr.as_ptr()); }, DisplayRef::Wayland => {} @@ -154,7 +161,8 @@ fn open_x_display() -> Option { log::debug!("Loading X11 library to get the current display"); unsafe { let library = find_library(&["libX11.so.6", "libX11.so"])?; - let func: libloading::Symbol = library.get(b"XOpenDisplay\0").unwrap(); + let func: libloading::Symbol = + library.get(c"XOpenDisplay".to_bytes()).unwrap(); let result = func(ptr::null()); ptr::NonNull::new(result).map(|ptr| DisplayOwner { display: DisplayRef::X11(ptr), @@ -180,10 +188,12 @@ fn test_wayland_display() -> Option { log::debug!("Loading Wayland library to get the current display"); let library = unsafe { let client_library = find_library(&["libwayland-client.so.0", "libwayland-client.so"])?; - let wl_display_connect: libloading::Symbol = - client_library.get(b"wl_display_connect\0").unwrap(); - let wl_display_disconnect: libloading::Symbol = - client_library.get(b"wl_display_disconnect\0").unwrap(); + let wl_display_connect: libloading::Symbol = client_library + .get(c"wl_display_connect".to_bytes()) + .unwrap(); + let wl_display_disconnect: libloading::Symbol = client_library + .get(c"wl_display_disconnect".to_bytes()) + .unwrap(); let display = ptr::NonNull::new(wl_display_connect(ptr::null()))?; wl_display_disconnect(display.as_ptr()); find_library(&["libwayland-egl.so.1", "libwayland-egl.so"])? @@ -450,7 +460,6 @@ struct Inner { /// Note: the context contains a dummy pbuffer (1x1). /// Required for `eglMakeCurrent` on platforms that doesn't supports `EGL_KHR_surfaceless_context`. egl: EglContext, - #[allow(unused)] version: (i32, i32), supports_native_window: bool, config: khronos_egl::Config, @@ -465,7 +474,8 @@ struct Inner { // Different calls to `eglGetPlatformDisplay` may return the same `Display`, making it a global // state of all our `EglContext`s. This forces us to track the number of such context to prevent // terminating the display if it's currently used by another `EglContext`. -static DISPLAYS_REFERENCE_COUNT: Lazy>> = Lazy::new(Default::default); +static DISPLAYS_REFERENCE_COUNT: LazyLock>> = + LazyLock::new(Default::default); fn initialize_display( egl: &EglInstance, @@ -882,7 +892,7 @@ impl crate::Instance for Instance { (display, Some(Rc::new(display_owner)), WindowKind::AngleX11) } else if client_ext_str.contains("EGL_MESA_platform_surfaceless") { log::warn!("No windowing system present. Using surfaceless platform"); - #[allow(clippy::unnecessary_literal_unwrap)] // This is only a literal on Emscripten + #[cfg_attr(Emscripten, expect(clippy::unnecessary_literal_unwrap))] let egl = egl1_5.expect("Failed to get EGL 1.5 for surfaceless"); let display = unsafe { egl.get_platform_display( @@ -940,7 +950,6 @@ impl crate::Instance for Instance { }) } - #[cfg_attr(target_os = "macos", allow(unused, unused_mut, unreachable_code))] unsafe fn create_surface( &self, display_handle: raw_window_handle::RawDisplayHandle, @@ -948,7 +957,7 @@ impl crate::Instance for Instance { ) -> Result { use raw_window_handle::RawWindowHandle as Rwh; - #[cfg_attr(any(target_os = "android", Emscripten), allow(unused_mut))] + #[cfg_attr(Emscripten, expect(unused_mut))] let mut inner = self.inner.lock(); match (window_handle, display_handle) { @@ -1156,7 +1165,7 @@ pub struct Swapchain { extent: wgt::Extent3d, format: wgt::TextureFormat, format_desc: super::TextureFormatDesc, - #[allow(unused)] + #[expect(unused)] sample_type: wgt::TextureSampleType, } @@ -1309,7 +1318,7 @@ impl crate::Surface for Surface { (WindowKind::Wayland, Rwh::Wayland(handle)) => { let library = &self.wsi.display_owner.as_ref().unwrap().library; let wl_egl_window_create: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_create\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_create".to_bytes()) }.unwrap(); let window = unsafe { wl_egl_window_create(handle.surface.as_ptr(), 640, 480) } .cast(); @@ -1418,7 +1427,7 @@ impl crate::Surface for Surface { if let Some(window) = wl_window { let library = &self.wsi.display_owner.as_ref().unwrap().library; let wl_egl_window_resize: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_resize\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_resize".to_bytes()) }.unwrap(); unsafe { wl_egl_window_resize( window, @@ -1490,7 +1499,7 @@ impl crate::Surface for Surface { .expect("unsupported window") .library; let wl_egl_window_destroy: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_destroy\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_destroy".to_bytes()) }.unwrap(); unsafe { wl_egl_window_destroy(window) }; } } diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 478f2c433c..2e5fc73f51 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -394,7 +394,6 @@ pub struct Texture { pub mip_level_count: u32, pub array_layer_count: u32, pub format: wgt::TextureFormat, - #[allow(unused)] pub format_desc: TextureFormatDesc, pub copy_size: CopyExtent, } @@ -868,7 +867,7 @@ enum Command { }, CopyBufferToTexture { src: Buffer, - #[allow(unused)] + #[expect(unused)] src_target: BindTarget, dst: glow::Texture, dst_target: BindTarget, @@ -880,7 +879,7 @@ enum Command { src_target: BindTarget, src_format: wgt::TextureFormat, dst: Buffer, - #[allow(unused)] + #[expect(unused)] dst_target: BindTarget, copy: crate::BufferTextureCopy, }, diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 1be46ceed2..0cd5f93b10 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -2,7 +2,6 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities}; use arrayvec::ArrayVec; use glow::HasContext; use std::{ - mem::size_of, slice, sync::{atomic::Ordering, Arc}, }; diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 41759f3817..552965a266 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -1,11 +1,11 @@ use std::{ ffi::{c_void, CStr, CString}, - mem::{self, size_of, size_of_val, ManuallyDrop}, + mem::{self, ManuallyDrop}, os::raw::c_int, ptr, sync::{ mpsc::{sync_channel, SyncSender}, - Arc, + Arc, LazyLock, }, thread, time::Duration, @@ -17,7 +17,6 @@ use glutin_wgl_sys::wgl_extra::{ CONTEXT_PROFILE_MASK_ARB, }; use hashbrown::HashSet; -use once_cell::sync::Lazy; use parking_lot::{Mutex, MutexGuard, RwLock}; use raw_window_handle::{RawDisplayHandle, RawWindowHandle}; use wgt::InstanceFlags; @@ -320,8 +319,8 @@ fn create_global_window_class() -> Result { } fn get_global_window_class() -> Result { - static GLOBAL: Lazy> = - Lazy::new(create_global_window_class); + static GLOBAL: LazyLock> = + LazyLock::new(create_global_window_class); GLOBAL.clone() } @@ -435,14 +434,13 @@ impl crate::Instance for Instance { unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init OpenGL (WGL) Backend"); let opengl_module = - unsafe { LibraryLoader::LoadLibraryA(PCSTR("opengl32.dll\0".as_ptr())) }.map_err( - |e| { + unsafe { LibraryLoader::LoadLibraryA(PCSTR(c"opengl32.dll".as_ptr().cast())) } + .map_err(|e| { crate::InstanceError::with_source( String::from("unable to load the OpenGL library"), e, ) - }, - )?; + })?; let device = create_instance_device()?; let dc = device.dc; @@ -650,7 +648,7 @@ pub struct Swapchain { format: wgt::TextureFormat, format_desc: super::TextureFormatDesc, - #[allow(unused)] + #[expect(unused)] sample_type: wgt::TextureSampleType, } diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 997119b79c..cac91fd605 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -226,6 +226,7 @@ clippy::pattern_type_mismatch, )] #![warn( + clippy::allow_attributes, clippy::ptr_as_ptr, trivial_casts, trivial_numeric_casts, @@ -351,13 +352,13 @@ pub enum DeviceError { Unexpected, } -#[allow(dead_code)] // may be unused on some platforms +#[cfg_attr(not(any(vulkan, dx12)), expect(dead_code))] #[cold] fn hal_usage_error(txt: T) -> ! { panic!("wgpu-hal invariant was violated (usage error): {txt}") } -#[allow(dead_code)] // may be unused on some platforms +#[cfg_attr(not(dx12), expect(dead_code))] #[cold] fn hal_internal_error(txt: T) -> ! { panic!("wgpu-hal ran into a preventable internal error: {txt}") @@ -419,14 +420,14 @@ pub struct InstanceError { } impl InstanceError { - #[allow(dead_code)] // may be unused on some platforms + #[cfg_attr(not(any(gles, vulkan, metal)), expect(dead_code))] pub(crate) fn new(message: String) -> Self { Self { message, source: None, } } - #[allow(dead_code)] // may be unused on some platforms + #[cfg_attr(not(any(gles, vulkan, metal)), expect(dead_code))] pub(crate) fn with_source( message: String, source: impl std::error::Error + Send + Sync + 'static, @@ -857,7 +858,7 @@ pub trait Device: WasmNotSendSync { ) -> Result<::PipelineLayout, DeviceError>; unsafe fn destroy_pipeline_layout(&self, pipeline_layout: ::PipelineLayout); - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] unsafe fn create_bind_group( &self, desc: &BindGroupDescriptor< @@ -877,7 +878,7 @@ pub trait Device: WasmNotSendSync { ) -> Result<::ShaderModule, ShaderError>; unsafe fn destroy_shader_module(&self, module: ::ShaderModule); - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] unsafe fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor< @@ -888,7 +889,7 @@ pub trait Device: WasmNotSendSync { ) -> Result<::RenderPipeline, PipelineError>; unsafe fn destroy_render_pipeline(&self, pipeline: ::RenderPipeline); - #[allow(clippy::type_complexity)] + #[expect(clippy::type_complexity)] unsafe fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor< @@ -948,7 +949,7 @@ pub trait Device: WasmNotSendSync { unsafe fn start_capture(&self) -> bool; unsafe fn stop_capture(&self); - #[allow(unused_variables)] + #[expect(unused_variables)] unsafe fn pipeline_cache_get_data( &self, cache: &::PipelineCache, @@ -2013,7 +2014,6 @@ impl fmt::Debug for NagaShader { } /// Shader input. -#[allow(clippy::large_enum_variant)] pub enum ShaderInput<'a> { Naga(NagaShader), SpirV(&'a [u32]), @@ -2288,7 +2288,7 @@ pub struct ValidationCanary { } impl ValidationCanary { - #[allow(dead_code)] // in some configurations this function is dead + #[cfg_attr(not(any(gles, vulkan, dx12)), expect(dead_code))] fn add(&self, msg: String) { self.inner.lock().push(msg); } diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index dae4cb3322..69ca728bef 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -511,7 +511,6 @@ impl super::PrivateCapabilities { pub fn new(device: &metal::Device) -> Self { #[repr(C)] #[derive(Clone, Copy, Debug)] - #[allow(clippy::upper_case_acronyms)] struct NSOperatingSystemVersion { major: usize, minor: usize, diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index c3f2c8cc59..b951ab9826 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -1,6 +1,6 @@ use super::{conv, AsNative, TimestampQuerySupport}; use crate::CommandEncoder as _; -use std::{borrow::Cow, mem::size_of, ops::Range}; +use std::{borrow::Cow, ops::Range}; // has to match `Temp::binding_sizes` const WORD_SIZE: usize = 4; diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index 8a3ff41bbe..c75d380530 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -17,7 +17,7 @@ end of the VS buffer table. // However, `MTLGpuFamily` is only supported starting MacOS 10.15, whereas our minimum target is MacOS 10.13, // See https://github.com/gpuweb/gpuweb/issues/1069 for minimum spec. // TODO: Eventually all deprecated features should be abstracted and use new api when available. -#[allow(deprecated)] +#[expect(deprecated)] mod adapter; mod command; mod conv; @@ -190,7 +190,7 @@ bitflags!( } ); -#[allow(dead_code)] +#[expect(dead_code)] #[derive(Clone, Debug)] struct PrivateCapabilities { family_check: bool, @@ -300,7 +300,7 @@ struct PrivateDisabilities { /// Near depth is not respected properly on some Intel GPUs. broken_viewport_near_depth: bool, /// Multi-target clears don't appear to work properly on Intel GPUs. - #[allow(dead_code)] + #[expect(dead_code)] broken_layered_clear_image: bool, } @@ -816,9 +816,8 @@ impl PipelineStageInfo { #[derive(Debug)] pub struct RenderPipeline { raw: metal::RenderPipelineState, - #[allow(dead_code)] + #[expect(dead_code)] vs_lib: metal::Library, - #[allow(dead_code)] fs_lib: Option, vs_info: PipelineStageInfo, fs_info: Option, @@ -838,7 +837,7 @@ impl crate::DynRenderPipeline for RenderPipeline {} #[derive(Debug)] pub struct ComputePipeline { raw: metal::ComputePipelineState, - #[allow(dead_code)] + #[expect(dead_code)] cs_lib: metal::Library, cs_info: PipelineStageInfo, work_group_size: metal::MTLSize, diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 5f4bcaeb81..b23d79f1a4 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -22,7 +22,6 @@ use parking_lot::{Mutex, RwLock}; #[link(name = "QuartzCore", kind = "framework")] extern "C" { - #[allow(non_upper_case_globals)] static kCAGravityResize: *mut Object; } @@ -73,7 +72,6 @@ impl super::Surface { } /// If not called on the main thread, this will panic. - #[allow(clippy::transmute_ptr_to_ref)] pub unsafe fn from_view(view: NonNull) -> Self { let layer = unsafe { Self::get_metal_layer(view) }; let layer = ManuallyDrop::new(layer); diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 61020c2a34..3356c64734 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1712,7 +1712,7 @@ impl super::Adapter { /// - `enabled_extensions` must be a superset of `required_device_extensions()`. /// - If `drop_callback` is [`None`], wgpu-hal will take ownership of `raw_device`. If /// `drop_callback` is [`Some`], `raw_device` must be valid until the callback is called. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub unsafe fn device_from_raw( &self, raw_device: ash::Device, diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 8e5f243ee5..369b73036d 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -3,11 +3,7 @@ use super::conv; use arrayvec::ArrayVec; use ash::vk; -use std::{ - mem::{self, size_of}, - ops::Range, - slice, -}; +use std::{mem, ops::Range, slice}; const ALLOCATION_GRANULARITY: u32 = 16; const DST_IMAGE_LAYOUT: vk::ImageLayout = vk::ImageLayout::TRANSFER_DST_OPTIMAL; diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index bba28939f7..d527e0031e 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -10,7 +10,7 @@ use std::{ borrow::Cow, collections::BTreeMap, ffi::{CStr, CString}, - mem::{self, size_of, MaybeUninit}, + mem::{self, MaybeUninit}, num::NonZeroU32, ptr, slice, sync::Arc, diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index d6ca55800d..037278d7f7 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -30,8 +30,7 @@ unsafe extern "system" fn debug_utils_messenger_callback( // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671 // Versions 1.3.240 through 1.3.250 return a spurious error here if // the debug range start and end appear in different command buffers. - const KHRONOS_VALIDATION_LAYER: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"Khronos Validation Layer\0") }; + const KHRONOS_VALIDATION_LAYER: &CStr = c"Khronos Validation Layer"; if let Some(layer_properties) = user_data.validation_layer_properties.as_ref() { if layer_properties.layer_description.as_ref() == KHRONOS_VALIDATION_LAYER && layer_properties.layer_spec_version >= vk::make_api_version(0, 1, 3, 240) @@ -323,7 +322,7 @@ impl super::Instance { /// /// If `debug_utils_user_data` is `Some`, then the validation layer is /// available, so create a [`vk::DebugUtilsMessengerEXT`]. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub unsafe fn from_raw( entry: ash::Entry, raw_instance: ash::Instance, @@ -607,7 +606,7 @@ impl crate::Instance for super::Instance { let app_info = vk::ApplicationInfo::default() .application_name(app_name.as_c_str()) .application_version(1) - .engine_name(CStr::from_bytes_with_nul(b"wgpu-hal\0").unwrap()) + .engine_name(c"wgpu-hal") .engine_version(2) .api_version( // Vulkan 1.0 doesn't like anything but 1.0 passed in here... @@ -649,8 +648,7 @@ impl crate::Instance for super::Instance { .find(|inst_layer| inst_layer.layer_name_as_c_str() == Ok(name)) } - let validation_layer_name = - CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap(); + let validation_layer_name = c"VK_LAYER_KHRONOS_validation"; let validation_layer_properties = find_layer(&instance_layers, validation_layer_name); // Determine if VK_EXT_validation_features is available, so we can enable @@ -674,10 +672,10 @@ impl crate::Instance for super::Instance { .intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION) && validation_features_are_enabled; - let nv_optimus_layer = CStr::from_bytes_with_nul(b"VK_LAYER_NV_optimus\0").unwrap(); + let nv_optimus_layer = c"VK_LAYER_NV_optimus"; let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some(); - let obs_layer = CStr::from_bytes_with_nul(b"VK_LAYER_OBS_HOOK\0").unwrap(); + let obs_layer = c"VK_LAYER_OBS_HOOK"; let has_obs_layer = find_layer(&instance_layers, obs_layer).is_some(); let mut layers: Vec<&'static CStr> = Vec::new(); diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 4421d0a5ef..05581c29d1 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -116,7 +116,7 @@ struct DebugUtils { /// `InstanceShared::drop` destroys the debug messenger before /// dropping this, so the callback should never receive a dangling /// user data pointer. - #[allow(dead_code)] + #[expect(dead_code)] callback_data: Box, } @@ -975,7 +975,6 @@ pub struct CommandBuffer { impl crate::DynCommandBuffer for CommandBuffer {} #[derive(Debug)] -#[allow(clippy::large_enum_variant)] pub enum ShaderModule { Raw(vk::ShaderModule), Intermediate { @@ -1452,7 +1451,7 @@ fn get_unexpected_err(_err: vk::Result) -> crate::DeviceError { #[cfg(feature = "internal_error_panic")] panic!("Unexpected Vulkan error: {_err:?}"); - #[allow(unreachable_code)] + #[cfg_attr(feature = "internal_error_panic", expect(unreachable_code))] crate::DeviceError::Unexpected } @@ -1462,7 +1461,7 @@ fn get_oom_err(_err: vk::Result) -> crate::DeviceError { #[cfg(feature = "oom_panic")] panic!("Out of memory ({_err:?})"); - #[allow(unreachable_code)] + #[cfg_attr(feature = "oom_panic", expect(unreachable_code))] crate::DeviceError::OutOfMemory } @@ -1472,7 +1471,7 @@ fn get_lost_err() -> crate::DeviceError { #[cfg(feature = "device_lost_panic")] panic!("Device lost"); - #[allow(unreachable_code)] + #[cfg_attr(feature = "device_lost_panic", expect(unreachable_code))] crate::DeviceError::Lost } diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 653f988b7b..37d5c6beff 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # 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" [package.metadata.docs.rs] all-features = true diff --git a/wgpu-types/src/counters.rs b/wgpu-types/src/counters.rs index ff38b33c66..08ed4e40b4 100644 --- a/wgpu-types/src/counters.rs +++ b/wgpu-types/src/counters.rs @@ -103,7 +103,10 @@ impl core::fmt::Debug for InternalCounter { } /// `wgpu-hal`'s internal counters. -#[allow(missing_docs)] +#[expect( + missing_docs, + reason = "We don't feel the need to document individual fields here." +)] #[derive(Clone, Default)] pub struct HalCounters { // API objects diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 4645b4ac19..9ef10c5003 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -6,7 +6,12 @@ // We don't use syntax sugar where it's not necessary. clippy::match_like_matches_macro, )] -#![warn(clippy::ptr_as_ptr, missing_docs, unsafe_op_in_unsafe_fn)] +#![warn( + clippy::allow_attributes, + clippy::ptr_as_ptr, + missing_docs, + unsafe_op_in_unsafe_fn +)] #![no_std] #[cfg(feature = "std")] @@ -17,7 +22,6 @@ extern crate alloc; use alloc::{string::String, vec, vec::Vec}; use core::{ hash::{Hash, Hasher}, - mem::size_of, num::NonZeroU32, ops::Range, }; @@ -1533,7 +1537,7 @@ impl Limits { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DownlevelLimits {} -#[allow(clippy::derivable_impls)] +#[expect(clippy::derivable_impls)] impl Default for DownlevelLimits { fn default() -> Self { DownlevelLimits {} @@ -6046,7 +6050,7 @@ pub struct Color { pub a: f64, } -#[allow(missing_docs)] +#[expect(missing_docs)] impl Color { pub const TRANSPARENT: Self = Self { r: 0.0, @@ -6114,9 +6118,9 @@ pub enum TextureDimension { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct Origin2d { - #[allow(missing_docs)] + #[expect(missing_docs)] pub x: u32, - #[allow(missing_docs)] + #[expect(missing_docs)] pub y: u32, } diff --git a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs index b3b55f506b..d23b44065f 100644 --- a/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs +++ b/wgpu/src/backend/webgpu/webgpu_sys/gen_GpuCommandBufferDescriptor.rs @@ -63,7 +63,7 @@ impl GpuCommandBufferDescriptor { #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn new() -> Self { - #[allow(unused_mut)] + #[expect(unused_mut)] let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); ret }