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

Satisfy Rust 1.78's latest easy lints #5651

Merged
merged 5 commits into from
May 13, 2024
Merged
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
1 change: 0 additions & 1 deletion d3d12/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub struct DiscardRegion<'a> {
pub type Resource = ComPtr<d3d12::ID3D12Resource>;

impl Resource {
///
pub fn map(
&self,
subresource: Subresource,
Expand Down
2 changes: 1 addition & 1 deletion naga-cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn run() -> anyhow::Result<()> {
block_ctx_dump_prefix: args.block_ctx_dir.clone().map(std::path::PathBuf::from),
};

params.entry_point = args.entry_point.clone();
params.entry_point.clone_from(&args.entry_point);
if let Some(ref version) = args.profile {
params.glsl.version = version.0;
}
Expand Down
6 changes: 3 additions & 3 deletions naga/src/back/glsl/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl<'a, W> Writer<'a, W> {
}

// If the type of this global is a struct
if let crate::TypeInner::Struct { ref members, .. } =
if let TypeInner::Struct { ref members, .. } =
self.module.types[global.ty].inner
{
// Check the last element of the struct to see if it's type uses
Expand Down Expand Up @@ -472,7 +472,7 @@ impl<'a, W> Writer<'a, W> {
// layers queries are also implemented as size queries
crate::ImageQuery::Size { .. } | crate::ImageQuery::NumLayers => {
if let TypeInner::Image {
class: crate::ImageClass::Storage { .. }, ..
class: ImageClass::Storage { .. }, ..
} = *info[image].ty.inner_with(&module.types) {
features.request(Features::IMAGE_SIZE)
}
Expand Down Expand Up @@ -558,7 +558,7 @@ impl<'a, W> Writer<'a, W> {

fn varying_required_features(&mut self, binding: Option<&Binding>, ty: Handle<Type>) {
match self.module.types[ty].inner {
crate::TypeInner::Struct { ref members, .. } => {
TypeInner::Struct { ref members, .. } => {
for member in members {
self.varying_required_features(member.binding.as_ref(), member.ty);
}
Expand Down
38 changes: 19 additions & 19 deletions naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ impl<'a, W: Write> Writer<'a, W> {
self.reflection_names_globals.insert(handle, block_name);

match self.module.types[global.ty].inner {
crate::TypeInner::Struct { ref members, .. }
TypeInner::Struct { ref members, .. }
if self.module.types[members.last().unwrap().ty]
.inner
.is_dynamically_sized(&self.module.types) =>
Expand Down Expand Up @@ -1429,7 +1429,7 @@ impl<'a, W: Write> Writer<'a, W> {
output: bool,
) -> Result<(), Error> {
// For a struct, emit a separate global for each member with a binding.
if let crate::TypeInner::Struct { ref members, .. } = self.module.types[ty].inner {
if let TypeInner::Struct { ref members, .. } = self.module.types[ty].inner {
for member in members {
self.write_varying(member.binding.as_ref(), member.ty, output)?;
}
Expand Down Expand Up @@ -1701,7 +1701,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, " {name}")?;
write!(self.out, " = ")?;
match self.module.types[arg.ty].inner {
crate::TypeInner::Struct { ref members, .. } => {
TypeInner::Struct { ref members, .. } => {
self.write_type(arg.ty)?;
write!(self.out, "(")?;
for (index, member) in members.iter().enumerate() {
Expand Down Expand Up @@ -2186,7 +2186,7 @@ impl<'a, W: Write> Writer<'a, W> {
if let Some(ref result) = ep.function.result {
let value = value.unwrap();
match self.module.types[result.ty].inner {
crate::TypeInner::Struct { ref members, .. } => {
TypeInner::Struct { ref members, .. } => {
let temp_struct_name = match ctx.expressions[value] {
crate::Expression::Compose { .. } => {
let return_struct = "_tmp_return";
Expand Down Expand Up @@ -2968,7 +2968,7 @@ impl<'a, W: Write> Writer<'a, W> {
if let Some(expr) = level {
let cast_to_int = matches!(
*ctx.resolve_type(expr, &self.module.types),
crate::TypeInner::Scalar(crate::Scalar {
TypeInner::Scalar(crate::Scalar {
kind: crate::ScalarKind::Uint,
..
})
Expand Down Expand Up @@ -3311,7 +3311,7 @@ impl<'a, W: Write> Writer<'a, W> {
self.write_expr(arg, ctx)?;

match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Vector { size, .. } => write!(
TypeInner::Vector { size, .. } => write!(
self.out,
", vec{}(0.0), vec{0}(1.0)",
back::vector_size_str(size)
Expand Down Expand Up @@ -3358,15 +3358,15 @@ impl<'a, W: Write> Writer<'a, W> {
Mf::Pow => "pow",
// geometry
Mf::Dot => match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Vector {
TypeInner::Vector {
scalar:
crate::Scalar {
kind: crate::ScalarKind::Float,
..
},
..
} => "dot",
crate::TypeInner::Vector { size, .. } => {
TypeInner::Vector { size, .. } => {
return self.write_dot_product(arg, arg1.unwrap(), size as usize, ctx)
}
_ => unreachable!(
Expand Down Expand Up @@ -3418,7 +3418,7 @@ impl<'a, W: Write> Writer<'a, W> {
// bits
Mf::CountTrailingZeros => {
match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Vector { size, scalar, .. } => {
TypeInner::Vector { size, scalar, .. } => {
let s = back::vector_size_str(size);
if let crate::ScalarKind::Uint = scalar.kind {
write!(self.out, "min(uvec{s}(findLSB(")?;
Expand All @@ -3430,7 +3430,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, ")), uvec{s}(32u)))")?;
}
}
crate::TypeInner::Scalar(scalar) => {
TypeInner::Scalar(scalar) => {
if let crate::ScalarKind::Uint = scalar.kind {
write!(self.out, "min(uint(findLSB(")?;
self.write_expr(arg, ctx)?;
Expand All @@ -3448,7 +3448,7 @@ impl<'a, W: Write> Writer<'a, W> {
Mf::CountLeadingZeros => {
if self.options.version.supports_integer_functions() {
match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Vector { size, scalar } => {
TypeInner::Vector { size, scalar } => {
let s = back::vector_size_str(size);

if let crate::ScalarKind::Uint = scalar.kind {
Expand All @@ -3463,7 +3463,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, ", ivec{s}(0)))")?;
}
}
crate::TypeInner::Scalar(scalar) => {
TypeInner::Scalar(scalar) => {
if let crate::ScalarKind::Uint = scalar.kind {
write!(self.out, "uint(31 - findMSB(")?;
} else {
Expand All @@ -3479,7 +3479,7 @@ impl<'a, W: Write> Writer<'a, W> {
};
} else {
match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Vector { size, scalar } => {
TypeInner::Vector { size, scalar } => {
let s = back::vector_size_str(size);

if let crate::ScalarKind::Uint = scalar.kind {
Expand All @@ -3497,7 +3497,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, ", ivec{s}(0u))))")?;
}
}
crate::TypeInner::Scalar(scalar) => {
TypeInner::Scalar(scalar) => {
if let crate::ScalarKind::Uint = scalar.kind {
write!(self.out, "uint(31.0 - floor(log2(float(")?;
self.write_expr(arg, ctx)?;
Expand Down Expand Up @@ -3605,11 +3605,11 @@ impl<'a, W: Write> Writer<'a, W> {
// Check if the argument is an unsigned integer and return the vector size
// in case it's a vector
let maybe_uint_size = match *ctx.resolve_type(arg, &self.module.types) {
crate::TypeInner::Scalar(crate::Scalar {
TypeInner::Scalar(crate::Scalar {
kind: crate::ScalarKind::Uint,
..
}) => Some(None),
crate::TypeInner::Vector {
TypeInner::Vector {
scalar:
crate::Scalar {
kind: crate::ScalarKind::Uint,
Expand Down Expand Up @@ -4402,7 +4402,7 @@ impl<'a, W: Write> Writer<'a, W> {
continue;
}
match self.module.types[var.ty].inner {
crate::TypeInner::Image { .. } => {
TypeInner::Image { .. } => {
let tex_name = self.reflection_names_globals[&handle].clone();
match texture_mapping.entry(tex_name) {
Entry::Vacant(v) => {
Expand Down Expand Up @@ -4438,7 +4438,7 @@ impl<'a, W: Write> Writer<'a, W> {
//
// This is potentially a bit wasteful, but the set of types in the program
// shouldn't be too large.
let mut layouter = crate::proc::Layouter::default();
let mut layouter = proc::Layouter::default();
layouter.update(self.module.to_ctx()).unwrap();

// We start with the name of the binding itself.
Expand Down Expand Up @@ -4466,7 +4466,7 @@ impl<'a, W: Write> Writer<'a, W> {
&mut self,
ty: Handle<crate::Type>,
segments: &mut Vec<String>,
layouter: &crate::proc::Layouter,
layouter: &proc::Layouter,
offset: &mut u32,
items: &mut Vec<PushConstantItem>,
) {
Expand Down
10 changes: 5 additions & 5 deletions naga/src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
}
crate::MathFunction::CountLeadingZeros => {
let inner = info[fun_handle].ty.inner_with(&module.types);
if let Some(crate::ScalarKind::Sint) = inner.scalar_kind() {
if let Some(ScalarKind::Sint) = inner.scalar_kind() {
self.need_bake_expressions.insert(arg);
}
}
Expand Down Expand Up @@ -450,7 +450,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
second_blend_source: false,
..
}) => {
if stage == Some((crate::ShaderStage::Fragment, Io::Output)) {
if stage == Some((ShaderStage::Fragment, Io::Output)) {
write!(self.out, " : SV_Target{location}")?;
} else {
write!(self.out, " : {LOCATION_SEMANTIC}{location}")?;
Expand Down Expand Up @@ -994,7 +994,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
columns,
scalar,
} if member.binding.is_none() && rows == crate::VectorSize::Bi => {
let vec_ty = crate::TypeInner::Vector { size: rows, scalar };
let vec_ty = TypeInner::Vector { size: rows, scalar };
let field_name_key = NameKey::StructMember(handle, index as u32);

for i in 0..columns as u8 {
Expand Down Expand Up @@ -2397,7 +2397,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
left,
right,
} if func_ctx.resolve_type(left, &module.types).scalar_kind()
== Some(crate::ScalarKind::Float) =>
== Some(ScalarKind::Float) =>
{
write!(self.out, "fmod(")?;
self.write_expr(module, left, func_ctx)?;
Expand All @@ -2408,7 +2408,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
Expression::Binary { op, left, right } => {
write!(self.out, "(")?;
self.write_expr(module, left, func_ctx)?;
write!(self.out, " {} ", crate::back::binary_operation_str(op))?;
write!(self.out, " {} ", back::binary_operation_str(op))?;
self.write_expr(module, right, func_ctx)?;
write!(self.out, ")")?;
}
Expand Down
2 changes: 1 addition & 1 deletion naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ pub fn write_string(
options: &Options,
pipeline_options: &PipelineOptions,
) -> Result<(String, TranslationInfo), Error> {
let mut w = writer::Writer::new(String::new());
let mut w = Writer::new(String::new());
let info = w.write(module, info, options, pipeline_options)?;
Ok((w.finish(), info))
}
Expand Down
6 changes: 3 additions & 3 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ impl<W: Write> Writer<W> {
write!(self.out, ")")?;
}
crate::Expression::Binary { op, left, right } => {
let op_str = crate::back::binary_operation_str(op);
let op_str = back::binary_operation_str(op);
let kind = context
.resolve_type(left)
.scalar_kind()
Expand Down Expand Up @@ -3973,7 +3973,7 @@ impl<W: Write> Writer<W> {
// mapping.
let mut flattened_member_names = FastHashMap::default();
// Varyings' members get their own namespace
let mut varyings_namer = crate::proc::Namer::default();
let mut varyings_namer = proc::Namer::default();

// List all the Naga `EntryPoint`'s `Function`'s arguments,
// flattening structs into their members. In Metal, we will pass
Expand Down Expand Up @@ -4804,7 +4804,7 @@ fn test_stack_size() {
);
let _ = module.functions.append(fun, Default::default());
// analyse the module
let info = crate::valid::Validator::new(ValidationFlags::empty(), Capabilities::empty())
let info = valid::Validator::new(ValidationFlags::empty(), Capabilities::empty())
.validate(&module)
.unwrap();
// process the module
Expand Down
4 changes: 2 additions & 2 deletions naga/src/back/pipeline_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ fn adjust_stmt(new_pos: &[Handle<Expression>], stmt: &mut Statement) {
}
adjust(value);
}
crate::Statement::Atomic {
Statement::Atomic {
ref mut pointer,
ref mut value,
ref mut result,
Expand Down Expand Up @@ -728,7 +728,7 @@ fn adjust_stmt(new_pos: &[Handle<Expression>], stmt: &mut Statement) {
/// [`needs_pre_emit`]: Expression::needs_pre_emit
/// [`Override`]: Expression::Override
fn filter_emits_in_block(block: &mut Block, expressions: &Arena<Expression>) {
let original = std::mem::replace(block, Block::with_capacity(block.len()));
let original = mem::replace(block, Block::with_capacity(block.len()));
for (stmt, span) in original.span_into_iter() {
match stmt {
Statement::Emit(range) => {
Expand Down
Loading
Loading