File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 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>> {
194194 }
195195}
196196
197- pub struct Profile < ' t > {
198- table : & ' t Value ,
197+ pub struct Profile {
198+ table : Value ,
199199}
200200
201- impl < ' t > Profile < ' t > {
201+ impl Profile {
202202 pub fn hash < H > ( & self , hasher : & mut H )
203203 where
204204 H : Hasher ,
@@ -218,9 +218,13 @@ impl<'t> Profile<'t> {
218218
219219 v. to_string ( ) . hash ( hasher) ;
220220 }
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+ }
221225}
222226
223- impl < ' t > fmt:: Display for Profile < ' t > {
227+ impl fmt:: Display for Profile {
224228 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
225229 let mut map = toml:: map:: Map :: new ( ) ;
226230 map. insert ( "profile" . to_owned ( ) , {
@@ -243,7 +247,7 @@ impl Toml {
243247 self . table
244248 . get ( "profile" )
245249 . and_then ( |v| v. get ( "release" ) )
246- . map ( |t| Profile { table : t } )
250+ . map ( |t| Profile { table : t. clone ( ) } )
247251 }
248252}
249253
Original file line number Diff line number Diff line change @@ -74,8 +74,11 @@ fn build_crate(
7474
7575 let target_dir = td. join ( "target" ) ;
7676
77- if let Some ( profile) = ctoml. profile ( ) {
77+ if let Some ( mut profile) = ctoml. profile ( ) {
78+ profile. set_lto ( ) ;
7879 stoml. push_str ( & profile. to_string ( ) )
80+ } else {
81+ stoml. push_str ( "[profile.release]\n lto = true" ) ;
7982 }
8083
8184 util:: write ( & td. join ( "Cargo.toml" ) , & stoml) ?;
You can’t perform that action at this time.
0 commit comments