1+ use  alloc:: borrow:: Cow ; 
12use  alloc:: { 
23    format, 
34    string:: { String ,  ToString } , 
45} ; 
5- 
66use  codespan_reporting:: diagnostic:: Diagnostic ; 
77use  codespan_reporting:: files:: SimpleFile ; 
88use  codespan_reporting:: term; 
@@ -14,6 +14,8 @@ use crate::{
1414    front:: atomic_upgrade, 
1515} ; 
1616
17+ use  crate :: proc:: ConstantEvaluatorError ; 
18+ 
1719#[ derive( Clone ,  Debug ,  thiserror:: Error ) ]  
1820pub  enum  Error  { 
1921    #[ error( "invalid header" ) ]  
@@ -30,6 +32,8 @@ pub enum Error {
3032    UnsupportedSpecConstantOp ( spirv:: Op ) , 
3133    #[ error( "invalid opcode in specialization constant operation {0:?}" ) ]  
3234    InvalidSpecConstantOp ( spirv:: Op ) , 
35+     #[ error( "{0}" ) ]  
36+     SemanticError ( Cow < ' static ,  str > ) , 
3337    #[ error( "unsupported capability {0:?}" ) ]  
3438    UnsupportedCapability ( spirv:: Capability ) , 
3539    #[ error( "unsupported extension {0}" ) ]  
@@ -155,11 +159,16 @@ pub enum Error {
155159    NonBindingArrayOfImageOrSamplers , 
156160    #[ error( "naga only supports specialization constant IDs up to 65535 but was given {0}" ) ]  
157161    SpecIdTooHigh ( u32 ) , 
158- 
159162    #[ error( "atomic upgrade error: {0}" ) ]  
160163    AtomicUpgradeError ( atomic_upgrade:: Error ) , 
161164} 
162165
166+ impl  From < ConstantEvaluatorError >  for  Error  { 
167+     fn  from ( err :  ConstantEvaluatorError )  -> Self  { 
168+         Error :: SemanticError ( err. to_string ( ) . into ( ) ) 
169+     } 
170+ } 
171+ 
163172impl  Error  { 
164173    pub  fn  emit_to_writer ( & self ,  writer :  & mut  impl  ErrorWrite ,  source :  & str )  { 
165174        self . emit_to_writer_with_path ( writer,  source,  "glsl" ) ; 
0 commit comments