File tree 2 files changed +13
-6
lines changed
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -194,11 +194,11 @@ pub fn config() -> Result<Option<Config>> {
194
194
}
195
195
}
196
196
197
- pub struct Profile < ' t > {
198
- table : & ' t Value ,
197
+ pub struct Profile {
198
+ table : Value ,
199
199
}
200
200
201
- impl < ' t > Profile < ' t > {
201
+ impl Profile {
202
202
pub fn hash < H > ( & self , hasher : & mut H )
203
203
where
204
204
H : Hasher ,
@@ -218,9 +218,13 @@ impl<'t> Profile<'t> {
218
218
219
219
v. to_string ( ) . hash ( hasher) ;
220
220
}
221
+
222
+ pub fn set_lto ( & mut self ) {
223
+ self . table . as_table_mut ( ) . expect ( "[profile.release] not a table" ) . insert ( "lto" . into ( ) , Value :: Boolean ( true ) ) ;
224
+ }
221
225
}
222
226
223
- impl < ' t > fmt:: Display for Profile < ' t > {
227
+ impl fmt:: Display for Profile {
224
228
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
225
229
let mut map = toml:: map:: Map :: new ( ) ;
226
230
map. insert ( "profile" . to_owned ( ) , {
@@ -243,7 +247,7 @@ impl Toml {
243
247
self . table
244
248
. get ( "profile" )
245
249
. and_then ( |v| v. get ( "release" ) )
246
- . map ( |t| Profile { table : t } )
250
+ . map ( |t| Profile { table : t. clone ( ) } )
247
251
}
248
252
}
249
253
Original file line number Diff line number Diff line change @@ -74,8 +74,11 @@ fn build_crate(
74
74
75
75
let target_dir = td. join ( "target" ) ;
76
76
77
- if let Some ( profile) = ctoml. profile ( ) {
77
+ if let Some ( mut profile) = ctoml. profile ( ) {
78
+ profile. set_lto ( ) ;
78
79
stoml. push_str ( & profile. to_string ( ) )
80
+ } else {
81
+ stoml. push_str ( "[profile.release]\n lto = true" ) ;
79
82
}
80
83
81
84
util:: write ( & td. join ( "Cargo.toml" ) , & stoml) ?;
You can’t perform that action at this time.
0 commit comments