1
+ use std:: collections:: HashMap ;
2
+
1
3
use base_db:: fixture:: WithFixture ;
2
4
use chalk_ir:: { AdtId , TyKind } ;
3
5
use hir_def:: {
@@ -9,16 +11,12 @@ use crate::{db::HirDatabase, test_db::TestDB, Interner, Substitution};
9
11
10
12
use super :: layout_of_ty;
11
13
12
- fn eval_goal ( ra_fixture : & str , minicore : & str ) -> Result < Layout , LayoutError > {
13
- // using unstable cargo features failed, fall back to using plain rustc
14
- let mut cmd = std:: process:: Command :: new ( "rustc" ) ;
15
- cmd. args ( [ "-Z" , "unstable-options" , "--print" , "target-spec-json" ] ) . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
16
- let output = cmd. output ( ) . unwrap ( ) ;
17
- assert ! ( output. status. success( ) , "{}" , output. status) ;
18
- let stdout = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
19
- let target_data_layout =
20
- stdout. split_once ( r#""data-layout": ""# ) . unwrap ( ) . 1 . split_once ( '"' ) . unwrap ( ) . 0 . to_owned ( ) ;
14
+ fn current_machine_data_layout ( ) -> String {
15
+ project_model:: target_data_layout:: get ( None , None , & HashMap :: default ( ) ) . unwrap ( )
16
+ }
21
17
18
+ fn eval_goal ( ra_fixture : & str , minicore : & str ) -> Result < Layout , LayoutError > {
19
+ let target_data_layout = current_machine_data_layout ( ) ;
22
20
let ra_fixture = format ! (
23
21
"{minicore}//- /main.rs crate:test target_data_layout:{target_data_layout}\n {ra_fixture}" ,
24
22
) ;
@@ -47,15 +45,7 @@ fn eval_goal(ra_fixture: &str, minicore: &str) -> Result<Layout, LayoutError> {
47
45
48
46
/// A version of `eval_goal` for types that can not be expressed in ADTs, like closures and `impl Trait`
49
47
fn eval_expr ( ra_fixture : & str , minicore : & str ) -> Result < Layout , LayoutError > {
50
- // using unstable cargo features failed, fall back to using plain rustc
51
- let mut cmd = std:: process:: Command :: new ( "rustc" ) ;
52
- cmd. args ( [ "-Z" , "unstable-options" , "--print" , "target-spec-json" ] ) . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
53
- let output = cmd. output ( ) . unwrap ( ) ;
54
- assert ! ( output. status. success( ) , "{}" , output. status) ;
55
- let stdout = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
56
- let target_data_layout =
57
- stdout. split_once ( r#""data-layout": ""# ) . unwrap ( ) . 1 . split_once ( '"' ) . unwrap ( ) . 0 . to_owned ( ) ;
58
-
48
+ let target_data_layout = current_machine_data_layout ( ) ;
59
49
let ra_fixture = format ! (
60
50
"{minicore}//- /main.rs crate:test target_data_layout:{target_data_layout}\n fn main(){{let goal = {{{ra_fixture}}};}}" ,
61
51
) ;
0 commit comments