1
Fork 0

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 @@ pub trait ArchiveBuilderBuilder {
} }
} }
pub fn create_mingw_dll_import_lib( fn create_mingw_dll_import_lib(
sess: &Session, sess: &Session,
lib_name: &str, lib_name: &str,
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>, import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,

View file

@ -8,7 +8,7 @@ use std::{fmt, io, mem};
use rustc_target::spec::LldFlavor; use rustc_target::spec::LldFlavor;
#[derive(Clone)] #[derive(Clone)]
pub struct Command { pub(crate) struct Command {
program: Program, program: Program,
args: Vec<OsString>, args: Vec<OsString>,
env: Vec<(OsString, OsString)>, env: Vec<(OsString, OsString)>,
@ -23,15 +23,15 @@ enum Program {
} }
impl Command { 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())) 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())) 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)) Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
} }
@ -39,12 +39,12 @@ impl Command {
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() } 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._arg(arg.as_ref());
self self
} }
pub fn args<I>(&mut self, args: I) -> &mut Command pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
where where
I: IntoIterator<Item: AsRef<OsStr>>, I: IntoIterator<Item: AsRef<OsStr>>,
{ {
@ -58,7 +58,7 @@ impl Command {
self.args.push(arg.to_owned()); 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 where
K: AsRef<OsStr>, K: AsRef<OsStr>,
V: AsRef<OsStr>, V: AsRef<OsStr>,
@ -71,7 +71,7 @@ impl Command {
self.env.push((key.to_owned(), value.to_owned())); 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 where
K: AsRef<OsStr>, K: AsRef<OsStr>,
{ {
@ -83,11 +83,11 @@ impl Command {
self.env_remove.push(key.to_owned()); 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() self.command().output()
} }
pub fn command(&self) -> process::Command { pub(crate) fn command(&self) -> process::Command {
let mut ret = match self.program { let mut ret = match self.program {
Program::Normal(ref p) => process::Command::new(p), Program::Normal(ref p) => process::Command::new(p),
Program::CmdBatScript(ref p) => { Program::CmdBatScript(ref p) => {
@ -111,17 +111,17 @@ impl Command {
// extensions // extensions
pub fn get_args(&self) -> &[OsString] { pub(crate) fn get_args(&self) -> &[OsString] {
&self.args &self.args
} }
pub fn take_args(&mut self) -> Vec<OsString> { pub(crate) fn take_args(&mut self) -> Vec<OsString> {
mem::take(&mut self.args) mem::take(&mut self.args)
} }
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits, /// 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. /// 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 // 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 // can be gargantuan anyway so we're pretty unlikely to hit them
if cfg!(unix) { if cfg!(unix) {

View file

@ -28,7 +28,7 @@ use crate::errors;
/// and prevent inspection of linker output in case of errors, which we occasionally do. /// 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, /// 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. /// 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. // No harm in setting both env vars simultaneously.
// Unix-style linkers. // Unix-style linkers.
linker.env("LC_ALL", "C"); 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 /// 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 /// path for MSVC to find its DLLs, and gcc to find its bundled
/// toolchain /// toolchain
pub fn get_linker<'a>( pub(crate) fn get_linker<'a>(
sess: &'a Session, sess: &'a Session,
linker: &Path, linker: &Path,
flavor: LinkerFlavor, flavor: LinkerFlavor,
@ -213,28 +213,36 @@ fn link_or_cc_args<L: Linker + ?Sized>(
macro_rules! generate_arg_methods { macro_rules! generate_arg_methods {
($($ty:ty)*) => { $( ($($ty:ty)*) => { $(
impl $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) 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)) 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) 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)) 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) 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)) 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) 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)) link_or_cc_args(self, iter::once(arg))
} }
} }
@ -261,7 +269,7 @@ generate_arg_methods! {
/// represents the meaning of each option being passed down. This trait is then /// 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 /// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
/// MSVC linker (e.g., `link.exe`) is being used. /// MSVC linker (e.g., `link.exe`) is being used.
pub trait Linker { pub(crate) trait Linker {
fn cmd(&mut self) -> &mut Command; fn cmd(&mut self) -> &mut Command;
fn is_cc(&self) -> bool { fn is_cc(&self) -> bool {
false false
@ -312,12 +320,12 @@ pub trait Linker {
} }
impl dyn Linker + '_ { impl dyn Linker + '_ {
pub fn take_cmd(&mut self) -> Command { pub(crate) fn take_cmd(&mut self) -> Command {
mem::replace(self.cmd(), Command::new("")) mem::replace(self.cmd(), Command::new(""))
} }
} }
pub struct GccLinker<'a> { struct GccLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
target_cpu: &'a str, target_cpu: &'a str,
@ -847,7 +855,7 @@ impl<'a> Linker for GccLinker<'a> {
} }
} }
pub struct MsvcLinker<'a> { struct MsvcLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }
@ -1095,7 +1103,7 @@ impl<'a> Linker for MsvcLinker<'a> {
} }
} }
pub struct EmLinker<'a> { struct EmLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }
@ -1212,7 +1220,7 @@ impl<'a> Linker for EmLinker<'a> {
} }
} }
pub struct WasmLd<'a> { struct WasmLd<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }
@ -1396,7 +1404,7 @@ impl<'a> WasmLd<'a> {
} }
/// Linker shepherd script for L4Re (Fiasco) /// Linker shepherd script for L4Re (Fiasco)
pub struct L4Bender<'a> { struct L4Bender<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
hinted_static: bool, hinted_static: bool,
@ -1502,7 +1510,7 @@ impl<'a> Linker for L4Bender<'a> {
} }
impl<'a> L4Bender<'a> { 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 } L4Bender { cmd, sess, hinted_static: false }
} }
@ -1515,14 +1523,14 @@ impl<'a> L4Bender<'a> {
} }
/// Linker for AIX. /// Linker for AIX.
pub struct AixLinker<'a> { struct AixLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
hinted_static: Option<bool>, hinted_static: Option<bool>,
} }
impl<'a> AixLinker<'a> { 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 } 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 /// Much simplified and explicit CLI for the NVPTX linker. The linker operates
/// with bitcode and uses LLVM backend to generate a PTX assembly. /// with bitcode and uses LLVM backend to generate a PTX assembly.
pub struct PtxLinker<'a> { struct PtxLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }
@ -1816,7 +1824,7 @@ impl<'a> Linker for PtxLinker<'a> {
} }
/// The `self-contained` LLVM bitcode linker /// The `self-contained` LLVM bitcode linker
pub struct LlbcLinker<'a> { struct LlbcLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }
@ -1887,7 +1895,7 @@ impl<'a> Linker for LlbcLinker<'a> {
fn linker_plugin_lto(&mut self) {} fn linker_plugin_lto(&mut self) {}
} }
pub struct BpfLinker<'a> { struct BpfLinker<'a> {
cmd: Command, cmd: Command,
sess: &'a Session, sess: &'a Session,
} }

