Skip to content

Commit

Permalink
Force compiler_builtins to be a private dependency
Browse files Browse the repository at this point in the history
`compiler_builtins` is an injected dependency, introduced in AST as
`extern crate compiler_builtins as _`. This means that `is_private_dep`
has no way of knowing this should be private.

To get around this, always mark `compiler_builtins` private. The items
in this crate are never used
  • Loading branch information
tgross35 committed Jan 28, 2025
1 parent b33490f commit 3fc0f76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_builtin_macros/src/standard_library_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub fn inject(
//
// FIXME(#113634) We should inject this during post-processing like
// we do for the panic runtime, profiler runtime, etc.
//
// See also `is_private_dep` within `rustc_metadata`.
cx.item(
span,
Ident::new(kw::Underscore, ident_span),
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
/// command parameter is set to `public-dependency`
fn is_private_dep(&self, name: Symbol, private_dep: Option<bool>) -> bool {
let extern_private = self.sess.opts.externs.get(name.as_str()).map(|e| e.is_private_dep);
if name == sym::compiler_builtins {
// compiler_builtins is a private implementation detail and should never show up in
// diagnostics. See also the note referencing #113634 in
// `rustc_builtin_macros::...::inject`.
return true;
}

match (extern_private, private_dep) {
// Explicit non-private via `--extern`, explicit non-private from metadata, or
// unspecified with default to public.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
/// Constructs the reduced graph for one item.
fn build_reduced_graph_for_item(&mut self, item: &'a Item) {
let parent_scope = &self.parent_scope;
let ps2 = self.parent_scope.clone();
let parent = parent_scope.module;
let expansion = parent_scope.expansion;
let ident = item.ident;
Expand Down

0 comments on commit 3fc0f76

Please sign in to comment.