2424use crate :: core:: compiler:: { CompileKind , CompileTarget , Unit } ;
2525use crate :: core:: dependency:: Artifact ;
2626use crate :: core:: resolver:: features:: FeaturesFor ;
27+ use crate :: core:: Feature ;
2728use crate :: core:: { PackageId , PackageIdSpec , Resolve , Shell , Target , Workspace } ;
2829use crate :: util:: interning:: InternedString ;
2930use crate :: util:: toml:: TomlTrimPaths ;
31+ use crate :: util:: toml:: TomlTrimPathsValue ;
3032use crate :: util:: toml:: {
3133 ProfilePackageSpec , StringOrBool , TomlDebugInfo , TomlProfile , TomlProfiles ,
3234} ;
@@ -81,7 +83,9 @@ impl Profiles {
8183 rustc_host,
8284 } ;
8385
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) ;
8589
8690 // Merge with predefined profiles.
8791 use std:: collections:: btree_map:: Entry ;
@@ -124,6 +128,7 @@ impl Profiles {
124128 fn add_root_profiles (
125129 profile_makers : & mut Profiles ,
126130 profiles : & BTreeMap < InternedString , TomlProfile > ,
131+ trim_paths_enabled : bool ,
127132 ) {
128133 profile_makers. by_name . insert (
129134 InternedString :: new ( "dev" ) ,
@@ -132,7 +137,10 @@ impl Profiles {
132137
133138 profile_makers. by_name . insert (
134139 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+ ) ,
136144 ) ;
137145 }
138146
@@ -636,7 +644,7 @@ compact_debug! {
636644 fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
637645 let ( default , default_name) = match self . name. as_str( ) {
638646 "dev" => ( Profile :: default_dev( ) , "default_dev()" ) ,
639- "release" => ( Profile :: default_release( ) , "default_release()" ) ,
647+ "release" => ( Profile :: default_release( false ) , "default_release()" ) ,
640648 _ => ( Profile :: default ( ) , "default()" ) ,
641649 } ;
642650 [ debug_the_fields(
@@ -697,11 +705,13 @@ impl Profile {
697705 }
698706
699707 /// Returns a built-in `release` profile.
700- fn default_release ( ) -> Profile {
708+ fn default_release ( trim_paths_enabled : bool ) -> Profile {
709+ let trim_paths = trim_paths_enabled. then ( || TomlTrimPathsValue :: Object . into ( ) ) ;
701710 Profile {
702711 name : InternedString :: new ( "release" ) ,
703712 root : ProfileRoot :: Release ,
704713 opt_level : InternedString :: new ( "3" ) ,
714+ trim_paths,
705715 ..Profile :: default ( )
706716 }
707717 }
0 commit comments