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
@@ -3,7 +3,7 @@ use super::{
Capabilities, Disalignment, FunctionError, ModuleInfo, ShaderStages, TypeFlags,
ValidationFlags,
};
use crate::arena::{Arena, Handle};
use crate::arena::{Handle, UniqueArena};
use bit_set::BitSet;
@@ -93,7 +93,7 @@ struct VaryingContext<'a> {
ty: Handle<crate::Type>,
stage: crate::ShaderStage,
output: bool,
types: &'a Arena<crate::Type>,
types: &'a UniqueArena<crate::Type>,
location_mask: &'a mut BitSet,
built_in_mask: u32,
capabilities: Capabilities,
@@ -320,7 +320,7 @@ impl super::Validator {
pub(super) fn validate_global_var(
&self,
var: &crate::GlobalVariable,
types: &Arena<crate::Type>,
types: &UniqueArena<crate::Type>,
) -> Result<(), GlobalVariableError> {
log::debug!("var {:?}", var);
let type_info = &self.types[var.ty.index()];