Minimize visibilities.

This makes it much clearer which things are used outside the crate.
This commit is contained in:
Nicholas Nethercote 2024-09-05 15:16:55 +10:00
parent 04a318787b
commit bdacdfe95f
24 changed files with 188 additions and 179 deletions

View File

@ -157,7 +157,7 @@ fn extract_bundled_libs<'a>(
}
}
pub fn create_mingw_dll_import_lib(
fn create_mingw_dll_import_lib(
sess: &Session,
lib_name: &str,
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,

View File

@ -8,7 +8,7 @@
use rustc_target::spec::LldFlavor;
#[derive(Clone)]
pub struct Command {
pub(crate) struct Command {
program: Program,
args: Vec<OsString>,
env: Vec<(OsString, OsString)>,
@ -23,15 +23,15 @@ enum Program {
}
impl Command {
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::Normal(program.as_ref().to_owned()))
}
pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
}
pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
}
@ -39,12 +39,12 @@ fn _new(program: Program) -> Command {
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
}
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
self._arg(arg.as_ref());
self
}
pub fn args<I>(&mut self, args: I) -> &mut Command
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
where
I: IntoIterator<Item: AsRef<OsStr>>,
{
@ -58,7 +58,7 @@ fn _arg(&mut self, arg: &OsStr) {
self.args.push(arg.to_owned());
}
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
@ -71,7 +71,7 @@ fn _env(&mut self, key: &OsStr, value: &OsStr) {
self.env.push((key.to_owned(), value.to_owned()));
}
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
where
K: AsRef<OsStr>,
{
@ -83,11 +83,11 @@ fn _env_remove(&mut self, key: &OsStr) {
self.env_remove.push(key.to_owned());
}
pub fn output(&mut self) -> io::Result<Output> {
pub(crate) fn output(&mut self) -> io::Result<Output> {
self.command().output()
}
pub fn command(&self) -> process::Command {
pub(crate) fn command(&self) -> process::Command {
let mut ret = match self.program {
Program::Normal(ref p) => process::Command::new(p),
Program::CmdBatScript(ref p) => {
@ -111,17 +111,17 @@ pub fn command(&self) -> process::Command {
// extensions
pub fn get_args(&self) -> &[OsString] {
pub(crate) fn get_args(&self) -> &[OsString] {
&self.args
}
pub fn take_args(&mut self) -> Vec<OsString> {
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
mem::take(&mut self.args)
}
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
/// or `false` if we should attempt to spawn and see what the OS says.
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
// We mostly only care about Windows in this method, on Unix the limits
// can be gargantuan anyway so we're pretty unlikely to hit them
if cfg!(unix) {

View File

@ -28,7 +28,7 @@
/// and prevent inspection of linker output in case of errors, which we occasionally do.
/// This should be acceptable because other messages from rustc are in English anyway,
/// and may also be desirable to improve searchability of the linker diagnostics.
pub fn disable_localization(linker: &mut Command) {
pub(crate) fn disable_localization(linker: &mut Command) {
// No harm in setting both env vars simultaneously.
// Unix-style linkers.
linker.env("LC_ALL", "C");
@ -39,7 +39,7 @@ pub fn disable_localization(linker: &mut Command) {
/// The third parameter is for env vars, used on windows to set up the
/// path for MSVC to find its DLLs, and gcc to find its bundled
/// toolchain
pub fn get_linker<'a>(
pub(crate) fn get_linker<'a>(
sess: &'a Session,
linker: &Path,
flavor: LinkerFlavor,
@ -213,28 +213,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
macro_rules! generate_arg_methods {
($($ty:ty)*) => { $(
impl $ty {
pub fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn verbatim_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
verbatim_args(self, args)
}
pub fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn verbatim_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
verbatim_args(self, iter::once(arg))
}
pub fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self {
link_args(self, args)
}
pub fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
link_args(self, iter::once(arg))
}
pub fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
cc_args(self, args)
}
pub fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
cc_args(self, iter::once(arg))
}
pub fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_or_cc_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
link_or_cc_args(self, args)
}
pub fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
#[allow(unused)]
pub(crate) fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
link_or_cc_args(self, iter::once(arg))
}
}
@ -261,7 +269,7 @@ pub fn link_or_cc_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
/// represents the meaning of each option being passed down. This trait is then
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
/// MSVC linker (e.g., `link.exe`) is being used.
pub trait Linker {
pub(crate) trait Linker {
fn cmd(&mut self) -> &mut Command;
fn is_cc(&self) -> bool {
false
@ -312,12 +320,12 @@ fn reset_per_library_state(&mut self) {}
}
impl dyn Linker + '_ {
pub fn take_cmd(&mut self) -> Command {
pub(crate) fn take_cmd(&mut self) -> Command {
mem::replace(self.cmd(), Command::new(""))
}
}
pub struct GccLinker<'a> {
struct GccLinker<'a> {
cmd: Command,
sess: &'a Session,
target_cpu: &'a str,
@ -847,7 +855,7 @@ fn add_as_needed(&mut self) {
}
}
pub struct MsvcLinker<'a> {
struct MsvcLinker<'a> {
cmd: Command,
sess: &'a Session,
}
@ -1095,7 +1103,7 @@ fn add_no_exec(&mut self) {
}
}
pub struct EmLinker<'a> {
struct EmLinker<'a> {
cmd: Command,
sess: &'a Session,
}
@ -1212,7 +1220,7 @@ fn linker_plugin_lto(&mut self) {
}
}
pub struct WasmLd<'a> {
struct WasmLd<'a> {
cmd: Command,
sess: &'a Session,
}
@ -1396,7 +1404,7 @@ fn push_linker_plugin_lto_args(&mut self) {
}
/// Linker shepherd script for L4Re (Fiasco)
pub struct L4Bender<'a> {
struct L4Bender<'a> {
cmd: Command,
sess: &'a Session,
hinted_static: bool,
@ -1502,7 +1510,7 @@ fn no_crt_objects(&mut self) {}
}
impl<'a> L4Bender<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
L4Bender { cmd, sess, hinted_static: false }
}
@ -1515,14 +1523,14 @@ fn hint_static(&mut self) {
}
/// Linker for AIX.
pub struct AixLinker<'a> {
struct AixLinker<'a> {
cmd: Command,
sess: &'a Session,
hinted_static: Option<bool>,
}
impl<'a> AixLinker<'a> {
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
AixLinker { cmd, sess, hinted_static: None }
}
@ -1750,7 +1758,7 @@ pub(crate) fn linked_symbols(
/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
/// with bitcode and uses LLVM backend to generate a PTX assembly.
pub struct PtxLinker<'a> {
struct PtxLinker<'a> {
cmd: Command,
sess: &'a Session,
}
@ -1816,7 +1824,7 @@ fn linker_plugin_lto(&mut self) {}
}
/// The `self-contained` LLVM bitcode linker
pub struct LlbcLinker<'a> {
struct LlbcLinker<'a> {
cmd: Command,
sess: &'a Session,
}
@ -1887,7 +1895,7 @@ fn subsystem(&mut self, _subsystem: &str) {}
fn linker_plugin_lto(&mut self) {}
}
pub struct BpfLinker<'a> {
struct BpfLinker<'a> {
cmd: Command,
sess: &'a Session,
}

