@@ -7,7 +7,13 @@ use crate::{
7
7
validation, Label , LifeGuard , Stored ,
8
8
} ;
9
9
use arrayvec:: ArrayVec ;
10
- use std:: { borrow:: Cow , error:: Error , fmt, marker:: PhantomData , num:: NonZeroU32 } ;
10
+ use std:: {
11
+ borrow:: Cow ,
12
+ error:: Error ,
13
+ fmt:: { self , Write } ,
14
+ marker:: PhantomData ,
15
+ num:: NonZeroU32 ,
16
+ } ;
11
17
use thiserror:: Error ;
12
18
13
19
/// Information about buffer bindings, which
@@ -92,7 +98,22 @@ impl fmt::Display for ShaderError<naga::WithSpan<naga::valid::ValidationError>>
92
98
let config = term:: Config :: default ( ) ;
93
99
let mut writer = term:: termcolor:: NoColor :: new ( Vec :: new ( ) ) ;
94
100
95
- let diagnostic = Diagnostic :: error ( ) . with_labels (
101
+ let err_chain = {
102
+ let mut msg_buf = String :: new ( ) ;
103
+ write ! ( msg_buf, "{}" , self . inner) . unwrap ( ) ;
104
+
105
+ let mut source = self . inner . source ( ) ;
106
+ while let Some ( next) = source {
107
+ // NOTE: The spacing here matters for presentation as a `Diagnostic`. Formula used:
108
+ //
109
+ // * 7 spaces to offset `error: `
110
+ // * 2 more spaces for "compact" indentation of the original error
111
+ writeln ! ( msg_buf, " {next}" ) . unwrap ( ) ;
112
+ source = next. source ( ) ;
113
+ }
114
+ msg_buf
115
+ } ;
116
+ let diagnostic = Diagnostic :: error ( ) . with_message ( err_chain) . with_labels (
96
117
self . inner
97
118
. spans ( )
98
119
. map ( |& ( span, ref desc) | {
0 commit comments