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 ;
@@ -81,7 +82,9 @@ impl Profiles {
81
82
rustc_host,
82
83
} ;
83
84
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) ;
85
88
86
89
// Merge with predefined profiles.
87
90
use std:: collections:: btree_map:: Entry ;
@@ -124,6 +127,7 @@ impl Profiles {
124
127
fn add_root_profiles (
125
128
profile_makers : & mut Profiles ,
126
129
profiles : & BTreeMap < InternedString , TomlProfile > ,
130
+ trim_paths_enabled : bool ,
127
131
) {
128
132
profile_makers. by_name . insert (
129
133
InternedString :: new ( "dev" ) ,
@@ -132,7 +136,10 @@ impl Profiles {
132
136
133
137
profile_makers. by_name . insert (
134
138
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
+ ) ,
136
143
) ;
137
144
}
138
145
@@ -634,8 +641,8 @@ compact_debug! {
634
641
impl fmt:: Debug for Profile {
635
642
fn fmt( & self , f: & mut fmt:: Formatter ) -> fmt:: Result {
636
643
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()" ) ,
639
646
_ => ( Profile :: default ( ) , "default()" ) ,
640
647
} ;
641
648
[ debug_the_fields(
@@ -696,11 +703,13 @@ impl Profile {
696
703
}
697
704
698
705
/// 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 ( ) ) ;
700
708
Profile {
701
709
name : InternedString :: new ( "release" ) ,
702
710
root : ProfileRoot :: Release ,
703
711
opt_level : InternedString :: new ( "3" ) ,
712
+ trim_paths,
704
713
..Profile :: default ( )
705
714
}
706
715
}
0 commit comments