@@ -52,23 +52,25 @@ impl Diagnostic {
52
52
pub ( crate ) unsafe fn from_diag (
53
53
diag : * mut diagnostics:: Diagnostic ,
54
54
) -> 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
+ }
58
59
59
- let ( message, notes) = Message :: message_and_notes_from_cstr ( ( * diag) . error ) ;
60
+ let ( message, notes) = Message :: message_and_notes_from_cstr ( ( * diag) . error ) ;
60
61
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
+ } ;
69
70
70
- diagnostics:: diagnostic_destroy ( diag) ;
71
- Ok ( res)
71
+ diagnostics:: diagnostic_destroy ( diag) ;
72
+ Ok ( res)
73
+ }
72
74
}
73
75
}
74
76
@@ -126,15 +128,17 @@ impl Message {
126
128
127
129
#[ cfg( feature = "use-compiled-tools" ) ]
128
130
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
+ }
138
142
}
139
143
}
140
144
0 commit comments