@@ -6,13 +6,12 @@ use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit};
66use crate :: core:: profiles:: { Profiles , UnitFor } ;
77use crate :: core:: resolver:: features:: { CliFeatures , FeaturesFor , ResolvedFeatures } ;
88use crate :: core:: resolver:: HasDevUnits ;
9- use crate :: core:: { Dependency , PackageId , PackageSet , Resolve , SourceId , Workspace } ;
9+ use crate :: core:: { PackageId , PackageSet , Resolve , Workspace } ;
1010use crate :: ops:: { self , Packages } ;
1111use crate :: util:: errors:: CargoResult ;
1212use crate :: GlobalContext ;
1313use std:: collections:: { HashMap , HashSet } ;
1414use std:: path:: PathBuf ;
15- use std:: rc:: Rc ;
1615
1716use super :: BuildConfig ;
1817
@@ -74,60 +73,11 @@ pub fn resolve_std<'gctx>(
7473 }
7574
7675 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" ) ;
11877 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" ) ;
12878 // TODO: Consider doing something to enforce --locked? Or to prevent the
12979 // 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) ?;
13181 // Don't require optional dependencies in this workspace, aka std's own
13282 // `[dev-dependencies]`. No need for us to generate a `Resolve` which has
13383 // those included because we'll never use them anyway.
0 commit comments