@@ -70,6 +70,8 @@ use crate::core::compiler::rustdoc::RustdocExternMap;
70
70
use crate :: core:: shell:: Verbosity ;
71
71
use crate :: core:: { features, CliUnstable , Shell , SourceId , Workspace , WorkspaceRootConfig } ;
72
72
use crate :: ops:: RegistryCredentialConfig ;
73
+ use crate :: sources:: CRATES_IO_INDEX ;
74
+ use crate :: sources:: CRATES_IO_REGISTRY ;
73
75
use crate :: util:: errors:: CargoResult ;
74
76
use crate :: util:: network:: http:: configure_http_handle;
75
77
use crate :: util:: network:: http:: http_handle;
@@ -1831,11 +1833,17 @@ impl Config {
1831
1833
target:: load_target_triple ( self , target)
1832
1834
}
1833
1835
1834
- pub fn crates_io_source_id < F > ( & self , f : F ) -> CargoResult < SourceId >
1835
- where
1836
- F : FnMut ( ) -> CargoResult < SourceId > ,
1837
- {
1838
- Ok ( * ( self . crates_io_source_id . try_borrow_with ( f) ?) )
1836
+ /// Returns the cached [`SourceId`] corresponding to the main repository.
1837
+ ///
1838
+ /// This is the main cargo registry by default, but it can be overridden in
1839
+ /// a `.cargo/config.toml`.
1840
+ pub fn crates_io_source_id ( & self ) -> CargoResult < SourceId > {
1841
+ let source_id = self . crates_io_source_id . try_borrow_with ( || {
1842
+ self . check_registry_index_not_set ( ) ?;
1843
+ let url = CRATES_IO_INDEX . into_url ( ) . unwrap ( ) ;
1844
+ SourceId :: for_alt_registry ( & url, CRATES_IO_REGISTRY )
1845
+ } ) ?;
1846
+ Ok ( * source_id)
1839
1847
}
1840
1848
1841
1849
pub fn creation_time ( & self ) -> Instant {
0 commit comments