@@ -52,23 +52,25 @@ impl Diagnostic {
5252 pub ( crate ) unsafe fn from_diag (
5353 diag : * mut diagnostics:: Diagnostic ,
5454 ) -> Result < Self , shared:: SpirvResult > {
55- if diag. is_null ( ) {
56- return Err ( shared:: SpirvResult :: Success ) ;
57- }
55+ unsafe {
56+ if diag. is_null ( ) {
57+ return Err ( shared:: SpirvResult :: Success ) ;
58+ }
5859
59- let ( message, notes) = Message :: message_and_notes_from_cstr ( ( * diag) . error ) ;
60+ let ( message, notes) = Message :: message_and_notes_from_cstr ( ( * diag) . error ) ;
6061
61- let res = Self {
62- line : ( * diag) . position . line ,
63- column : ( * diag) . position . column ,
64- index : ( * diag) . position . index ,
65- message,
66- notes,
67- is_text : ( * diag) . is_text_source ,
68- } ;
62+ let res = Self {
63+ line : ( * diag) . position . line ,
64+ column : ( * diag) . position . column ,
65+ index : ( * diag) . position . index ,
66+ message,
67+ notes,
68+ is_text : ( * diag) . is_text_source ,
69+ } ;
6970
70- diagnostics:: diagnostic_destroy ( diag) ;
71- Ok ( res)
71+ diagnostics:: diagnostic_destroy ( diag) ;
72+ Ok ( res)
73+ }
7274 }
7375}
7476
@@ -126,15 +128,17 @@ impl Message {
126128
127129 #[ cfg( feature = "use-compiled-tools" ) ]
128130 unsafe fn message_and_notes_from_cstr ( msg : * const std:: os:: raw:: c_char ) -> ( String , String ) {
129- let full_message = std:: ffi:: CStr :: from_ptr ( msg) . to_string_lossy ( ) ;
130-
131- if let Some ( ind) = full_message. find ( '\n' ) {
132- (
133- full_message[ ..ind] . to_owned ( ) ,
134- full_message[ ind + 1 ..] . to_owned ( ) ,
135- )
136- } else {
137- ( full_message. into_owned ( ) , String :: new ( ) )
131+ unsafe {
132+ let full_message = std:: ffi:: CStr :: from_ptr ( msg) . to_string_lossy ( ) ;
133+
134+ if let Some ( ind) = full_message. find ( '\n' ) {
135+ (
136+ full_message[ ..ind] . to_owned ( ) ,
137+ full_message[ ind + 1 ..] . to_owned ( ) ,
138+ )
139+ } else {
140+ ( full_message. into_owned ( ) , String :: new ( ) )
141+ }
138142 }
139143 }
140144
0 commit comments