@@ -12,7 +12,7 @@ mod interface;
1212mod r#type;
1313
1414use alloc:: { boxed:: Box , string:: String , vec, vec:: Vec } ;
15- use core:: ops:: { self , Deref , DerefMut } ;
15+ use core:: ops;
1616
1717use bit_set:: BitSet ;
1818
@@ -474,35 +474,7 @@ pub enum OverrideError {
474474
475475#[ derive( Clone , Debug , thiserror:: Error ) ]
476476#[ cfg_attr( test, derive( PartialEq ) ) ]
477- #[ error( transparent) ]
478- pub struct ValidationError ( Box < ValidationErrorInner > ) ;
479-
480- impl < T > From < T > for ValidationError
481- where
482- T : Into < ValidationErrorInner > ,
483- {
484- fn from ( value : T ) -> Self {
485- ValidationError ( Box :: new ( value. into ( ) ) )
486- }
487- }
488-
489- impl Deref for ValidationError {
490- type Target = Box < ValidationErrorInner > ;
491-
492- fn deref ( & self ) -> & Self :: Target {
493- & self . 0
494- }
495- }
496-
497- impl DerefMut for ValidationError {
498- fn deref_mut ( & mut self ) -> & mut Self :: Target {
499- & mut self . 0
500- }
501- }
502-
503- #[ derive( Clone , Debug , thiserror:: Error ) ]
504- #[ cfg_attr( test, derive( PartialEq ) ) ]
505- pub enum ValidationErrorInner {
477+ pub enum ValidationError {
506478 #[ error( transparent) ]
507479 InvalidHandle ( #[ from] InvalidHandleError ) ,
508480 #[ error( transparent) ]
@@ -761,7 +733,7 @@ impl Validator {
761733 pub fn validate (
762734 & mut self ,
763735 module : & crate :: Module ,
764- ) -> Result < ModuleInfo , WithSpan < ValidationError > > {
736+ ) -> Result < ModuleInfo , WithSpan < Box < ValidationError > > > {
765737 self . overrides_resolved = false ;
766738 self . validate_impl ( module)
767739 }
@@ -776,23 +748,23 @@ impl Validator {
776748 pub fn validate_resolved_overrides (
777749 & mut self ,
778750 module : & crate :: Module ,
779- ) -> Result < ModuleInfo , WithSpan < ValidationError > > {
751+ ) -> Result < ModuleInfo , WithSpan < Box < ValidationError > > > {
780752 self . overrides_resolved = true ;
781753 self . validate_impl ( module)
782754 }
783755
784756 fn validate_impl (
785757 & mut self ,
786758 module : & crate :: Module ,
787- ) -> Result < ModuleInfo , WithSpan < ValidationError > > {
759+ ) -> Result < ModuleInfo , WithSpan < Box < ValidationError > > > {
788760 self . reset ( ) ;
789761 self . reset_types ( module. types . len ( ) ) ;
790762
791- Self :: validate_module_handles ( module) . map_err ( |e| ValidationError :: from ( e ) . with_span ( ) ) ?;
763+ Self :: validate_module_handles ( module) . map_err ( |e| e . with_span ( ) ) ?;
792764
793765 self . layouter . update ( module. to_ctx ( ) ) . map_err ( |e| {
794766 let handle = e. ty ;
795- ValidationError :: from ( e) . with_span_handle ( handle, & module. types )
767+ Box :: new ( ValidationError :: from ( e) ) . with_span_handle ( handle, & module. types )
796768 } ) ?;
797769
798770 // These should all get overwritten.
@@ -813,7 +785,7 @@ impl Validator {
813785 let ty_info = self
814786 . validate_type ( handle, module. to_ctx ( ) )
815787 . map_err ( |source| {
816- ValidationError :: from ( ValidationErrorInner :: Type {
788+ Box :: new ( ValidationError :: Type {
817789 handle,
818790 name : ty. name . clone ( ) . unwrap_or_default ( ) ,
819791 source,
@@ -835,7 +807,7 @@ impl Validator {
835807 mod_info
836808 . process_const_expression ( handle, & resolve_context, module. to_ctx ( ) )
837809 . map_err ( |source| {
838- ValidationError :: from ( ValidationErrorInner :: ConstExpression {
810+ Box :: new ( ValidationError :: ConstExpression {
839811 handle,
840812 source,
841813 } )
@@ -855,15 +827,15 @@ impl Validator {
855827 & global_expr_kind,
856828 )
857829 . map_err ( |source| {
858- ValidationError :: from ( ValidationErrorInner :: ConstExpression { handle, source } )
830+ Box :: new ( ValidationError :: ConstExpression { handle, source } )
859831 . with_span_handle ( handle, & module. global_expressions )
860832 } ) ?
861833 }
862834
863835 for ( handle, constant) in module. constants . iter ( ) {
864836 self . validate_constant ( handle, module. to_ctx ( ) , & mod_info, & global_expr_kind)
865837 . map_err ( |source| {
866- ValidationError :: from ( ValidationErrorInner :: Constant {
838+ Box :: new ( ValidationError :: Constant {
867839 handle,
868840 name : constant. name . clone ( ) . unwrap_or_default ( ) ,
869841 source,
@@ -875,7 +847,7 @@ impl Validator {
875847 for ( handle, r#override) in module. overrides . iter ( ) {
876848 self . validate_override ( handle, module. to_ctx ( ) , & mod_info)
877849 . map_err ( |source| {
878- ValidationError :: from ( ValidationErrorInner :: Override {
850+ Box :: new ( ValidationError :: Override {
879851 handle,
880852 name : r#override. name . clone ( ) . unwrap_or_default ( ) ,
881853 source,
@@ -888,7 +860,7 @@ impl Validator {
888860 for ( var_handle, var) in module. global_variables . iter ( ) {
889861 self . validate_global_var ( var, module. to_ctx ( ) , & mod_info, & global_expr_kind)
890862 . map_err ( |source| {
891- ValidationError :: from ( ValidationErrorInner :: GlobalVariable {
863+ Box :: new ( ValidationError :: GlobalVariable {
892864 handle : var_handle,
893865 name : var. name . clone ( ) . unwrap_or_default ( ) ,
894866 source,
@@ -902,7 +874,7 @@ impl Validator {
902874 Ok ( info) => mod_info. functions . push ( info) ,
903875 Err ( error) => {
904876 return Err ( error. and_then ( |source| {
905- ValidationError :: from ( ValidationErrorInner :: Function {
877+ Box :: new ( ValidationError :: Function {
906878 handle,
907879 name : fun. name . clone ( ) . unwrap_or_default ( ) ,
908880 source,
@@ -916,7 +888,7 @@ impl Validator {
916888 let mut ep_map = FastHashSet :: default ( ) ;
917889 for ep in module. entry_points . iter ( ) {
918890 if !ep_map. insert ( ( ep. stage , & ep. name ) ) {
919- return Err ( ValidationError :: from ( ValidationErrorInner :: EntryPoint {
891+ return Err ( Box :: new ( ValidationError :: EntryPoint {
920892 stage : ep. stage ,
921893 name : ep. name . clone ( ) ,
922894 source : EntryPointError :: Conflict ,
@@ -928,7 +900,7 @@ impl Validator {
928900 Ok ( info) => mod_info. entry_points . push ( info) ,
929901 Err ( error) => {
930902 return Err ( error. and_then ( |source| {
931- ValidationError :: from ( ValidationErrorInner :: EntryPoint {
903+ Box :: new ( ValidationError :: EntryPoint {
932904 stage : ep. stage ,
933905 name : ep. name . clone ( ) ,
934906 source,
0 commit comments