@@ -4,7 +4,7 @@ use std::mem;
4
4
5
5
use cfg:: { CfgAtom , CfgExpr } ;
6
6
use ide:: { FileId , RunnableKind , TestId } ;
7
- use project_model:: { self , ManifestPath , TargetKind } ;
7
+ use project_model:: { self , CargoFeatures , ManifestPath , TargetKind } ;
8
8
use vfs:: AbsPathBuf ;
9
9
10
10
use crate :: { global_state:: GlobalStateSnapshot , Result } ;
@@ -35,41 +35,41 @@ impl CargoTargetSpec {
35
35
36
36
match kind {
37
37
RunnableKind :: Test { test_id, attr } => {
38
- args. push ( "test" . to_string ( ) ) ;
38
+ args. push ( "test" . to_owned ( ) ) ;
39
39
extra_args. push ( test_id. to_string ( ) ) ;
40
40
if let TestId :: Path ( _) = test_id {
41
- extra_args. push ( "--exact" . to_string ( ) ) ;
41
+ extra_args. push ( "--exact" . to_owned ( ) ) ;
42
42
}
43
- extra_args. push ( "--nocapture" . to_string ( ) ) ;
43
+ extra_args. push ( "--nocapture" . to_owned ( ) ) ;
44
44
if attr. ignore {
45
- extra_args. push ( "--ignored" . to_string ( ) ) ;
45
+ extra_args. push ( "--ignored" . to_owned ( ) ) ;
46
46
}
47
47
}
48
48
RunnableKind :: TestMod { path } => {
49
- args. push ( "test" . to_string ( ) ) ;
50
- extra_args. push ( path. to_string ( ) ) ;
51
- extra_args. push ( "--nocapture" . to_string ( ) ) ;
49
+ args. push ( "test" . to_owned ( ) ) ;
50
+ extra_args. push ( path. clone ( ) ) ;
51
+ extra_args. push ( "--nocapture" . to_owned ( ) ) ;
52
52
}
53
53
RunnableKind :: Bench { test_id } => {
54
- args. push ( "bench" . to_string ( ) ) ;
54
+ args. push ( "bench" . to_owned ( ) ) ;
55
55
extra_args. push ( test_id. to_string ( ) ) ;
56
56
if let TestId :: Path ( _) = test_id {
57
- extra_args. push ( "--exact" . to_string ( ) ) ;
57
+ extra_args. push ( "--exact" . to_owned ( ) ) ;
58
58
}
59
- extra_args. push ( "--nocapture" . to_string ( ) ) ;
59
+ extra_args. push ( "--nocapture" . to_owned ( ) ) ;
60
60
}
61
61
RunnableKind :: DocTest { test_id } => {
62
- args. push ( "test" . to_string ( ) ) ;
63
- args. push ( "--doc" . to_string ( ) ) ;
62
+ args. push ( "test" . to_owned ( ) ) ;
63
+ args. push ( "--doc" . to_owned ( ) ) ;
64
64
extra_args. push ( test_id. to_string ( ) ) ;
65
- extra_args. push ( "--nocapture" . to_string ( ) ) ;
65
+ extra_args. push ( "--nocapture" . to_owned ( ) ) ;
66
66
}
67
67
RunnableKind :: Bin => {
68
68
let subcommand = match spec {
69
69
Some ( CargoTargetSpec { target_kind : TargetKind :: Test , .. } ) => "test" ,
70
70
_ => "run" ,
71
71
} ;
72
- args. push ( subcommand. to_string ( ) ) ;
72
+ args. push ( subcommand. to_owned ( ) ) ;
73
73
}
74
74
}
75
75
@@ -82,29 +82,35 @@ impl CargoTargetSpec {
82
82
} ;
83
83
84
84
let cargo_config = snap. config . cargo ( ) ;
85
- if cargo_config. all_features {
86
- args. push ( "--all-features" . to_string ( ) ) ;
87
85
88
- for feature in target_required_features {
89
- args. push ( "--features" . to_string ( ) ) ;
90
- args. push ( feature) ;
91
- }
92
- } else {
93
- let mut features = Vec :: new ( ) ;
94
- if let Some ( cfg) = cfg. as_ref ( ) {
95
- required_features ( cfg, & mut features) ;
86
+ match & cargo_config. features {
87
+ CargoFeatures :: All => {
88
+ args. push ( "--all-features" . to_owned ( ) ) ;
89
+ for feature in target_required_features {
90
+ args. push ( "--features" . to_owned ( ) ) ;
91
+ args. push ( feature) ;
92
+ }
96
93
}
94
+ CargoFeatures :: Selected { features, no_default_features } => {
95
+ let mut feats = Vec :: new ( ) ;
96
+ if let Some ( cfg) = cfg. as_ref ( ) {
97
+ required_features ( cfg, & mut feats) ;
98
+ }
97
99
98
- features . extend ( cargo_config . features ) ;
99
- features . extend ( target_required_features) ;
100
+ feats . extend ( features. iter ( ) . cloned ( ) ) ;
101
+ feats . extend ( target_required_features) ;
100
102
101
- features. dedup ( ) ;
102
- for feature in features {
103
- args. push ( "--features" . to_string ( ) ) ;
104
- args. push ( feature) ;
103
+ feats. dedup ( ) ;
104
+ for feature in feats {
105
+ args. push ( "--features" . to_owned ( ) ) ;
106
+ args. push ( feature) ;
107
+ }
108
+
109
+ if * no_default_features {
110
+ args. push ( "--no-default-features" . to_owned ( ) ) ;
111
+ }
105
112
}
106
113
}
107
-
108
114
Ok ( ( args, extra_args) )
109
115
}
110
116
@@ -136,7 +142,7 @@ impl CargoTargetSpec {
136
142
}
137
143
138
144
pub ( crate ) fn push_to ( self , buf : & mut Vec < String > , kind : & RunnableKind ) {
139
- buf. push ( "--package" . to_string ( ) ) ;
145
+ buf. push ( "--package" . to_owned ( ) ) ;
140
146
buf. push ( self . package ) ;
141
147
142
148
// Can't mix --doc with other target flags
@@ -145,23 +151,23 @@ impl CargoTargetSpec {
145
151
}
146
152
match self . target_kind {
147
153
TargetKind :: Bin => {
148
- buf. push ( "--bin" . to_string ( ) ) ;
154
+ buf. push ( "--bin" . to_owned ( ) ) ;
149
155
buf. push ( self . target ) ;
150
156
}
151
157
TargetKind :: Test => {
152
- buf. push ( "--test" . to_string ( ) ) ;
158
+ buf. push ( "--test" . to_owned ( ) ) ;
153
159
buf. push ( self . target ) ;
154
160
}
155
161
TargetKind :: Bench => {
156
- buf. push ( "--bench" . to_string ( ) ) ;
162
+ buf. push ( "--bench" . to_owned ( ) ) ;
157
163
buf. push ( self . target ) ;
158
164
}
159
165
TargetKind :: Example => {
160
- buf. push ( "--example" . to_string ( ) ) ;
166
+ buf. push ( "--example" . to_owned ( ) ) ;
161
167
buf. push ( self . target ) ;
162
168
}
163
169
TargetKind :: Lib => {
164
- buf. push ( "--lib" . to_string ( ) ) ;
170
+ buf. push ( "--lib" . to_owned ( ) ) ;
165
171
}
166
172
TargetKind :: Other | TargetKind :: BuildScript => ( ) ,
167
173
}
0 commit comments