24
24
use crate :: core:: compiler:: { CompileKind , CompileTarget , Unit } ;
25
25
use crate :: core:: dependency:: Artifact ;
26
26
use crate :: core:: resolver:: features:: FeaturesFor ;
27
+ use crate :: core:: Feature ;
27
28
use crate :: core:: { PackageId , PackageIdSpec , Resolve , Shell , Target , Workspace } ;
28
29
use crate :: util:: interning:: InternedString ;
29
30
use crate :: util:: toml:: TomlTrimPaths ;
31
+ use crate :: util:: toml:: TomlTrimPathsValue ;
30
32
use crate :: util:: toml:: {
31
33
ProfilePackageSpec , StringOrBool , TomlDebugInfo , TomlProfile , TomlProfiles ,
32
34
} ;
@@ -81,7 +83,9 @@ impl Profiles {
81
83
rustc_host,
82
84
} ;
83
85
84
- Self :: add_root_profiles ( & mut profile_makers, & profiles) ;
86
+ let trim_paths_enabled = ws. unstable_features ( ) . is_enabled ( Feature :: trim_paths ( ) )
87
+ || config. cli_unstable ( ) . trim_paths ;
88
+ Self :: add_root_profiles ( & mut profile_makers, & profiles, trim_paths_enabled) ;
85
89
86
90
// Merge with predefined profiles.
87
91
use std:: collections:: btree_map:: Entry ;
@@ -124,6 +128,7 @@ impl Profiles {
124
128
fn add_root_profiles (
125
129
profile_makers : & mut Profiles ,
126
130
profiles : & BTreeMap < InternedString , TomlProfile > ,
131
+ trim_paths_enabled : bool ,
127
132
) {
128
133
profile_makers. by_name . insert (
129
134
InternedString :: new ( "dev" ) ,
@@ -132,7 +137,10 @@ impl Profiles {
132
137
133
138
profile_makers. by_name . insert (
134
139
InternedString :: new ( "release" ) ,
135
- ProfileMaker :: new ( Profile :: default_release ( ) , profiles. get ( "release" ) . cloned ( ) ) ,
140
+ ProfileMaker :: new (
141
+ Profile :: default_release ( trim_paths_enabled) ,
142
+ profiles. get ( "release" ) . cloned ( ) ,
143
+ ) ,
136
144
) ;
137
145
}
138
146
@@ -635,7 +643,7 @@ compact_debug! {
635
643
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
636
644
let ( default , default_name) = match self . name. as_str( ) {
637
645
"dev" => ( Profile :: default_dev( ) , "default_dev()" ) ,
638
- "release" => ( Profile :: default_release( ) , "default_release()" ) ,
646
+ "release" => ( Profile :: default_release( false ) , "default_release()" ) ,
639
647
_ => ( Profile :: default ( ) , "default()" ) ,
640
648
} ;
641
649
[ debug_the_fields(
@@ -696,11 +704,13 @@ impl Profile {
696
704
}
697
705
698
706
/// Returns a built-in `release` profile.
699
- fn default_release ( ) -> Profile {
707
+ fn default_release ( trim_paths_enabled : bool ) -> Profile {
708
+ let trim_paths = trim_paths_enabled. then ( || TomlTrimPathsValue :: Object . into ( ) ) ;
700
709
Profile {
701
710
name : InternedString :: new ( "release" ) ,
702
711
root : ProfileRoot :: Release ,
703
712
opt_level : InternedString :: new ( "3" ) ,
713
+ trim_paths,
704
714
..Profile :: default ( )
705
715
}
706
716
}
0 commit comments