Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

derive PartialEq on Expression #2417

Merged
merged 2 commits into from
Aug 2, 2023
Merged

Conversation

robtfm
Copy link
Contributor

@robtfm robtfm commented Jul 30, 2023

in updating naga_oil i found i needed to have the const_expressions arena contain only unique expressions. this is needed because the equality test for Consts and GlobalVariables does not inspect the init field, it just compares handles, so otherwise equal items with equivalent inits that are distinct handles do not test as equal. I rely on the Arena::fetch_or_append to deduplicate consts and globals which uses the derived equality.

adds the expression-eq feature to enable derive of PartialEq for Expression.

i note there are quite a lot of other PartialEq impls that are cfg(test). I don't need any of them but perhaps the feature sohuld be more general and include them as well:

front::glsl::error::ErrorKind
front::glsl::error::Error

front::glsl::lex::LexerResultKind
front::glsl::lex::LexerResult

front::glsl::token::DirectiveKind
front::glsl::token::Directive
front::glsl::token::Token

valid::UniformityDisruptor
valid::compose::ComposeError
valid::expression::ExpressionError

valid::function::CallError
valid::function::AtomicError
valid::function::LocalVariableError
valid::function::FunctionError

@teoxoy
Copy link
Member

teoxoy commented Aug 1, 2023

Thanks for the PR!

I don't think we need to derive PartialEq for the other types in the glsl frontend and validation module.

Are the compilation times so drastic that we should gate this derive behind a feature flag?

@robtfm
Copy link
Contributor Author

robtfm commented Aug 1, 2023

the generated code is ~260 lines, a single run showed negligible impact on compile time. happy to remove the flag and always derive it if you prefer.

@teoxoy
Copy link
Member

teoxoy commented Aug 1, 2023

Let's always derive it.

@robtfm robtfm changed the title add feature to derive PartialEq on Expression derive PartialEq on Expression Aug 1, 2023
@teoxoy teoxoy merged commit d0d3a2e into gfx-rs:master Aug 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants