@@ -1102,12 +1102,8 @@ impl Config {
1102
1102
}
1103
1103
1104
1104
pub fn proc_macro_srv ( & self ) -> Option < AbsPathBuf > {
1105
- self . data
1106
- . procMacro_server
1107
- . clone ( )
1108
- . map ( AbsPathBuf :: try_from) ?
1109
- . ok ( )
1110
- . map ( |path| self . root_path . join ( path) )
1105
+ let path = self . data . procMacro_server . clone ( ) ?;
1106
+ Some ( AbsPathBuf :: try_from ( path) . unwrap_or_else ( |path| self . root_path . join ( & path) ) )
1111
1107
}
1112
1108
1113
1109
pub fn dummy_replacements ( & self ) -> & FxHashMap < Box < str > , Box < [ Box < str > ] > > {
@@ -2424,4 +2420,43 @@ mod tests {
2424
2420
fn remove_ws ( text : & str ) -> String {
2425
2421
text. replace ( char:: is_whitespace, "" )
2426
2422
}
2423
+
2424
+ #[ test]
2425
+ fn proc_macro_srv_null ( ) {
2426
+ let mut config =
2427
+ Config :: new ( AbsPathBuf :: try_from ( project_root ( ) ) . unwrap ( ) , Default :: default ( ) , vec ! [ ] ) ;
2428
+ config
2429
+ . update ( serde_json:: json!( {
2430
+ "procMacro_server" : null,
2431
+ } ) )
2432
+ . unwrap ( ) ;
2433
+ assert_eq ! ( config. proc_macro_srv( ) , None ) ;
2434
+ }
2435
+
2436
+ #[ test]
2437
+ fn proc_macro_srv_abs ( ) {
2438
+ let mut config =
2439
+ Config :: new ( AbsPathBuf :: try_from ( project_root ( ) ) . unwrap ( ) , Default :: default ( ) , vec ! [ ] ) ;
2440
+ config
2441
+ . update ( serde_json:: json!( {
2442
+ "procMacro" : { "server" : project_root( ) . display( ) . to_string( ) }
2443
+ } ) )
2444
+ . unwrap ( ) ;
2445
+ assert_eq ! ( config. proc_macro_srv( ) , Some ( AbsPathBuf :: try_from( project_root( ) ) . unwrap( ) ) ) ;
2446
+ }
2447
+
2448
+ #[ test]
2449
+ fn proc_macro_srv_rel ( ) {
2450
+ let mut config =
2451
+ Config :: new ( AbsPathBuf :: try_from ( project_root ( ) ) . unwrap ( ) , Default :: default ( ) , vec ! [ ] ) ;
2452
+ config
2453
+ . update ( serde_json:: json!( {
2454
+ "procMacro" : { "server" : "./server" }
2455
+ } ) )
2456
+ . unwrap ( ) ;
2457
+ assert_eq ! (
2458
+ config. proc_macro_srv( ) ,
2459
+ Some ( AbsPathBuf :: try_from( project_root( ) . join( "./server" ) ) . unwrap( ) )
2460
+ ) ;
2461
+ }
2427
2462
}
0 commit comments