Skip to content

Commit 69b0546

Browse files
committed
Force builtins to be private
1 parent ee49697 commit 69b0546

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

compiler/rustc_builtin_macros/src/standard_library_imports.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub fn inject(
5353
//
5454
// FIXME(#113634) We should inject this during post-processing like
5555
// we do for the panic runtime, profiler runtime, etc.
56+
//
57+
// See also `is_private_dep` within `rustc_metadata`.
5658
cx.item(
5759
span,
5860
Ident::new(kw::Underscore, ident_span),

compiler/rustc_metadata/src/creader.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
404404
fn is_private_dep(&self, name: Symbol, private_dep: Option<bool>) -> bool {
405405
let extern_private = self.sess.opts.externs.get(name.as_str()).map(|e| e.is_private_dep);
406406
debug!("name: {name}, private: {private_dep:?}, extern private: {extern_private:?}");
407+
if name == sym::compiler_builtins {
408+
// compiler_builtins is a private implementation detail and should never show up in
409+
// diagnostics. See also the note referencing #113634 in
410+
// `rustc_builtin_macros::...::inject`.
411+
return true;
412+
}
413+
407414
match (extern_private, private_dep) {
408415
// Explicit non-private via `--extern`, explicit non-private from metadata, or
409416
// unspecified with default to public.

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
730730
/// Constructs the reduced graph for one item.
731731
fn build_reduced_graph_for_item(&mut self, item: &'a Item) {
732732
let parent_scope = &self.parent_scope;
733+
let ps2 = self.parent_scope.clone();
733734
let parent = parent_scope.module;
734735
let expansion = parent_scope.expansion;
735736
let ident = item.ident;
@@ -761,8 +762,8 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
761762

762763
ItemKind::ExternCrate(orig_name) => {
763764
tracing::info!(
764-
"extern crate {:?}",
765-
(&orig_name, &item, &local_def_id, &vis, &parent)
765+
"extern crate {:#?}",
766+
(ps2, parent, &orig_name, &item, &local_def_id, &vis, &parent)
766767
);
767768
self.build_reduced_graph_for_extern_crate(
768769
orig_name,

0 commit comments

Comments
 (0)