View File

@ -32,7 +32,7 @@
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
/// </dl>
#[derive(Debug)]
pub struct DefaultMetadataLoader;
pub(crate) struct DefaultMetadataLoader;
static AIX_METADATA_SYMBOL_NAME: &'static str = "__aix_rust_metadata";
@ -416,7 +416,7 @@ fn macho_is_arm64e(target: &Target) -> bool {
target.llvm_target.starts_with("arm64e")
}
pub enum MetadataPosition {
pub(crate) enum MetadataPosition {
First,
Last,
}
@ -452,7 +452,7 @@ pub enum MetadataPosition {
/// * ELF - All other targets are similar to Windows in that there's a
/// `SHF_EXCLUDE` flag we can set on sections in an object file to get
/// automatically removed from the final output.
pub fn create_wrapper_file(
pub(crate) fn create_wrapper_file(
sess: &Session,
section_name: String,
data: &[u8],

View File

@ -1,9 +1,9 @@
pub mod archive;
pub mod command;
pub(crate) mod command;
pub mod link;
pub mod linker;
pub(crate) mod linker;
pub mod lto;
pub mod metadata;
pub mod rpath;
pub(crate) mod rpath;
pub mod symbol_export;
pub mod write;

View File

@ -6,14 +6,14 @@
use rustc_fs_util::try_canonicalize;
use tracing::debug;
pub struct RPathConfig<'a> {
pub(super) struct RPathConfig<'a> {
pub libs: &'a [&'a Path],
pub out_filename: PathBuf,
pub is_like_osx: bool,
pub linker_is_gnu: bool,
}
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
pub(super) fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
debug!("preparing the RPATH!");
let rpaths = get_rpaths(config);

View File

@ -18,7 +18,7 @@
use crate::base::allocator_kind_for_codegen;
pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
crates_export_threshold(tcx.crate_types())
}
@ -484,7 +484,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
!tcx.reachable_set(()).contains(&def_id)
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.reachable_non_generics = reachable_non_generics_provider;
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
providers.exported_symbols = exported_symbols_provider_local;
@ -525,7 +525,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
}
/// This is the symbol name of the given instance instantiated in a specific crate.
pub fn symbol_name_for_instance_in_crate<'tcx>(
pub(crate) fn symbol_name_for_instance_in_crate<'tcx>(
tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>,
instantiating_crate: CrateNum,
@ -582,7 +582,7 @@ pub fn symbol_name_for_instance_in_crate<'tcx>(
/// This is the symbol name of the given instance as seen by the linker.
///
/// On 32-bit Windows symbols are decorated according to their calling conventions.
pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>(
tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>,
instantiating_crate: CrateNum,
@ -661,7 +661,7 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
format!("{prefix}{undecorated}{suffix}{args_in_bytes}")
}
pub fn exporting_symbol_name_for_instance_in_crate<'tcx>(
pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>(
tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>,
cnum: CrateNum,

View File

@ -335,7 +335,7 @@ pub fn new(
+ Sync,
>;
pub type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
type ExportedSymbols = FxHashMap<CrateNum, Arc<Vec<(String, SymbolExportInfo)>>>;
/// Additional resources used by optimize_and_codegen (not module specific)
#[derive(Clone)]
@ -437,9 +437,9 @@ fn generate_lto_work<B: ExtraBackendMethods>(
}
}
pub struct CompiledModules {
pub modules: Vec<CompiledModule>,
pub allocator_module: Option<CompiledModule>,
struct CompiledModules {
modules: Vec<CompiledModule>,
allocator_module: Option<CompiledModule>,
}
fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
@ -462,7 +462,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
}
}
pub fn start_async_codegen<B: ExtraBackendMethods>(
pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
backend: B,
tcx: TyCtxt<'_>,
target_cpu: String,
@ -836,13 +836,13 @@ pub enum FatLtoInput<B: WriteBackendMethods> {
}
/// Actual LTO type we end up choosing based on multiple factors.
pub enum ComputedLtoType {
pub(crate) enum ComputedLtoType {
No,
Thin,
Fat,
}
pub fn compute_per_cgu_lto_type(
pub(crate) fn compute_per_cgu_lto_type(
sess_lto: &Lto,
opts: &config::Options,
sess_crate_types: &[CrateType],
@ -1087,7 +1087,7 @@ struct Diagnostic {
// A cut-down version of `rustc_errors::Subdiag` that impls `Send`. It's
// missing the following fields from `rustc_errors::Subdiag`.
// - `span`: it doesn't impl `Send`.
pub struct Subdiagnostic {
pub(crate) struct Subdiagnostic {
level: Level,
messages: Vec<(DiagMessage, Style)>,
}
@ -1779,7 +1779,7 @@ fn queue_full_enough(items_in_queue: usize, workers_running: usize) -> bool {
/// `FatalError` is explicitly not `Send`.
#[must_use]
pub struct WorkerFatalError;
pub(crate) struct WorkerFatalError;
fn spawn_work<'a, B: ExtraBackendMethods>(
cgcx: &'a CodegenContext<B>,
@ -1867,7 +1867,7 @@ pub struct SharedEmitterMain {
}
impl SharedEmitter {
pub fn new() -> (SharedEmitter, SharedEmitterMain) {
fn new() -> (SharedEmitter, SharedEmitterMain) {
let (sender, receiver) = channel();
(SharedEmitter { sender }, SharedEmitterMain { receiver })
@ -1883,7 +1883,7 @@ pub fn inline_asm_error(
drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)));
}
pub fn fatal(&self, msg: &str) {
fn fatal(&self, msg: &str) {
drop(self.sender.send(SharedEmitterMessage::Fatal(msg.to_string())));
}
}
@ -1930,7 +1930,7 @@ fn source_map(&self) -> Option<&Lrc<SourceMap>> {
}
impl SharedEmitterMain {
pub fn check(&self, sess: &Session, blocking: bool) {
fn check(&self, sess: &Session, blocking: bool) {
loop {
let message = if blocking {
match self.receiver.recv() {
@ -2087,17 +2087,17 @@ pub fn join(self, sess: &Session) -> (CodegenResults, FxIndexMap<WorkProductId,
)
}
pub fn codegen_finished(&self, tcx: TyCtxt<'_>) {
pub(crate) fn codegen_finished(&self, tcx: TyCtxt<'_>) {
self.wait_for_signal_to_codegen_item();
self.check_for_errors(tcx.sess);
drop(self.coordinator.sender.send(Box::new(Message::CodegenComplete::<B>)));
}
pub fn check_for_errors(&self, sess: &Session) {
pub(crate) fn check_for_errors(&self, sess: &Session) {
self.shared_emitter_main.check(sess, false);
}
pub fn wait_for_signal_to_codegen_item(&self) {
pub(crate) fn wait_for_signal_to_codegen_item(&self) {
match self.codegen_worker_receive.recv() {
Ok(CguMessage) => {
// Ok to proceed.
@ -2110,7 +2110,7 @@ pub fn wait_for_signal_to_codegen_item(&self) {
}
}
pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
pub(crate) fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
module: ModuleCodegen<B::Module>,
@ -2120,7 +2120,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost })));
}
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
pub(crate) fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,
module: CachedModuleCodegen,
@ -2129,7 +2129,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
drop(tx_to_llvm_workers.send(Box::new(Message::CodegenDone::<B> { llvm_work_item, cost: 0 })));
}
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
pub(crate) fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
_backend: &B,
tcx: TyCtxt<'_>,
tx_to_llvm_workers: &Sender<Box<dyn Any + Send>>,

View File

@ -44,7 +44,7 @@
errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
};
pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
pub(crate) fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
match op {
BinOp::Eq => IntPredicate::IntEQ,
BinOp::Ne => IntPredicate::IntNE,
@ -84,7 +84,7 @@ pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
}
}
pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
pub(crate) fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
match op {
BinOp::Eq => RealPredicate::RealOEQ,
BinOp::Ne => RealPredicate::RealUNE,
@ -135,7 +135,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
///
/// The `old_info` argument is a bit odd. It is intended for use in an upcast,
/// where the new vtable for an object will be derived from the old one.
pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
source: Ty<'tcx>,
target: Ty<'tcx>,
@ -182,7 +182,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
/// Coerces `src` to `dst_ty`. `src_ty` must be a pointer.
pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
src: Bx::Value,
src_ty: Ty<'tcx>,
@ -227,7 +227,7 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
/// Coerces `src` to `dst_ty` which is guaranteed to be a `dyn*` type.
pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
src: Bx::Value,
src_ty_and_layout: TyAndLayout<'tcx>,
@ -250,7 +250,7 @@ pub fn cast_to_dyn_star<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
/// Coerces `src`, which is a reference to a value of type `src_ty`,
/// to a value of type `dst_ty`, and stores the result in `dst`.
pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
src: PlaceRef<'tcx, Bx::Value>,
dst: PlaceRef<'tcx, Bx::Value>,
@ -305,7 +305,7 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
///
/// If `is_unchecked` is true, this does no masking, and adds sufficient `assume`
/// calls or operation flags to preserve as much freedom to optimize as possible.
pub fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
lhs: Bx::Value,
mut rhs: Bx::Value,
@ -369,11 +369,11 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
/// Returns `true` if this session's target requires the new exception
/// handling LLVM IR instructions (catchpad / cleanuppad / ... instead
/// of landingpad)
pub fn wants_new_eh_instructions(sess: &Session) -> bool {
pub(crate) fn wants_new_eh_instructions(sess: &Session) -> bool {
wants_wasm_eh(sess) || wants_msvc_seh(sess)
}
pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
cx: &'a Bx::CodegenCx,
instance: Instance<'tcx>,
) {
@ -999,7 +999,7 @@ pub fn new(tcx: TyCtxt<'_>, target_cpu: String) -> CrateInfo {
}
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.backend_optimization_level = |tcx, cratenum| {
let for_speed = match tcx.sess.opts.optimize {
// If globally no optimisation is done, #[optimize] has no effect.

View File

@ -755,6 +755,6 @@ fn check_link_name_xor_ordinal(
}
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
}

View File

@ -118,7 +118,7 @@ fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) {
}
}
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &Bx,
span: Option<Span>,
li: LangItem,
@ -129,7 +129,7 @@ pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
(bx.fn_abi_of_instance(instance, ty::List::empty()), bx.get_fn_addr(instance), instance)
}
pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
llty: Bx::Type,
mask_llty: Bx::Type,

View File

@ -54,7 +54,7 @@ pub fn tag_base_type<'tcx>(tcx: TyCtxt<'tcx>, enum_type_and_layout: TyAndLayout<
})
}
pub fn tag_base_type_opt<'tcx>(
fn tag_base_type_opt<'tcx>(
tcx: TyCtxt<'tcx>,
enum_type_and_layout: TyAndLayout<'tcx>,
) -> Option<Ty<'tcx>> {

View File

@ -21,7 +21,7 @@
#[derive(Diagnostic)]
#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
pub struct IncorrectCguReuseType<'a> {
pub(crate) struct IncorrectCguReuseType<'a> {
#[primary_span]
pub span: Span,
pub cgu_user_name: &'a str,
@ -32,14 +32,14 @@ pub struct IncorrectCguReuseType<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_cgu_not_recorded)]
pub struct CguNotRecorded<'a> {
pub(crate) struct CguNotRecorded<'a> {
pub cgu_user_name: &'a str,
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_reuse_kind)]
pub struct UnknownReuseKind {
pub(crate) struct UnknownReuseKind {
#[primary_span]
pub span: Span,
pub kind: Symbol,
@ -47,14 +47,14 @@ pub struct UnknownReuseKind {
#[derive(Diagnostic)]
#[diag(codegen_ssa_missing_query_depgraph)]
pub struct MissingQueryDepGraph {
pub(crate) struct MissingQueryDepGraph {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_malformed_cgu_name)]
pub struct MalformedCguName {
pub(crate) struct MalformedCguName {
#[primary_span]
pub span: Span,
pub user_path: String,
@ -63,7 +63,7 @@ pub struct MalformedCguName {
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_module_named)]
pub struct NoModuleNamed<'a> {
pub(crate) struct NoModuleNamed<'a> {
#[primary_span]
pub span: Span,
pub user_path: &'a str,
@ -73,7 +73,7 @@ pub struct NoModuleNamed<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_field_associated_value_expected)]
pub struct FieldAssociatedValueExpected {
pub(crate) struct FieldAssociatedValueExpected {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -81,7 +81,7 @@ pub struct FieldAssociatedValueExpected {
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_field)]
pub struct NoField {
pub(crate) struct NoField {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -89,49 +89,49 @@ pub struct NoField {
#[derive(Diagnostic)]
#[diag(codegen_ssa_lib_def_write_failure)]
pub struct LibDefWriteFailure {
pub(crate) struct LibDefWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_version_script_write_failure)]
pub struct VersionScriptWriteFailure {
pub(crate) struct VersionScriptWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_symbol_file_write_failure)]
pub struct SymbolFileWriteFailure {
pub(crate) struct SymbolFileWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_ld64_unimplemented_modifier)]
pub struct Ld64UnimplementedModifier;
pub(crate) struct Ld64UnimplementedModifier;
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_unsupported_modifier)]
pub struct LinkerUnsupportedModifier;
pub(crate) struct LinkerUnsupportedModifier;
#[derive(Diagnostic)]
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
pub struct L4BenderExportingSymbolsUnimplemented;
pub(crate) struct L4BenderExportingSymbolsUnimplemented;
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_natvis_directory)]
pub struct NoNatvisDirectory {
pub(crate) struct NoNatvisDirectory {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_no_saved_object_file)]
pub struct NoSavedObjectFile<'a> {
pub(crate) struct NoSavedObjectFile<'a> {
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_copy_path_buf)]
pub struct CopyPathBuf {
pub(crate) struct CopyPathBuf {
pub source_file: PathBuf,
pub output_path: PathBuf,
pub error: Error,
@ -180,20 +180,20 @@ pub struct IgnoringOutput {
#[derive(Diagnostic)]
#[diag(codegen_ssa_create_temp_dir)]
pub struct CreateTempDir {
pub(crate) struct CreateTempDir {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_add_native_library)]
pub struct AddNativeLibrary {
pub(crate) struct AddNativeLibrary {
pub library_path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_multiple_external_func_decl)]
pub struct MultipleExternalFuncDecl<'a> {
pub(crate) struct MultipleExternalFuncDecl<'a> {
#[primary_span]
pub span: Span,
pub function: Symbol,
@ -215,7 +215,7 @@ pub enum LinkRlibError {
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
}
pub struct ThorinErrorWrapper(pub thorin::Error);
pub(crate) struct ThorinErrorWrapper(pub thorin::Error);
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
@ -343,7 +343,7 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
}
}
pub struct LinkingFailed<'a> {
pub(crate) struct LinkingFailed<'a> {
pub linker_path: &'a PathBuf,
pub exit_status: ExitStatus,
pub command: &'a Command,
@ -376,28 +376,28 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_exe_unexpected_error)]
pub struct LinkExeUnexpectedError;
pub(crate) struct LinkExeUnexpectedError;
#[derive(Diagnostic)]
#[diag(codegen_ssa_repair_vs_build_tools)]
pub struct RepairVSBuildTools;
pub(crate) struct RepairVSBuildTools;
#[derive(Diagnostic)]
#[diag(codegen_ssa_missing_cpp_build_tool_component)]
pub struct MissingCppBuildToolComponent;
pub(crate) struct MissingCppBuildToolComponent;
#[derive(Diagnostic)]
#[diag(codegen_ssa_select_cpp_build_tool_workload)]
pub struct SelectCppBuildToolWorkload;
pub(crate) struct SelectCppBuildToolWorkload;
#[derive(Diagnostic)]
#[diag(codegen_ssa_visual_studio_not_installed)]
pub struct VisualStudioNotInstalled;
pub(crate) struct VisualStudioNotInstalled;
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_not_found)]
#[note]
pub struct LinkerNotFound {
pub(crate) struct LinkerNotFound {
pub linker_path: PathBuf,
pub error: Error,
}
@ -406,7 +406,7 @@ pub struct LinkerNotFound {
#[diag(codegen_ssa_unable_to_exe_linker)]
#[note]
#[note(codegen_ssa_command_note)]
pub struct UnableToExeLinker {
pub(crate) struct UnableToExeLinker {
pub linker_path: PathBuf,
pub error: Error,
pub command_formatted: String,
@ -414,38 +414,38 @@ pub struct UnableToExeLinker {
#[derive(Diagnostic)]
#[diag(codegen_ssa_msvc_missing_linker)]
pub struct MsvcMissingLinker;
pub(crate) struct MsvcMissingLinker;
#[derive(Diagnostic)]
#[diag(codegen_ssa_self_contained_linker_missing)]
pub struct SelfContainedLinkerMissing;
pub(crate) struct SelfContainedLinkerMissing;
#[derive(Diagnostic)]
#[diag(codegen_ssa_check_installed_visual_studio)]
pub struct CheckInstalledVisualStudio;
pub(crate) struct CheckInstalledVisualStudio;
#[derive(Diagnostic)]
#[diag(codegen_ssa_insufficient_vs_code_product)]
pub struct InsufficientVSCodeProduct;
pub(crate) struct InsufficientVSCodeProduct;
#[derive(Diagnostic)]
#[diag(codegen_ssa_processing_dymutil_failed)]
#[note]
pub struct ProcessingDymutilFailed {
pub(crate) struct ProcessingDymutilFailed {
pub status: ExitStatus,
pub output: String,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_run_dsymutil)]
pub struct UnableToRunDsymutil {
pub(crate) struct UnableToRunDsymutil {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_stripping_debug_info_failed)]
#[note]
pub struct StrippingDebugInfoFailed<'a> {
pub(crate) struct StrippingDebugInfoFailed<'a> {
pub util: &'a str,
pub status: ExitStatus,
pub output: String,
@ -453,58 +453,59 @@ pub struct StrippingDebugInfoFailed<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_run)]
pub struct UnableToRun<'a> {
pub(crate) struct UnableToRun<'a> {
pub util: &'a str,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_linker_file_stem)]
pub struct LinkerFileStem;
pub(crate) struct LinkerFileStem;
#[derive(Diagnostic)]
#[diag(codegen_ssa_static_library_native_artifacts)]
pub struct StaticLibraryNativeArtifacts;
pub(crate) struct StaticLibraryNativeArtifacts;
#[derive(Diagnostic)]
#[diag(codegen_ssa_static_library_native_artifacts_to_file)]
pub struct StaticLibraryNativeArtifactsToFile<'a> {
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_script_unavailable)]
pub struct LinkScriptUnavailable;
pub(crate) struct LinkScriptUnavailable;
#[derive(Diagnostic)]
#[diag(codegen_ssa_link_script_write_failure)]
pub struct LinkScriptWriteFailure {
pub(crate) struct LinkScriptWriteFailure {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_failed_to_write)]
pub struct FailedToWrite {
pub(crate) struct FailedToWrite {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_write_debugger_visualizer)]
pub struct UnableToWriteDebuggerVisualizer {
pub(crate) struct UnableToWriteDebuggerVisualizer {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_rlib_archive_build_failure)]
pub struct RlibArchiveBuildFailure {
pub(crate) struct RlibArchiveBuildFailure {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
// Public for rustc_codegen_llvm::back::archive
pub enum ExtractBundledLibsError<'a> {
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
@ -533,26 +534,26 @@ pub enum ExtractBundledLibsError<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_unsupported_arch)]
pub struct UnsupportedArch<'a> {
pub(crate) struct UnsupportedArch<'a> {
pub arch: &'a str,
pub os: &'a str,
}
#[derive(Diagnostic)]
pub enum AppleSdkRootError<'a> {
pub(crate) enum AppleSdkRootError<'a> {
#[diag(codegen_ssa_apple_sdk_error_sdk_path)]
SdkPath { sdk_name: &'a str, error: Error },
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_read_file)]
pub struct ReadFileError {
pub(crate) struct ReadFileError {
pub message: std::io::Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_unsupported_link_self_contained)]
pub struct UnsupportedLinkSelfContained;
pub(crate) struct UnsupportedLinkSelfContained;
#[derive(Diagnostic)]
#[diag(codegen_ssa_archive_build_failure)]
@ -571,7 +572,7 @@ pub struct UnknownArchiveKind<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_expected_used_symbol)]
pub struct ExpectedUsedSymbol {
pub(crate) struct ExpectedUsedSymbol {
#[primary_span]
pub span: Span,
}
@ -579,45 +580,45 @@ pub struct ExpectedUsedSymbol {
#[derive(Diagnostic)]
#[diag(codegen_ssa_multiple_main_functions)]
#[help]
pub struct MultipleMainFunctions {
pub(crate) struct MultipleMainFunctions {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_metadata_object_file_write)]
pub struct MetadataObjectFileWrite {
pub(crate) struct MetadataObjectFileWrite {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_invalid_windows_subsystem)]
pub struct InvalidWindowsSubsystem {
pub(crate) struct InvalidWindowsSubsystem {
pub subsystem: Symbol,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_shuffle_indices_evaluation)]
pub struct ShuffleIndicesEvaluation {
pub(crate) struct ShuffleIndicesEvaluation {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_missing_memory_ordering)]
pub struct MissingMemoryOrdering;
pub(crate) struct MissingMemoryOrdering;
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_atomic_ordering)]
pub struct UnknownAtomicOrdering;
pub(crate) struct UnknownAtomicOrdering;
#[derive(Diagnostic)]
#[diag(codegen_ssa_atomic_compare_exchange)]
pub struct AtomicCompareExchange;
pub(crate) struct AtomicCompareExchange;
#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_atomic_operation)]
pub struct UnknownAtomicOperation;
pub(crate) struct UnknownAtomicOperation;
#[derive(Diagnostic)]
pub enum InvalidMonomorphization<'tcx> {
@ -986,7 +987,7 @@ fn into_diag_arg(self) -> DiagArgValue {
#[derive(Diagnostic)]
#[diag(codegen_ssa_invalid_no_sanitize)]
#[note]
pub struct InvalidNoSanitize {
pub(crate) struct InvalidNoSanitize {
#[primary_span]
pub span: Span,
}
@ -994,7 +995,7 @@ pub struct InvalidNoSanitize {
#[derive(Diagnostic)]
#[diag(codegen_ssa_invalid_link_ordinal_nargs)]
#[note]
pub struct InvalidLinkOrdinalNargs {
pub(crate) struct InvalidLinkOrdinalNargs {
#[primary_span]
pub span: Span,
}
@ -1002,14 +1003,14 @@ pub struct InvalidLinkOrdinalNargs {
#[derive(Diagnostic)]
#[diag(codegen_ssa_illegal_link_ordinal_format)]
#[note]
pub struct InvalidLinkOrdinalFormat {
pub(crate) struct InvalidLinkOrdinalFormat {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(codegen_ssa_target_feature_safe_trait)]
pub struct TargetFeatureSafeTrait {
pub(crate) struct TargetFeatureSafeTrait {
#[primary_span]
#[label]
pub span: Span,
@ -1050,7 +1051,7 @@ pub(crate) struct ErrorCallingDllTool<'a> {
#[derive(Diagnostic)]
#[diag(codegen_ssa_error_creating_remark_dir)]
pub struct ErrorCreatingRemarkDir {
pub(crate) struct ErrorCreatingRemarkDir {
pub error: std::io::Error,
}

View File

@ -128,7 +128,7 @@ pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
}
}
pub struct CachedModuleCodegen {
pub(crate) struct CachedModuleCodegen {
pub name: String,
pub source: WorkProduct,
}

View File

@ -8,10 +8,10 @@
use crate::traits::*;
#[derive(Copy, Clone, Debug)]
pub struct VirtualIndex(u64);
pub(crate) struct VirtualIndex(u64);
impl<'a, 'tcx> VirtualIndex {
pub fn from_index(index: usize) -> Self {
pub(crate) fn from_index(index: usize) -> Self {
VirtualIndex(index as u64)
}
@ -51,7 +51,7 @@ fn get_fn_inner<Bx: BuilderMethods<'a, 'tcx>>(
}
}
pub fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
self,
bx: &mut Bx,
llvtable: Bx::Value,
@ -61,7 +61,7 @@ pub fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(
self.get_fn_inner(bx, llvtable, ty, fn_abi, false)
}
pub fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
self,
bx: &mut Bx,
llvtable: Bx::Value,
@ -71,7 +71,7 @@ pub fn get_fn<Bx: BuilderMethods<'a, 'tcx>>(
self.get_fn_inner(bx, llvtable, ty, fn_abi, true)
}
pub fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
pub(crate) fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
self,
bx: &mut Bx,
llvtable: Bx::Value,
@ -115,7 +115,7 @@ fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> {
/// making an object `Foo<dyn Trait>` from a value of type `Foo<T>`, then
/// `trait_ref` would map `T: Trait`.
#[instrument(level = "debug", skip(cx))]
pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
pub(crate) fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
cx: &Cx,
ty: Ty<'tcx>,
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,

View File

@ -1215,7 +1215,7 @@ fn codegen_asm_terminator(
}
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
pub(crate) fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
let llbb = match self.try_llbb(bb) {
Some(llbb) => llbb,
None => return,
@ -1255,7 +1255,7 @@ pub fn codegen_block(&mut self, mut bb: mir::BasicBlock) {
}
}
pub fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
pub(crate) fn codegen_block_as_unreachable(&mut self, bb: mir::BasicBlock) {
let llbb = match self.try_llbb(bb) {
Some(llbb) => llbb,
None => return,
@ -1740,7 +1740,7 @@ pub fn llbb(&mut self, bb: mir::BasicBlock) -> Bx::BasicBlock {
}
/// Like `llbb`, but may fail if the basic block should be skipped.
pub fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
pub(crate) fn try_llbb(&mut self, bb: mir::BasicBlock) -> Option<Bx::BasicBlock> {
match self.cached_llbbs[bb] {
CachedLlbb::None => {
let llbb = Bx::append_block(self.cx, self.llfn, &format!("{bb:?}"));

View File

@ -10,7 +10,7 @@
use crate::traits::*;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn eval_mir_constant_to_operand(
pub(crate) fn eval_mir_constant_to_operand(
&self,
bx: &mut Bx,
constant: &mir::ConstOperand<'tcx>,
@ -33,7 +33,7 @@ pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::Cons
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
///
/// Note that this function is cursed, since usually MIR consts should not be evaluated to valtrees!
pub fn eval_unevaluated_mir_constant_to_valtree(
fn eval_unevaluated_mir_constant_to_valtree(
&self,
constant: &mir::ConstOperand<'tcx>,
) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> {

View File

@ -5,7 +5,7 @@
use crate::traits::*;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
pub(crate) fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
// Determine the instance that coverage data was originally generated for.
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
self.monomorphize(inlined)

View File

@ -243,7 +243,7 @@ fn spill_operand_to_stack(
/// Apply debuginfo and/or name, after creating the `alloca` for a local,
/// or initializing the local with an operand (whichever applies).
pub fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
pub(crate) fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full;
let vars = match &self.per_local_var_debug_info {
@ -426,7 +426,7 @@ fn debug_introduce_local_as_var(
}
}
pub fn debug_introduce_locals(&self, bx: &mut Bx) {
pub(crate) fn debug_introduce_locals(&self, bx: &mut Bx) {
if bx.sess().opts.debuginfo == DebugInfo::Full || !bx.sess().fewer_names() {
for local in self.locals.indices() {
self.debug_introduce_local(bx, local);
@ -435,7 +435,7 @@ pub fn debug_introduce_locals(&self, bx: &mut Bx) {
}
/// Partition all `VarDebugInfo` in `self.mir`, by their base `Local`.
pub fn compute_per_local_var_debug_info(
pub(crate) fn compute_per_local_var_debug_info(
&self,
bx: &mut Bx,
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {

View File

@ -15,8 +15,8 @@
mod analyze;
mod block;
pub mod constant;
pub mod coverageinfo;
mod constant;
mod coverageinfo;
pub mod debuginfo;
mod intrinsic;
mod locals;

View File

@ -64,7 +64,7 @@ impl<V: CodegenObject> OperandValue<V> {
/// If this is ZeroSized/Immediate/Pair, return an array of the 0/1/2 values.
/// If this is Ref, return the place.
#[inline]
pub fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
pub(crate) fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
match self {
OperandValue::ZeroSized => Either::Left(ArrayVec::new()),
OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])),
@ -75,7 +75,7 @@ pub fn immediates_or_place(self) -> Either<ArrayVec<V, 2>, PlaceValue<V>> {
/// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair.
#[inline]
pub fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
pub(crate) fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
let mut it = immediates.into_iter();
let Some(a) = it.next() else {
return OperandValue::ZeroSized;
@ -90,7 +90,7 @@ pub fn from_immediates(immediates: ArrayVec<V, 2>) -> Self {
/// optional metadata as backend values.
///
/// If you're making a place, use [`Self::deref`] instead.
pub fn pointer_parts(self) -> (V, Option<V>) {
pub(crate) fn pointer_parts(self) -> (V, Option<V>) {
match self {
OperandValue::Immediate(llptr) => (llptr, None),
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
@ -105,7 +105,7 @@ pub fn pointer_parts(self) -> (V, Option<V>) {
/// alignment, then maybe you want [`OperandRef::deref`] instead.
///
/// This is the inverse of [`PlaceValue::address`].
pub fn deref(self, align: Align) -> PlaceValue<V> {
pub(crate) fn deref(self, align: Align) -> PlaceValue<V> {
let (llval, llextra) = self.pointer_parts();
PlaceValue { llval, llextra, align }
}
@ -153,7 +153,7 @@ pub fn zero_sized(layout: TyAndLayout<'tcx>) -> OperandRef<'tcx, V> {
OperandRef { val: OperandValue::ZeroSized, layout }
}
pub fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
pub(crate) fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
bx: &mut Bx,
val: mir::ConstValue<'tcx>,
ty: Ty<'tcx>,
@ -334,7 +334,7 @@ pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
OperandRef { val, layout }
}
pub fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
pub(crate) fn extract_field<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
&self,
bx: &mut Bx,
i: usize,

View File

@ -19,7 +19,7 @@
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
#[instrument(level = "trace", skip(self, bx))]
pub fn codegen_rvalue(
pub(crate) fn codegen_rvalue(
&mut self,
bx: &mut Bx,
dest: PlaceRef<'tcx, Bx::Value>,
@ -419,7 +419,7 @@ fn assume_scalar_range(
}
}
pub fn codegen_rvalue_unsized(
pub(crate) fn codegen_rvalue_unsized(
&mut self,
bx: &mut Bx,
indirect_dest: PlaceRef<'tcx, Bx::Value>,
@ -440,7 +440,7 @@ pub fn codegen_rvalue_unsized(
}
}
pub fn codegen_rvalue_operand(
pub(crate) fn codegen_rvalue_operand(
&mut self,
bx: &mut Bx,
rvalue: &mir::Rvalue<'tcx>,
@ -836,7 +836,7 @@ fn codegen_place_to_pointer(
OperandRef { val, layout: self.cx.layout_of(mk_ptr_ty(self.cx.tcx(), ty)) }
}
pub fn codegen_scalar_binop(
fn codegen_scalar_binop(
&mut self,
bx: &mut Bx,
op: mir::BinOp,
@ -981,7 +981,7 @@ pub fn codegen_scalar_binop(
}
}
pub fn codegen_fat_ptr_binop(
fn codegen_fat_ptr_binop(
&mut self,
bx: &mut Bx,
op: mir::BinOp,
@ -1023,7 +1023,7 @@ pub fn codegen_fat_ptr_binop(
}
}
pub fn codegen_scalar_checked_binop(
fn codegen_scalar_checked_binop(
&mut self,
bx: &mut Bx,
op: mir::BinOp,
@ -1050,7 +1050,7 @@ pub fn codegen_scalar_checked_binop(
}
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
pub(crate) fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) -> bool {
match *rvalue {
mir::Rvalue::Cast(mir::CastKind::Transmute, ref operand, cast_ty) => {
let operand_ty = operand.ty(self.mir, self.cx.tcx());

View File

@ -7,7 +7,7 @@
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
#[instrument(level = "debug", skip(self, bx))]
pub fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
pub(crate) fn codegen_statement(&mut self, bx: &mut Bx, statement: &mir::Statement<'tcx>) {
self.set_debug_loc(bx, statement.source_info);
match statement.kind {
mir::StatementKind::Assign(box (ref place, ref rvalue)) => {

View File

@ -15,7 +15,7 @@
use crate::errors;
pub fn from_target_feature(
pub(crate) fn from_target_feature(
tcx: TyCtxt<'_>,
attr: &ast::Attribute,
supported_target_features: &UnordMap<String, Option<Symbol>>,
@ -146,7 +146,7 @@ fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
/// Checks the function annotated with `#[target_feature]` is not a safe
/// trait method implementation, reporting an error if it is.
pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
pub(crate) fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) {
if let DefKind::AssocFn = tcx.def_kind(id) {
let parent_id = tcx.local_parent(id);
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {