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.77 lints #6104

Closed
Closed
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ env:
# We sometimes need nightly to use special things in CI.
#
# In order to prevent CI regressions, we pin the nightly version.
NIGHTLY_VERSION: "nightly-2023-12-17"
NIGHTLY_VERSION: "nightly-2024-01-31"
# Version of rust used to build the docs with.
#
# This needs to be newer to work around https://github.com/gfx-rs/wgpu/issues/4905.
#
# Once 1.76 coes out, we can use that instead of nightly.
DOCS_RUST_VERSION: "nightly-2023-12-17"
# Once this fix hits stable Rust, we can use that instead of nightly.
DOCS_RUST_VERSION: "nightly-2024-01-31"
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
REPO_MSRV: "1.76"
REPO_MSRV: "1.77.2"
# 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.77.2"

#
# Environment variables
Expand Down
20 changes: 13 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ default-members = [

[workspace.package]
edition = "2021"
rust-version = "1.76"
rust-version = "1.77.0"
keywords = ["graphics"]
license = "MIT OR Apache-2.0"
homepage = "https://wgpu.rs/"
Expand Down Expand Up @@ -77,7 +77,7 @@ bincode = "1"
bit-vec = "0.8"
bitflags = "2.6"
bytemuck = { version = "1.16", features = ["derive"] }
cfg_aliases = "0.1"
cfg_aliases = "0.2.1"
cfg-if = "1"
criterion = "0.5"
codespan-reporting = "0.11"
Expand Down
7 changes: 6 additions & 1 deletion naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ keywords = ["shader", "SPIR-V", "GLSL", "MSL"]
license = "MIT OR Apache-2.0"
exclude = ["bin/**/*", "tests/**/*", "Cargo.lock", "target/**/*"]
resolver = "2"
rust-version = "1.76"
autotests = false

# Override the workspace's `rust-version` key. Firefox uses `cargo vendor` to
# 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.77.0"

[[test]]
name = "naga-test"
path = "tests/root.rs"
Expand Down
15 changes: 7 additions & 8 deletions naga/src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,13 @@ impl<'a, W: Write> Writer<'a, W> {
crate::MathFunction::Dot => {
// if the expression is a Dot product with integer arguments,
// then the args needs baking as well
if let TypeInner::Scalar(crate::Scalar { kind, .. }) = *inner {
match kind {
crate::ScalarKind::Sint | crate::ScalarKind::Uint => {
self.need_bake_expressions.insert(arg);
self.need_bake_expressions.insert(arg1.unwrap());
}
_ => {}
}
if let TypeInner::Scalar(crate::Scalar {
kind: crate::ScalarKind::Sint | crate::ScalarKind::Uint,
..
}) = *inner
{
self.need_bake_expressions.insert(arg);
self.need_bake_expressions.insert(arg1.unwrap());
}
}
crate::MathFunction::Pack4xI8
Expand Down
7 changes: 3 additions & 4 deletions naga/src/valid/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,14 @@ impl FunctionInfo {
E::FunctionArgument(index) => {
let arg = &resolve_context.arguments[index as usize];
let uniform = match arg.binding {
Some(crate::Binding::BuiltIn(built_in)) => match built_in {
Some(crate::Binding::BuiltIn(
// per-polygon built-ins are uniform
crate::BuiltIn::FrontFacing
// per-work-group built-ins are uniform
| crate::BuiltIn::WorkGroupId
| crate::BuiltIn::WorkGroupSize
| crate::BuiltIn::NumWorkGroups => true,
_ => false,
},
| crate::BuiltIn::NumWorkGroups)
) => true,
// only flat inputs are uniform
Some(crate::Binding::Location {
interpolation: Some(crate::Interpolation::Flat),
Expand Down
55 changes: 4 additions & 51 deletions naga/src/valid/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ pub fn check_literal_value(literal: crate::Literal) -> Result<(), LiteralError>
Ok(())
}

#[cfg(all(test, feature = "validate"))]
#[cfg(test)]
/// Validate a module containing the given expression, expecting an error.
fn validate_with_expression(
expr: crate::Expression,
Expand All @@ -1719,7 +1719,7 @@ fn validate_with_expression(
validator.validate(&module)
}

#[cfg(all(test, feature = "validate"))]
#[cfg(test)]
/// Validate a module containing the given constant expression, expecting an error.
fn validate_with_const_expression(
expr: crate::Expression,
Expand All @@ -1736,7 +1736,6 @@ fn validate_with_const_expression(
}

/// Using F64 in a function's expression arena is forbidden.
#[cfg(feature = "validate")]
#[test]
fn f64_runtime_literals() {
let result = validate_with_expression(
Expand All @@ -1748,7 +1747,7 @@ fn f64_runtime_literals() {
error,
crate::valid::ValidationError::Function {
source: super::FunctionError::Expression {
source: super::ExpressionError::Literal(super::LiteralError::Width(
source: ExpressionError::Literal(LiteralError::Width(
super::r#type::WidthError::MissingCapability {
name: "f64",
flag: "FLOAT64",
Expand All @@ -1768,7 +1767,6 @@ fn f64_runtime_literals() {
}

/// Using F64 in a module's constant expression arena is forbidden.
#[cfg(feature = "validate")]
#[test]
fn f64_const_literals() {
let result = validate_with_const_expression(
Expand All @@ -1779,7 +1777,7 @@ fn f64_const_literals() {
assert!(matches!(
error,
crate::valid::ValidationError::ConstExpression {
source: super::ConstExpressionError::Literal(super::LiteralError::Width(
source: ConstExpressionError::Literal(LiteralError::Width(
super::r#type::WidthError::MissingCapability {
name: "f64",
flag: "FLOAT64",
Expand All @@ -1795,48 +1793,3 @@ fn f64_const_literals() {
);
assert!(result.is_ok());
}

/// Using I64 in a function's expression arena is forbidden.
#[cfg(feature = "validate")]
#[test]
fn i64_runtime_literals() {
let result = validate_with_expression(
crate::Expression::Literal(crate::Literal::I64(1729)),
// There is no capability that enables this.
super::Capabilities::all(),
);
let error = result.unwrap_err().into_inner();
assert!(matches!(
error,
crate::valid::ValidationError::Function {
source: super::FunctionError::Expression {
source: super::ExpressionError::Literal(super::LiteralError::Width(
super::r#type::WidthError::Unsupported64Bit
),),
..
},
..
}
));
}

/// Using I64 in a module's constant expression arena is forbidden.
#[cfg(feature = "validate")]
#[test]
fn i64_const_literals() {
let result = validate_with_const_expression(
crate::Expression::Literal(crate::Literal::I64(1729)),
// There is no capability that enables this.
super::Capabilities::all(),
);
let error = result.unwrap_err().into_inner();
assert!(matches!(
error,
crate::valid::ValidationError::ConstExpression {
source: super::ConstExpressionError::Literal(super::LiteralError::Width(
super::r#type::WidthError::Unsupported64Bit,
),),
..
}
));
}
7 changes: 3 additions & 4 deletions naga/src/valid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,13 @@ impl Validator {

let decl_ty = &gctx.types[o.ty].inner;
match decl_ty {
&crate::TypeInner::Scalar(scalar) => match scalar {
&crate::TypeInner::Scalar(
crate::Scalar::BOOL
| crate::Scalar::I32
| crate::Scalar::U32
| crate::Scalar::F32
| crate::Scalar::F64 => {}
_ => return Err(OverrideError::TypeNotScalar),
},
| crate::Scalar::F64,
) => {}
_ => return Err(OverrideError::TypeNotScalar),
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.76"
channel = "1.77.2"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.77.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ fn main() {
metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") },
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }
}
println!("cargo::rustc-check-cfg=cfg(wgpu_core_doc)");
println!("cargo::rustc-check-cfg=cfg(wgpu_validate_locks)");
}
2 changes: 1 addition & 1 deletion wgpu-core/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type IdType = u64;
type ZippedIndex = Index;
type NonZeroId = std::num::NonZeroU64;

const INDEX_BITS: usize = std::mem::size_of::<ZippedIndex>() * 8;
const INDEX_BITS: usize = ZippedIndex::BITS as usize;
const EPOCH_BITS: usize = INDEX_BITS - BACKEND_BITS;
const BACKEND_BITS: usize = 3;
const BACKEND_SHIFT: usize = INDEX_BITS * 2 - BACKEND_BITS;
Expand Down
3 changes: 1 addition & 2 deletions wgpu-core/src/track/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! The `ResourceMetadata` type.

use bit_vec::BitVec;
use std::mem;
use wgt::strict_assert;

/// A set of resources, holding a `Arc<T>` and epoch for each member.
Expand Down Expand Up @@ -191,7 +190,7 @@ fn resize_bitvec<B: bit_vec::BitBlock>(vec: &mut BitVec<B>, size: usize) {
///
/// Will skip entire usize's worth of bits if they are all false.
fn iterate_bitvec_indices(ownership: &BitVec<usize>) -> impl Iterator<Item = usize> + '_ {
const BITS_PER_BLOCK: usize = mem::size_of::<usize>() * 8;
const BITS_PER_BLOCK: usize = usize::BITS as usize;

let size = ownership.len();

Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.77.0"

[package.metadata.docs.rs]
# Ideally we would enable all the features.
Expand Down
25 changes: 13 additions & 12 deletions wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ fn main() {

match event {
Event::LoopDestroyed => (),
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested
| WindowEvent::KeyboardInput {
input:
KeyboardInput {
virtual_keycode: Some(VirtualKeyCode::Escape),
..
},
..
} => *control_flow = ControlFlow::Exit,
_ => (),
},
Event::WindowEvent {
event:
WindowEvent::CloseRequested
| WindowEvent::KeyboardInput {
input:
KeyboardInput {
virtual_keycode: Some(VirtualKeyCode::Escape),
..
},
..
},
..
} => *control_flow = ControlFlow::Exit,
_ => (),
}
});
Expand Down
2 changes: 1 addition & 1 deletion wgpu-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.77.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
Loading