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

Resolve lints in versions _newer_ than Rust 1.76 while still in Rust 1.76 #6103

Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ env:
#
# 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.
# Once this fix hits stable Rust, we can use that instead of nightly.
DOCS_RUST_VERSION: "nightly-2023-12-17"
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
REPO_MSRV: "1.76"
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.76"

[[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(
ErichDonGubler marked this conversation as resolved.
Show resolved Hide resolved
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() {
ErichDonGubler marked this conversation as resolved.
Show resolved Hide resolved
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 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
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
Loading