Skip to content

Commit f1c2e39

Browse files
committed
Partially revert ed63539 ("Mark dependencies ... private by default")
Remove the portion of ed63539 that automatically sets crates private based on whether they are dependencies of `std`. Instead, this is controlled by dependency configuration in `Cargo.toml`.
1 parent fdd1a3b commit f1c2e39

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_session::lint::{self, BuiltinLintDiag};
2929
use rustc_session::output::validate_crate_name;
3030
use rustc_session::search_paths::PathKind;
3131
use rustc_span::edition::Edition;
32-
use rustc_span::{DUMMY_SP, Ident, STDLIB_STABLE_CRATES, Span, Symbol, sym};
32+
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym};
3333
use rustc_target::spec::{PanicStrategy, Target, TargetTuple};
3434
use tracing::{debug, info, trace};
3535

@@ -400,29 +400,8 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
400400
/// Sometimes the directly dependent crate is not specified by `--extern`, in this case,
401401
/// `private-dep` is none during loading. This is equivalent to the scenario where the
402402
/// command parameter is set to `public-dependency`
403-
fn is_private_dep(
404-
&self,
405-
name: Symbol,
406-
private_dep: Option<bool>,
407-
dep_root: Option<&CratePaths>,
408-
) -> bool {
409-
// Standard library crates are never private.
410-
if STDLIB_STABLE_CRATES.contains(&name) {
411-
tracing::info!("returning false for {name} is private");
412-
return false;
413-
}
414-
403+
fn is_private_dep(&self, name: Symbol, private_dep: Option<bool>) -> bool {
415404
let extern_private = self.sess.opts.externs.get(name.as_str()).map(|e| e.is_private_dep);
416-
417-
// Any descendants of `std` should be private. These crates are usually not marked
418-
// private in metadata, so we ignore that field.
419-
if extern_private.is_none()
420-
&& let Some(dep) = dep_root
421-
&& STDLIB_STABLE_CRATES.contains(&dep.name)
422-
{
423-
return true;
424-
}
425-
426405
match (extern_private, private_dep) {
427406
// Explicit non-private via `--extern`, explicit non-private from metadata, or
428407
// unspecified with default to public.
@@ -447,7 +426,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
447426
let Library { source, metadata } = lib;
448427
let crate_root = metadata.get_root();
449428
let host_hash = host_lib.as_ref().map(|lib| lib.metadata.get_root().hash());
450-
let private_dep = self.is_private_dep(name, private_dep, dep_root);
429+
let private_dep = self.is_private_dep(name, private_dep);
451430

452431
// Claim this crate number and cache it
453432
let feed = self.cstore.intern_stable_crate_id(&crate_root, self.tcx)?;
@@ -643,7 +622,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
643622
// not specified by `--extern` on command line parameters, it may be
644623
// `private-dependency` when `register_crate` is called for the first time. Then it must be updated to
645624
// `public-dependency` here.
646-
let private_dep = self.is_private_dep(name, private_dep, dep_root);
625+
let private_dep = self.is_private_dep(name, private_dep);
647626
let data = self.cstore.get_crate_data_mut(cnum);
648627
if data.is_proc_macro_crate() {
649628
dep_kind = CrateDepKind::MacrosOnly;

0 commit comments

Comments
 (0)