@@ -6,13 +6,12 @@ use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit};
6
6
use crate :: core:: profiles:: { Profiles , UnitFor } ;
7
7
use crate :: core:: resolver:: features:: { CliFeatures , FeaturesFor , ResolvedFeatures } ;
8
8
use crate :: core:: resolver:: HasDevUnits ;
9
- use crate :: core:: { Dependency , PackageId , PackageSet , Resolve , SourceId , Workspace } ;
9
+ use crate :: core:: { PackageId , PackageSet , Resolve , Workspace } ;
10
10
use crate :: ops:: { self , Packages } ;
11
11
use crate :: util:: errors:: CargoResult ;
12
12
use crate :: GlobalContext ;
13
13
use std:: collections:: { HashMap , HashSet } ;
14
14
use std:: path:: PathBuf ;
15
- use std:: rc:: Rc ;
16
15
17
16
use super :: BuildConfig ;
18
17
@@ -74,60 +73,11 @@ pub fn resolve_std<'gctx>(
74
73
}
75
74
76
75
let src_path = detect_sysroot_src_path ( target_data) ?;
77
- let to_patch = [
78
- "rustc-std-workspace-core" ,
79
- "rustc-std-workspace-alloc" ,
80
- "rustc-std-workspace-std" ,
81
- ] ;
82
- let patches = to_patch
83
- . iter ( )
84
- . map ( |& name| {
85
- let source_path = SourceId :: for_path ( & src_path. join ( "library" ) . join ( name) ) ?;
86
- let dep = Dependency :: parse ( name, None , source_path) ?;
87
- Ok ( dep)
88
- } )
89
- . collect :: < CargoResult < Vec < _ > > > ( ) ?;
90
- let crates_io_url = crate :: sources:: CRATES_IO_INDEX . parse ( ) . unwrap ( ) ;
91
- let patch = HashMap :: from ( [ ( crates_io_url, patches) ] ) ;
92
- let members = vec ! [
93
- String :: from( "library/std" ) ,
94
- String :: from( "library/core" ) ,
95
- String :: from( "library/alloc" ) ,
96
- String :: from( "library/sysroot" ) ,
97
- ] ;
98
- let ws_config = crate :: core:: WorkspaceConfig :: Root ( crate :: core:: WorkspaceRootConfig :: new (
99
- & src_path,
100
- & Some ( members) ,
101
- /*default_members*/ & None ,
102
- /*exclude*/ & None ,
103
- /*inheritable*/ & None ,
104
- /*custom_metadata*/ & None ,
105
- ) ) ;
106
- let virtual_manifest = crate :: core:: VirtualManifest :: new (
107
- Rc :: default ( ) ,
108
- Rc :: new ( toml_edit:: ImDocument :: parse ( "" . to_owned ( ) ) . expect ( "empty is valid TOML" ) ) ,
109
- Rc :: default ( ) ,
110
- Rc :: default ( ) ,
111
- /*replace*/ Vec :: new ( ) ,
112
- patch,
113
- ws_config,
114
- crate :: core:: Features :: default ( ) ,
115
- None ,
116
- ) ;
117
-
76
+ let std_ws_manifest_path = src_path. join ( "library" ) . join ( "Cargo.toml" ) ;
118
77
let gctx = ws. gctx ( ) ;
119
- // This is a delicate hack. In order for features to resolve correctly,
120
- // the resolver needs to run a specific "current" member of the workspace.
121
- // Thus, in order to set the features for `std`, we need to set `sysroot`
122
- // to be the "current" member. `sysroot` is the root, and all other
123
- // standard library crates are dependencies from there. Since none of the
124
- // other crates need to alter their features, this should be fine, for
125
- // now. Perhaps in the future features will be decoupled from the resolver
126
- // and it will be easier to control feature selection.
127
- let current_manifest = src_path. join ( "library/sysroot/Cargo.toml" ) ;
128
78
// TODO: Consider doing something to enforce --locked? Or to prevent the
129
79
// lock file from being written, such as setting ephemeral.
130
- let mut std_ws = Workspace :: new_virtual ( src_path , current_manifest , virtual_manifest , gctx) ?;
80
+ let mut std_ws = Workspace :: new ( & std_ws_manifest_path , gctx) ?;
131
81
// Don't require optional dependencies in this workspace, aka std's own
132
82
// `[dev-dependencies]`. No need for us to generate a `Resolve` which has
133
83
// those included because we'll never use them anyway.
0 commit comments