Use UniqueArena for types.

Ensure that each distinct type occurs only once in `Module::types`, so that we
can use `Eq` on `Type` or `TypeInner` for type equivalence, without being
confused by differing `Handle<Type>` values that point to identical types.

This removes a number of duplicate types from the ir snapshots.

Fixes #1385.
This commit is contained in:
Jim Blandy authored and Dzmitry Malyshau committed 2021-09-27 15:17:41 -04:00
1 parent d026577a91
commit 944a693ae5
32 files changed
+387 -363

No files matched your search

+3 -3
View File
@@ -2,7 +2,7 @@ use super::{
analyzer::{UniformityDisruptor, UniformityRequirements},
ExpressionError, FunctionInfo, ModuleInfo, ShaderStages, TypeFlags, ValidationFlags,
};
use crate::arena::{Arena, Handle};
use crate::arena::{Arena, Handle, UniqueArena};
use bit_set::BitSet;
#[derive(Clone, Debug, thiserror::Error)]
@@ -144,7 +144,7 @@ struct BlockContext<'a> {
abilities: ControlFlowAbility,
info: &'a FunctionInfo,
expressions: &'a Arena<crate::Expression>,
types: &'a Arena<crate::Type>,
types: &'a UniqueArena<crate::Type>,
global_vars: &'a Arena<crate::GlobalVariable>,
functions: &'a Arena<crate::Function>,
prev_infos: &'a [FunctionInfo],
@@ -627,7 +627,7 @@ impl super::Validator {
fn validate_local_var(
&self,
var: &crate::LocalVariable,
types: &Arena<crate::Type>,
types: &UniqueArena<crate::Type>,
constants: &Arena<crate::Constant>,
) -> Result<(), LocalVariableError> {
log::debug!("var {:?}", var);