View file

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

View file

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

View file

@ -6,14 +6,14 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_fs_util::try_canonicalize; use rustc_fs_util::try_canonicalize;
use tracing::debug; use tracing::debug;
pub struct RPathConfig<'a> { pub(super) struct RPathConfig<'a> {
pub libs: &'a [&'a Path], pub libs: &'a [&'a Path],
pub out_filename: PathBuf, pub out_filename: PathBuf,
pub is_like_osx: bool, pub is_like_osx: bool,
pub linker_is_gnu: 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!"); debug!("preparing the RPATH!");
let rpaths = get_rpaths(config); let rpaths = get_rpaths(config);

View file

@ -18,7 +18,7 @@ use tracing::debug;
use crate::base::allocator_kind_for_codegen; use crate::base::allocator_kind_for_codegen;
pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel { fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
crates_export_threshold(tcx.crate_types()) 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) !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.reachable_non_generics = reachable_non_generics_provider;
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local; providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
providers.exported_symbols = exported_symbols_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. /// 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>, tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>, symbol: ExportedSymbol<'tcx>,
instantiating_crate: CrateNum, 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. /// 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. /// 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>, tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>, symbol: ExportedSymbol<'tcx>,
instantiating_crate: CrateNum, instantiating_crate: CrateNum,
@ -661,7 +661,7 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
format!("{prefix}{undecorated}{suffix}{args_in_bytes}") 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>, tcx: TyCtxt<'tcx>,
symbol: ExportedSymbol<'tcx>, symbol: ExportedSymbol<'tcx>,
cnum: CrateNum, cnum: CrateNum,

View file

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

View file

