@@ -86,7 +86,7 @@ use regex_set::RegexSet;
86
86
use std:: fs:: OpenOptions ;
87
87
use std:: io:: { self , Write } ;
88
88
use std:: path:: Path ;
89
- use std:: sync:: { Arc , Mutex } ;
89
+ use std:: sync:: Arc ;
90
90
91
91
use syntax:: ast;
92
92
use syntax:: codemap:: { DUMMY_SP , Span } ;
@@ -653,23 +653,15 @@ fn ensure_libclang_is_loaded() {
653
653
// across different threads.
654
654
655
655
lazy_static ! {
656
- static ref LIBCLANG : Mutex <Option <Arc <clang_sys:: SharedLibrary >>> = {
657
- Mutex :: new( None )
656
+ static ref LIBCLANG : Arc <clang_sys:: SharedLibrary > = {
657
+ clang_sys:: load( ) . expect( "Unable to find libclang" ) ;
658
+ clang_sys:: get_library( )
659
+ . expect( "We just loaded libclang and it had better still be \
660
+ here!")
658
661
} ;
659
662
}
660
663
661
- let mut libclang = LIBCLANG . lock ( ) . unwrap ( ) ;
662
- if !clang_sys:: is_loaded ( ) {
663
- if libclang. is_none ( ) {
664
- // TODO(emilio): Return meaningful error (breaking).
665
- clang_sys:: load ( ) . expect ( "Unable to find libclang" ) ;
666
- * libclang = Some ( clang_sys:: get_library ( )
667
- . expect ( "We just loaded libclang and it had \
668
- better still be here!") ) ;
669
- } else {
670
- clang_sys:: set_library ( libclang. clone ( ) ) ;
671
- }
672
- }
664
+ clang_sys:: set_library ( Some ( LIBCLANG . clone ( ) ) ) ;
673
665
}
674
666
675
667
/// Generated Rust bindings.
0 commit comments