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 ;
@@ -81,7 +82,9 @@ impl Profiles {
8182 rustc_host,
8283 } ;
8384
84- Self :: add_root_profiles ( & mut profile_makers, & profiles) ;
85+ let trim_paths_enabled = ws. unstable_features ( ) . is_enabled ( Feature :: trim_paths ( ) )
86+ || config. cli_unstable ( ) . trim_paths ;
87+ Self :: add_root_profiles ( & mut profile_makers, & profiles, trim_paths_enabled) ;
8588
8689 // Merge with predefined profiles.
8790 use std:: collections:: btree_map:: Entry ;
@@ -124,6 +127,7 @@ impl Profiles {
124127 fn add_root_profiles (
125128 profile_makers : & mut Profiles ,
126129 profiles : & BTreeMap < InternedString , TomlProfile > ,
130+ trim_paths_enabled : bool ,
127131 ) {
128132 profile_makers. by_name . insert (
129133 InternedString :: new ( "dev" ) ,
@@ -132,7 +136,10 @@ impl Profiles {
132136
133137 profile_makers. by_name . insert (
134138 InternedString :: new ( "release" ) ,
135- ProfileMaker :: new ( Profile :: default_release ( ) , profiles. get ( "release" ) . cloned ( ) ) ,
139+ ProfileMaker :: new (
140+ Profile :: default_release ( trim_paths_enabled) ,
141+ profiles. get ( "release" ) . cloned ( ) ,
142+ ) ,
136143 ) ;
137144 }
138145
@@ -634,8 +641,8 @@ compact_debug! {
634641 impl fmt:: Debug for Profile {
635642 fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
636643 let ( default , default_name) = match self . name. as_str( ) {
637- "dev" => ( Profile :: default_dev ( ) , "default_dev()" ) ,
638- "release" => ( Profile :: default_release ( ) , "default_release()" ) ,
644+ "dev" => ( self . clone ( ) , "default_dev()" ) ,
645+ "release" => ( self . clone ( ) , "default_release()" ) ,
639646 _ => ( Profile :: default ( ) , "default()" ) ,
640647 } ;
641648 [ debug_the_fields(
@@ -696,11 +703,13 @@ impl Profile {
696703 }
697704
698705 /// Returns a built-in `release` profile.
699- fn default_release ( ) -> Profile {
706+ fn default_release ( trim_paths_enabled : bool ) -> Profile {
707+ let trim_paths = trim_paths_enabled. then_some ( TomlTrimPaths :: object ( ) ) ;
700708 Profile {
701709 name : InternedString :: new ( "release" ) ,
702710 root : ProfileRoot :: Release ,
703711 opt_level : InternedString :: new ( "3" ) ,
712+ trim_paths,
704713 ..Profile :: default ( )
705714 }
706715 }
0 commit comments