Skip to content

Commit

Permalink
[naga] Remove unneeded PartialEq derivations.
Browse files Browse the repository at this point in the history
Remove `PartialEq` derivations from various Naga IR types on which
equality doesn't really make sense. In some cases, derive only in
`cfg(test)` builds, so tests can check for expected output.

In the GLSL front end, use `append` to add new constants, not
`fetch_or_append`, since the latter requires `PartialEq` yet GLSL
doesn't permit duplicate declarations anyway.
  • Loading branch information
jimblandy committed Jun 14, 2024
1 parent e78c33b commit d4be02f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion naga/src/front/glsl/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl Frontend {
ty,
init,
};
let handle = ctx.module.constants.fetch_or_append(constant, meta);
let handle = ctx.module.constants.append(constant, meta);

let lookup = GlobalLookup {
kind: GlobalLookupKind::Constant(handle, ty),
Expand Down
10 changes: 6 additions & 4 deletions naga/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ pub enum Literal {
}

/// Pipeline-overridable constant.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
Expand All @@ -909,7 +909,8 @@ pub struct Override {
}

/// Constant value.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
Expand Down Expand Up @@ -971,7 +972,7 @@ pub struct ResourceBinding {
}

/// Variable defined at module level.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
Expand Down Expand Up @@ -1371,7 +1372,8 @@ bitflags::bitflags! {
///
/// [`Constant`]: Expression::Constant
/// [`Override`]: Expression::Override
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
Expand Down

0 comments on commit d4be02f

Please sign in to comment.