@ -44,7 +44,7 @@ use crate::{
errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind, 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 { match op {
BinOp::Eq => IntPredicate::IntEQ, BinOp::Eq => IntPredicate::IntEQ,
BinOp::Ne => IntPredicate::IntNE, 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 { match op {
BinOp::Eq => RealPredicate::RealOEQ, BinOp::Eq => RealPredicate::RealOEQ,
BinOp::Ne => RealPredicate::RealUNE, 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, /// 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. /// 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, bx: &mut Bx,
source: Ty<'tcx>, source: Ty<'tcx>,
target: 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. /// 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, bx: &mut Bx,
src: Bx::Value, src: Bx::Value,
src_ty: Ty<'tcx>, 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. /// 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, bx: &mut Bx,
src: Bx::Value, src: Bx::Value,
src_ty_and_layout: TyAndLayout<'tcx>, 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`, /// 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`. /// 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, bx: &mut Bx,
src: PlaceRef<'tcx, Bx::Value>, src: PlaceRef<'tcx, Bx::Value>,
dst: 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` /// 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. /// 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, bx: &mut Bx,
lhs: Bx::Value, lhs: Bx::Value,
mut rhs: 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 /// Returns `true` if this session's target requires the new exception
/// handling LLVM IR instructions (catchpad / cleanuppad / ... instead /// handling LLVM IR instructions (catchpad / cleanuppad / ... instead
/// of landingpad) /// 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) 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, cx: &'a Bx::CodegenCx,
instance: Instance<'tcx>, instance: Instance<'tcx>,
) { ) {
@ -999,7 +999,7 @@ impl CrateInfo {
} }
} }
pub fn provide(providers: &mut Providers) { pub(crate) fn provide(providers: &mut Providers) {
providers.backend_optimization_level = |tcx, cratenum| { providers.backend_optimization_level = |tcx, cratenum| {
let for_speed = match tcx.sess.opts.optimize { let for_speed = match tcx.sess.opts.optimize {
// If globally no optimisation is done, #[optimize] has no effect. // 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 }; *providers = Providers { codegen_fn_attrs, should_inherit_track_caller, ..*providers };
} }

View file

@ -118,7 +118,7 @@ mod temp_stable_hash_impls {
} }
} }
pub fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( pub(crate) fn build_langcall<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &Bx, bx: &Bx,
span: Option<Span>, span: Option<Span>,
li: LangItem, 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) (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, bx: &mut Bx,
llty: Bx::Type, llty: Bx::Type,
mask_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>, tcx: TyCtxt<'tcx>,
enum_type_and_layout: TyAndLayout<'tcx>, enum_type_and_layout: TyAndLayout<'tcx>,
) -> Option<Ty<'tcx>> { ) -> Option<Ty<'tcx>> {

View file

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

View file

@ -128,7 +128,7 @@ impl CompiledModule {
} }
} }
pub struct CachedModuleCodegen { pub(crate) struct CachedModuleCodegen {
pub name: String, pub name: String,
pub source: WorkProduct, pub source: WorkProduct,
} }

View file

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

View file

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

View file

@ -10,7 +10,7 @@ use crate::mir::operand::OperandRef;
use crate::traits::*; use crate::traits::*;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { 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, &self,
bx: &mut Bx, bx: &mut Bx,
constant: &mir::ConstOperand<'tcx>, constant: &mir::ConstOperand<'tcx>,
@ -33,7 +33,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip. /// 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! /// 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, &self,
constant: &mir::ConstOperand<'tcx>, constant: &mir::ConstOperand<'tcx>,
) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> { ) -> Result<Result<ty::ValTree<'tcx>, Ty<'tcx>>, ErrorHandled> {

View file

@ -5,7 +5,7 @@ use super::FunctionCx;
use crate::traits::*; use crate::traits::*;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { 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. // Determine the instance that coverage data was originally generated for.
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) { let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
self.monomorphize(inlined) self.monomorphize(inlined)

View file

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

View file

@ -15,8 +15,8 @@ use crate::traits::*;
mod analyze; mod analyze;
mod block; mod block;
pub mod constant; mod constant;
pub mod coverageinfo; mod coverageinfo;
pub mod debuginfo; pub mod debuginfo;
mod intrinsic; mod intrinsic;
mod locals; 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 ZeroSized/Immediate/Pair, return an array of the 0/1/2 values.
/// If this is Ref, return the place. /// If this is Ref, return the place.
#[inline] #[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 { match self {
OperandValue::ZeroSized => Either::Left(ArrayVec::new()), OperandValue::ZeroSized => Either::Left(ArrayVec::new()),
OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])), OperandValue::Immediate(a) => Either::Left(ArrayVec::from_iter([a])),
@ -75,7 +75,7 @@ impl<V: CodegenObject> OperandValue<V> {
/// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair. /// Given an array of 0/1/2 immediate values, return ZeroSized/Immediate/Pair.
#[inline] #[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 mut it = immediates.into_iter();
let Some(a) = it.next() else { let Some(a) = it.next() else {
return OperandValue::ZeroSized; return OperandValue::ZeroSized;
@ -90,7 +90,7 @@ impl<V: CodegenObject> OperandValue<V> {
/// optional metadata as backend values. /// optional metadata as backend values.
/// ///
/// If you're making a place, use [`Self::deref`] instead. /// 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 { match self {
OperandValue::Immediate(llptr) => (llptr, None), OperandValue::Immediate(llptr) => (llptr, None),
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)), OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
@ -105,7 +105,7 @@ impl<V: CodegenObject> OperandValue<V> {
/// alignment, then maybe you want [`OperandRef::deref`] instead. /// alignment, then maybe you want [`OperandRef::deref`] instead.
/// ///
/// This is the inverse of [`PlaceValue::address`]. /// 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(); let (llval, llextra) = self.pointer_parts();
PlaceValue { llval, llextra, align } PlaceValue { llval, llextra, align }
} }
@ -153,7 +153,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
OperandRef { val: OperandValue::ZeroSized, layout } 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, bx: &mut Bx,
val: mir::ConstValue<'tcx>, val: mir::ConstValue<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
@ -334,7 +334,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
OperandRef { val, layout } 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, &self,
bx: &mut Bx, bx: &mut Bx,
i: usize, i: usize,

View file

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

View file

@ -7,7 +7,7 @@ use crate::traits::*;
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
#[instrument(level = "debug", skip(self, 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); self.set_debug_loc(bx, statement.source_info);
match statement.kind { match statement.kind {
mir::StatementKind::Assign(box (ref place, ref rvalue)) => { mir::StatementKind::Assign(box (ref place, ref rvalue)) => {

View file

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