Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau

Add `unreachable_pub`, round 4

A follow-up to #129732.

r? `@Urgau`
This commit is contained in:
bors 2024-09-03 01:27:20 +00:00
commit 6199b69c53
363 changed files with 504 additions and 487 deletions

View File

@ -46,7 +46,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub fn needs_drop(
fn needs_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
@ -76,7 +76,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `NeedsNonConstDrop` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary
pub fn needs_non_const_drop(
pub(crate) fn needs_non_const_drop(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,
@ -106,7 +106,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
/// Returns `true` if `local` is `HasMutInterior` at the given `Location`.
///
/// Only updates the cursor if absolutely necessary.
pub fn has_mut_interior(
fn has_mut_interior(
&mut self,
ccx: &'mir ConstCx<'mir, 'tcx>,
local: Local,

View File

@ -57,7 +57,7 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
/// A function call where the callee is a pointer.
#[derive(Debug)]
pub struct FnCallIndirect;
pub(crate) struct FnCallIndirect;
impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::UnallowedFnPointerCall { span, kind: ccx.const_kind() })
@ -66,7 +66,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
/// A function call where the callee is not marked as `const`.
#[derive(Debug, Clone, Copy)]
pub struct FnCallNonConst<'tcx> {
pub(crate) struct FnCallNonConst<'tcx> {
pub caller: LocalDefId,
pub callee: DefId,
pub args: GenericArgsRef<'tcx>,
@ -299,7 +299,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
///
/// Contains the name of the feature that would allow the use of this function.
#[derive(Debug)]
pub struct FnCallUnstable(pub DefId, pub Option<Symbol>);
pub(crate) struct FnCallUnstable(pub DefId, pub Option<Symbol>);
impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
@ -324,7 +324,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
}
#[derive(Debug)]
pub struct Coroutine(pub hir::CoroutineKind);
pub(crate) struct Coroutine(pub hir::CoroutineKind);
impl<'tcx> NonConstOp<'tcx> for Coroutine {
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
if let hir::CoroutineKind::Desugared(
@ -356,7 +356,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
}
#[derive(Debug)]
pub struct HeapAllocation;
pub(crate) struct HeapAllocation;
impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::UnallowedHeapAllocations {
@ -368,7 +368,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
}
#[derive(Debug)]
pub struct InlineAsm;
pub(crate) struct InlineAsm;
impl<'tcx> NonConstOp<'tcx> for InlineAsm {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::UnallowedInlineAsm { span, kind: ccx.const_kind() })
@ -376,7 +376,7 @@ impl<'tcx> NonConstOp<'tcx> for InlineAsm {
}
#[derive(Debug)]
pub struct LiveDrop<'tcx> {
pub(crate) struct LiveDrop<'tcx> {
pub dropped_at: Option<Span>,
pub dropped_ty: Ty<'tcx>,
}
@ -394,7 +394,7 @@ impl<'tcx> NonConstOp<'tcx> for LiveDrop<'tcx> {
#[derive(Debug)]
/// A borrow of a type that contains an `UnsafeCell` somewhere. The borrow never escapes to
/// the final value of the constant.
pub struct TransientCellBorrow;
pub(crate) struct TransientCellBorrow;
impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
Status::Unstable(sym::const_refs_to_cell)
@ -410,7 +410,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
/// A borrow of a type that contains an `UnsafeCell` somewhere. The borrow might escape to
/// the final value of the constant, and thus we cannot allow this (for now). We may allow
/// it in the future for static items.
pub struct CellBorrow;
pub(crate) struct CellBorrow;
impl<'tcx> NonConstOp<'tcx> for CellBorrow {
fn importance(&self) -> DiagImportance {
// Most likely the code will try to do mutation with these borrows, which
@ -431,7 +431,7 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
/// This op is for `&mut` borrows in the trailing expression of a constant
/// which uses the "enclosing scopes rule" to leak its locals into anonymous
/// static or const items.
pub struct MutBorrow(pub hir::BorrowKind);
pub(crate) struct MutBorrow(pub hir::BorrowKind);
impl<'tcx> NonConstOp<'tcx> for MutBorrow {
fn status_in_item(&self, _ccx: &ConstCx<'_, 'tcx>) -> Status {
@ -461,7 +461,7 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
}
#[derive(Debug)]
pub struct TransientMutBorrow(pub hir::BorrowKind);
pub(crate) struct TransientMutBorrow(pub hir::BorrowKind);
impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow {
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
@ -484,7 +484,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow {
}
#[derive(Debug)]
pub struct MutDeref;
pub(crate) struct MutDeref;
impl<'tcx> NonConstOp<'tcx> for MutDeref {
fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
Status::Unstable(sym::const_mut_refs)
@ -505,7 +505,7 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref {
/// A call to a `panic()` lang item where the first argument is _not_ a `&str`.
#[derive(Debug)]
pub struct PanicNonStr;
pub(crate) struct PanicNonStr;
impl<'tcx> NonConstOp<'tcx> for PanicNonStr {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::PanicNonStrErr { span })
@ -516,7 +516,7 @@ impl<'tcx> NonConstOp<'tcx> for PanicNonStr {
/// Not currently intended to ever be allowed, even behind a feature gate: operation depends on
/// allocation base addresses that are not known at compile-time.
#[derive(Debug)]
pub struct RawPtrComparison;
pub(crate) struct RawPtrComparison;
impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
// FIXME(const_trait_impl): revert to span_bug?
@ -525,7 +525,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
}
#[derive(Debug)]
pub struct RawMutPtrDeref;
pub(crate) struct RawMutPtrDeref;
impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
Status::Unstable(sym::const_mut_refs)
@ -546,7 +546,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
/// Not currently intended to ever be allowed, even behind a feature gate: operation depends on
/// allocation base addresses that are not known at compile-time.
#[derive(Debug)]
pub struct RawPtrToIntCast;
pub(crate) struct RawPtrToIntCast;
impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::RawPtrToIntErr { span })
@ -555,7 +555,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
/// An access to a (non-thread-local) `static`.
#[derive(Debug)]
pub struct StaticAccess;
pub(crate) struct StaticAccess;
impl<'tcx> NonConstOp<'tcx> for StaticAccess {
fn status_in_item(&self, ccx: &ConstCx<'_, 'tcx>) -> Status {
if let hir::ConstContext::Static(_) = ccx.const_kind() {
@ -582,7 +582,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
/// An access to a thread-local `static`.
#[derive(Debug)]
pub struct ThreadLocalAccess;
pub(crate) struct ThreadLocalAccess;
impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
ccx.dcx().create_err(errors::ThreadLocalAccessErr { span })
@ -590,11 +590,11 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
}
/// Types that cannot appear in the signature or locals of a `const fn`.
pub mod mut_ref {
pub(crate) mod mut_ref {
use super::*;
#[derive(Debug)]
pub struct MutRef(pub mir::LocalKind);
pub(crate) struct MutRef(pub mir::LocalKind);
impl<'tcx> NonConstOp<'tcx> for MutRef {
fn status_in_item(&self, _ccx: &ConstCx<'_, 'tcx>) -> Status {
Status::Unstable(sym::const_mut_refs)

View File

@ -61,13 +61,13 @@ pub(super) struct MemPlace<Prov: Provenance = CtfeProvenance> {
impl<Prov: Provenance> MemPlace<Prov> {
/// Adjust the provenance of the main pointer (metadata is unaffected).
pub fn map_provenance(self, f: impl FnOnce(Prov) -> Prov) -> Self {
fn map_provenance(self, f: impl FnOnce(Prov) -> Prov) -> Self {
MemPlace { ptr: self.ptr.map_provenance(|p| p.map(f)), ..self }
}
/// Turn a mplace into a (thin or wide) pointer, as a reference, pointing to the same space.
#[inline]
pub fn to_ref(self, cx: &impl HasDataLayout) -> Immediate<Prov> {
fn to_ref(self, cx: &impl HasDataLayout) -> Immediate<Prov> {
Immediate::new_pointer_with_meta(self.ptr, self.meta, cx)
}

View File

@ -14,6 +14,7 @@
#![feature(trait_alias)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod check_consts;

View File

@ -26,11 +26,11 @@ use crate::cfi::typeid::itanium_cxx_abi::transform::{TransformTy, TransformTyOpt
use crate::cfi::typeid::TypeIdOptions;
/// Options for encode_ty.
pub type EncodeTyOptions = TypeIdOptions;
pub(crate) type EncodeTyOptions = TypeIdOptions;
/// Substitution dictionary key.
#[derive(Eq, Hash, PartialEq)]
pub enum DictKey<'tcx> {
pub(crate) enum DictKey<'tcx> {
Ty(Ty<'tcx>, TyQ),
Region(Region<'tcx>),
Const(Const<'tcx>),
@ -39,7 +39,7 @@ pub enum DictKey<'tcx> {
/// Type and extended type qualifiers.
#[derive(Eq, Hash, PartialEq)]
pub enum TyQ {
pub(crate) enum TyQ {
None,
Const,
Mut,

View File

@ -23,16 +23,16 @@ use crate::cfi::typeid::itanium_cxx_abi::encode::EncodeTyOptions;
use crate::cfi::typeid::TypeIdOptions;
/// Options for transform_ty.
pub type TransformTyOptions = TypeIdOptions;
pub(crate) type TransformTyOptions = TypeIdOptions;
pub struct TransformTy<'tcx> {
pub(crate) struct TransformTy<'tcx> {
tcx: TyCtxt<'tcx>,
options: TransformTyOptions,
parents: Vec<Ty<'tcx>>,
}
impl<'tcx> TransformTy<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, options: TransformTyOptions) -> Self {
pub(crate) fn new(tcx: TyCtxt<'tcx>, options: TransformTyOptions) -> Self {
TransformTy { tcx, options, parents: Vec::new() }
}
}

View File

@ -5,6 +5,7 @@
// tidy-alphabetical-start
#![feature(let_chains)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod cfi;

View File

@ -16,6 +16,7 @@
#![feature(never_type)]
#![feature(ptr_sub_ptr)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub use self::serialize::{Decodable, Decoder, Encodable, Encoder};

View File

@ -5,6 +5,7 @@
#![feature(map_many_mut)]
#![feature(option_get_or_insert_default)]
#![feature(rustc_attrs)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod errors;

View File

@ -358,94 +358,98 @@ fn build_options<O: Default>(
#[allow(non_upper_case_globals)]
mod desc {
pub const parse_no_flag: &str = "no value";
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
pub const parse_opt_bool: &str = parse_bool;
pub const parse_string: &str = "a string";
pub const parse_opt_string: &str = parse_string;
pub const parse_string_push: &str = parse_string;
pub const parse_opt_langid: &str = "a language identifier";
pub const parse_opt_pathbuf: &str = "a path";
pub const parse_list: &str = "a space-separated list of strings";
pub const parse_list_with_polarity: &str =
pub(crate) const parse_no_flag: &str = "no value";
pub(crate) const parse_bool: &str =
"one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
pub(crate) const parse_opt_bool: &str = parse_bool;
pub(crate) const parse_string: &str = "a string";
pub(crate) const parse_opt_string: &str = parse_string;
pub(crate) const parse_string_push: &str = parse_string;
pub(crate) const parse_opt_langid: &str = "a language identifier";
pub(crate) const parse_opt_pathbuf: &str = "a path";
pub(crate) const parse_list: &str = "a space-separated list of strings";
pub(crate) const parse_list_with_polarity: &str =
"a comma-separated list of strings, with elements beginning with + or -";
pub const parse_comma_list: &str = "a comma-separated list of strings";
pub const parse_opt_comma_list: &str = parse_comma_list;
pub const parse_number: &str = "a number";
pub const parse_opt_number: &str = parse_number;
pub const parse_frame_pointer: &str = "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf` or `always`";
pub const parse_threads: &str = parse_number;
pub const parse_time_passes_format: &str = "`text` (default) or `json`";
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
pub const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`";
pub const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)";
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
pub const parse_oom_strategy: &str = "either `panic` or `abort`";
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, or `thread`";
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
pub const parse_cfguard: &str =
pub(crate) const parse_comma_list: &str = "a comma-separated list of strings";
pub(crate) const parse_opt_comma_list: &str = parse_comma_list;
pub(crate) const parse_number: &str = "a number";
pub(crate) const parse_opt_number: &str = parse_number;
pub(crate) const parse_frame_pointer: &str = "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf` or `always`";
pub(crate) const parse_threads: &str = parse_number;
pub(crate) const parse_time_passes_format: &str = "`text` (default) or `json`";
pub(crate) const parse_passes: &str = "a space-separated list of passes, or `all`";
pub(crate) const parse_panic_strategy: &str = "either `unwind` or `abort`";
pub(crate) const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`";
pub(crate) const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)";
pub(crate) const parse_opt_panic_strategy: &str = parse_panic_strategy;
pub(crate) const parse_oom_strategy: &str = "either `panic` or `abort`";
pub(crate) const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
pub(crate) const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, or `thread`";
pub(crate) const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
pub(crate) const parse_cfguard: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
pub const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
pub const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
pub const parse_debuginfo_compression: &str = "one of `none`, `zlib`, or `zstd`";
pub const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
pub const parse_optimization_fuel: &str = "crate=integer";
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
pub const parse_instrument_coverage: &str = parse_bool;
pub const parse_coverage_options: &str =
pub(crate) const parse_cfprotection: &str = "`none`|`no`|`n` (default), `branch`, `return`, or `full`|`yes`|`y` (equivalent to `branch` and `return`)";
pub(crate) const parse_debuginfo: &str = "either an integer (0, 1, 2), `none`, `line-directives-only`, `line-tables-only`, `limited`, or `full`";
pub(crate) const parse_debuginfo_compression: &str = "one of `none`, `zlib`, or `zstd`";
pub(crate) const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
pub(crate) const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
pub(crate) const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
pub(crate) const parse_optimization_fuel: &str = "crate=integer";
pub(crate) const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
pub(crate) const parse_instrument_coverage: &str = parse_bool;
pub(crate) const parse_coverage_options: &str =
"`block` | `branch` | `condition` | `mcdc` | `no-mir-spans`";
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
pub const parse_unpretty: &str = "`string` or `string=string`";
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
pub const parse_next_solver_config: &str =
pub(crate) const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
pub(crate) const parse_next_solver_config: &str =
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
pub const parse_lto: &str =
pub(crate) const parse_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
pub const parse_linker_plugin_lto: &str =
pub(crate) const parse_linker_plugin_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
pub const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
pub const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
pub const parse_switch_with_opt_path: &str =
pub(crate) const parse_location_detail: &str = "either `none`, or a comma separated list of location details to track: `file`, `line`, or `column`";
pub(crate) const parse_fmt_debug: &str = "either `full`, `shallow`, or `none`";
pub(crate) const parse_switch_with_opt_path: &str =
"an optional path to the profiling data output directory";
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
pub const parse_symbol_mangling_version: &str =
pub(crate) const parse_merge_functions: &str =
"one of: `disabled`, `trampolines`, or `aliases`";
pub(crate) const parse_symbol_mangling_version: &str =
"one of: `legacy`, `v0` (RFC 2603), or `hashed`";
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
pub const parse_relocation_model: &str =
pub(crate) const parse_src_file_hash: &str = "either `md5` or `sha1`";
pub(crate) const parse_relocation_model: &str =
"one of supported relocation models (`rustc --print relocation-models`)";
pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
pub const parse_target_feature: &str = parse_string;
pub const parse_terminal_url: &str =
pub(crate) const parse_code_model: &str =
"one of supported code models (`rustc --print code-models`)";
pub(crate) const parse_tls_model: &str =
"one of supported TLS models (`rustc --print tls-models`)";
pub(crate) const parse_target_feature: &str = parse_string;
pub(crate) const parse_terminal_url: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `auto`";
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
pub const parse_split_debuginfo: &str =
pub(crate) const parse_wasi_exec_model: &str = "either `command` or `reactor`";
pub(crate) const parse_split_debuginfo: &str =
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
pub const parse_split_dwarf_kind: &str =
pub(crate) const parse_split_dwarf_kind: &str =
"one of supported split dwarf modes (`split` or `single`)";
pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
pub(crate) const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
pub const parse_linker_features: &str =
pub(crate) const parse_linker_features: &str =
"a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld`";
pub const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
pub const parse_stack_protector: &str =
pub(crate) const parse_polonius: &str = "either no value or `legacy` (the default), or `next`";
pub(crate) const parse_stack_protector: &str =
"one of (`none` (default), `basic`, `strong`, or `all`)";
pub const parse_branch_protection: &str =
pub(crate) const parse_branch_protection: &str =
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
pub const parse_proc_macro_execution_strategy: &str =
pub(crate) const parse_proc_macro_execution_strategy: &str =
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
pub const parse_remap_path_scope: &str =
pub(crate) const parse_remap_path_scope: &str =
"comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`";
pub const parse_inlining_threshold: &str =
pub(crate) const parse_inlining_threshold: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
pub const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
pub const parse_function_return: &str = "`keep` or `thunk-extern`";
pub const parse_wasm_c_abi: &str = "`legacy` or `spec`";
pub const parse_mir_include_spans: &str =
pub(crate) const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
pub(crate) const parse_function_return: &str = "`keep` or `thunk-extern`";
pub(crate) const parse_wasm_c_abi: &str = "`legacy` or `spec`";
pub(crate) const parse_mir_include_spans: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
}

View File

@ -15,6 +15,7 @@
)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod rustc_internal;

View File

@ -20,7 +20,7 @@ fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation {
// because we need to get `Ty` of the const we are trying to create, to do that
// we need to have access to `ConstantKind` but we can't access that inside Stable impl.
#[allow(rustc::usage_of_qualified_ty)]
pub fn new_allocation<'tcx>(
pub(crate) fn new_allocation<'tcx>(
ty: rustc_middle::ty::Ty<'tcx>,
const_value: ConstValue<'tcx>,
tables: &mut Tables<'tcx>,
@ -30,7 +30,7 @@ pub fn new_allocation<'tcx>(
}
#[allow(rustc::usage_of_qualified_ty)]
pub fn try_new_allocation<'tcx>(
pub(crate) fn try_new_allocation<'tcx>(
ty: rustc_middle::ty::Ty<'tcx>,
const_value: ConstValue<'tcx>,
tables: &mut Tables<'tcx>,

View File

@ -12,13 +12,13 @@ use rustc_middle::ty::{self, TyCtxt};
use crate::rustc_smir::{Stable, Tables};
/// Builds a monomorphic body for a given instance.
pub struct BodyBuilder<'tcx> {
pub(crate) struct BodyBuilder<'tcx> {
tcx: TyCtxt<'tcx>,
instance: ty::Instance<'tcx>,
}
impl<'tcx> BodyBuilder<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>) -> Self {
pub(crate) fn new(tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>) -> Self {
let instance = match instance.def {
// To get the fallback body of an intrinsic, we need to convert it to an item.
ty::InstanceKind::Intrinsic(def_id) => ty::Instance::new(def_id, instance.args),
@ -30,7 +30,7 @@ impl<'tcx> BodyBuilder<'tcx> {
/// Build a stable monomorphic body for a given instance based on the MIR body.
///
/// All constants are also evaluated.
pub fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body {
pub(crate) fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body {
let body = tables.tcx.instance_mir(self.instance.def).clone();
let mono_body = if !self.instance.args.is_empty()
// Without the `generic_const_exprs` feature gate, anon consts in signatures do not

View File

@ -784,7 +784,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
}
}
pub struct TablesWrapper<'tcx>(pub RefCell<Tables<'tcx>>);
pub(crate) struct TablesWrapper<'tcx>(pub RefCell<Tables<'tcx>>);
/// Implement error handling for extracting function ABI information.
impl<'tcx> FnAbiOfHelpers<'tcx> for Tables<'tcx> {

View File

@ -9,7 +9,7 @@ mod error;
mod mir;
mod ty;
pub use ty::mir_const_from_ty_const;
pub(crate) use ty::mir_const_from_ty_const;
impl<'tcx> Stable<'tcx> for rustc_hir::Safety {
type T = stable_mir::mir::Safety;

View File

@ -411,7 +411,7 @@ impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
}
}
pub fn mir_const_from_ty_const<'tcx>(
pub(crate) fn mir_const_from_ty_const<'tcx>(
tables: &mut Tables<'tcx>,
ty_const: ty::Const<'tcx>,
ty: Ty<'tcx>,

View File

@ -8,7 +8,7 @@ mod tests;
///
/// This function will use an SSE2 enhanced implementation if hardware support
/// is detected at runtime.
pub fn analyze_source_file(src: &str) -> (Vec<RelativeBytePos>, Vec<MultiByteChar>) {
pub(crate) fn analyze_source_file(src: &str) -> (Vec<RelativeBytePos>, Vec<MultiByteChar>) {
let mut lines = vec![RelativeBytePos::from_u32(0)];
let mut multi_byte_chars = vec![];

View File

@ -30,6 +30,7 @@
#![feature(round_char_boundary)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
// The code produced by the `Encodable`/`Decodable` derive macros refer to

View File

@ -424,7 +424,7 @@ impl Span {
}
#[derive(Default)]
pub struct SpanInterner {
pub(crate) struct SpanInterner {
spans: FxIndexSet<SpanData>,
}

View File

@ -93,6 +93,7 @@
#![doc(rust_logo)]
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use rustc_hir::def::DefKind;

View File

@ -6,7 +6,7 @@ use crate::abi::{HasDataLayout, TyAbiInterface};
///
/// Corresponds to Clang's `AArch64ABIInfo::ABIKind`.
#[derive(Copy, Clone, PartialEq)]
pub enum AbiKind {
pub(crate) enum AbiKind {
AAPCS,
DarwinPCS,
Win64,
@ -109,7 +109,7 @@ where
arg.make_indirect();
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, kind: AbiKind)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, kind: AbiKind)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,

View File

@ -17,7 +17,7 @@ where
arg.extend_integer_width_to(32);
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,

View File

@ -81,7 +81,7 @@ where
arg.cast_to(Uniform::consecutive(if align <= 4 { Reg::i32() } else { Reg::i64() }, total));
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -44,7 +44,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) {
if !fty.ret.is_ignore() {
classify_ret_ty(&mut fty.ret);
}

View File

@ -17,7 +17,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -47,7 +47,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -16,7 +16,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -325,7 +325,7 @@ fn extend_integer_width<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64) {
arg.extend_integer_width_to(xlen);
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -20,7 +20,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -35,7 +35,7 @@ where
*offset = offset.align_to(align) + size.align_to(align);
}
pub fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
pub(crate) fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
where
C: HasDataLayout,
{

View File

@ -149,7 +149,7 @@ where
});
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,

View File

@ -25,7 +25,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -71,7 +71,7 @@ where
}
}
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}
@ -84,7 +84,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
}
}
pub fn compute_ptx_kernel_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_ptx_kernel_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,

View File

@ -27,7 +27,7 @@ fn classify_arg<Ty>(cx: &impl HasTargetSpec, arg: &mut ArgAbi<'_, Ty>) {
}
}
pub fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

View File

@ -86,7 +86,7 @@ where
};
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -331,7 +331,7 @@ fn extend_integer_width<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64) {
arg.extend_integer_width_to(xlen);
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -54,7 +54,7 @@ where
}
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -35,7 +35,7 @@ where
*offset = offset.align_to(align) + size.align_to(align);
}
pub fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
pub(crate) fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
where
C: HasDataLayout,
{

View File

@ -7,7 +7,7 @@ use crate::abi::{self, HasDataLayout, Scalar, Size, TyAbiInterface, TyAndLayout}
use crate::spec::HasTargetSpec;
#[derive(Clone, Debug)]
pub struct Sdata {
struct Sdata {
pub prefix: [Option<Reg>; 8],
pub prefix_index: usize,
pub last_offset: Size,
@ -209,7 +209,7 @@ where
arg.cast_to(Uniform::new(Reg::i64(), total));
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -45,7 +45,7 @@ where
}
/// The purpose of this ABI is to match the C ABI (aka clang) exactly.
pub fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,
@ -69,7 +69,7 @@ where
/// This ABI is *bad*! It uses `PassMode::Direct` for `abi::Aggregate` types, which leaks LLVM
/// implementation details into the ABI. It's just hard to fix because ABIs are hard to change.
/// Also see <https://github.com/rust-lang/rust/issues/115666>.
pub fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret_wasm_abi(&mut fn_abi.ret);
}

View File

@ -3,12 +3,12 @@ use crate::abi::{Abi, Align, HasDataLayout, TyAbiInterface, TyAndLayout};
use crate::spec::HasTargetSpec;
#[derive(PartialEq)]
pub enum Flavor {
pub(crate) enum Flavor {
General,
FastcallOrVectorcall,
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, flavor: Flavor)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, flavor: Flavor)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -170,7 +170,7 @@ fn cast_target(cls: &[Option<Class>], size: Size) -> CastTarget {
const MAX_INT_REGS: usize = 6; // RDI, RSI, RDX, RCX, R8, R9
const MAX_SSE_REGS: usize = 8; // XMM0-7
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,

View File

@ -4,7 +4,7 @@ use crate::spec::HasTargetSpec;
// Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing
pub fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
let fixup = |a: &mut ArgAbi<'_, Ty>| {
match a.layout.abi {
Abi::Uninhabited | Abi::Aggregate { sized: false } => {}

View File

@ -96,7 +96,7 @@ where
}
}
pub fn compute_abi_info<'a, Ty, C>(_cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
pub(crate) fn compute_abi_info<'a, Ty, C>(_cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,

View File

@ -70,7 +70,7 @@ impl AArch64InlineAsmRegClass {
}
}
pub fn target_reserves_x18(target: &Target) -> bool {
pub(crate) fn target_reserves_x18(target: &Target) -> bool {
target.os == "android" || target.os == "fuchsia" || target.is_like_osx || target.is_like_windows
}

View File

@ -17,6 +17,7 @@
#![feature(let_chains)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::path::{Path, PathBuf};

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
abi: "vec-extabi".into(),
code_model: Some(CodeModel::Small),

View File

@ -1,6 +1,6 @@
use crate::spec::{base, SanitizerSet, TargetOptions, TlsModel};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut base = base::linux::opts();
base.os = "android".into();
base.is_like_android = true;

View File

@ -12,7 +12,7 @@ mod tests;
use Arch::*;
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, PartialEq)]
pub enum Arch {
pub(crate) enum Arch {
Armv7k,
Armv7s,
Arm64,
@ -25,7 +25,7 @@ pub enum Arch {
}
impl Arch {
pub fn target_name(self) -> &'static str {
fn target_name(self) -> &'static str {
match self {
Armv7k => "armv7k",
Armv7s => "armv7s",
@ -39,7 +39,7 @@ impl Arch {
}
}
pub fn target_arch(self) -> Cow<'static, str> {
pub(crate) fn target_arch(self) -> Cow<'static, str> {
Cow::Borrowed(match self {
Armv7k | Armv7s => "arm",
Arm64 | Arm64e | Arm64_32 => "aarch64",
@ -80,7 +80,7 @@ impl Arch {
}
#[derive(Copy, Clone, PartialEq)]
pub enum TargetAbi {
pub(crate) enum TargetAbi {
Normal,
Simulator,
MacCatalyst,
@ -142,7 +142,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
args
}
pub fn opts(os: &'static str, arch: Arch, abi: TargetAbi) -> TargetOptions {
pub(crate) fn opts(os: &'static str, arch: Arch, abi: TargetAbi) -> TargetOptions {
TargetOptions {
abi: abi.target_abi().into(),
os: os.into(),
@ -279,7 +279,7 @@ fn macos_deployment_target(arch: Arch) -> (u32, u32) {
.unwrap_or_else(|| macos_default_deployment_target(arch))
}
pub fn macos_llvm_target(arch: Arch) -> String {
pub(crate) fn macos_llvm_target(arch: Arch) -> String {
let (major, minor) = macos_deployment_target(arch);
format!("{}-apple-macosx{}.{}.0", arch.target_name(), major, minor)
}
@ -333,7 +333,7 @@ fn ios_deployment_target(arch: Arch, abi: &str) -> (u32, u32) {
from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((major, minor))
}
pub fn ios_llvm_target(arch: Arch) -> String {
pub(crate) fn ios_llvm_target(arch: Arch) -> String {
// Modern iOS tooling extracts information about deployment target
// from LC_BUILD_VERSION. This load command will only be emitted when
// we build with a version specific `llvm_target`, with the version
@ -344,12 +344,12 @@ pub fn ios_llvm_target(arch: Arch) -> String {
format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor)
}
pub fn mac_catalyst_llvm_target(arch: Arch) -> String {
pub(crate) fn mac_catalyst_llvm_target(arch: Arch) -> String {
let (major, minor) = ios_deployment_target(arch, "macabi");
format!("{}-apple-ios{}.{}.0-macabi", arch.target_name(), major, minor)
}
pub fn ios_sim_llvm_target(arch: Arch) -> String {
pub(crate) fn ios_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = ios_deployment_target(arch, "sim");
format!("{}-apple-ios{}.{}.0-simulator", arch.target_name(), major, minor)
}
@ -360,12 +360,12 @@ fn tvos_deployment_target() -> (u32, u32) {
from_set_deployment_target("TVOS_DEPLOYMENT_TARGET").unwrap_or((10, 0))
}
pub fn tvos_llvm_target(arch: Arch) -> String {
pub(crate) fn tvos_llvm_target(arch: Arch) -> String {
let (major, minor) = tvos_deployment_target();
format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor)
}
pub fn tvos_sim_llvm_target(arch: Arch) -> String {
pub(crate) fn tvos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = tvos_deployment_target();
format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor)
}
@ -376,12 +376,12 @@ fn watchos_deployment_target() -> (u32, u32) {
from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0))
}
pub fn watchos_llvm_target(arch: Arch) -> String {
pub(crate) fn watchos_llvm_target(arch: Arch) -> String {
let (major, minor) = watchos_deployment_target();
format!("{}-apple-watchos{}.{}.0", arch.target_name(), major, minor)
}
pub fn watchos_sim_llvm_target(arch: Arch) -> String {
pub(crate) fn watchos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = watchos_deployment_target();
format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor)
}
@ -392,12 +392,12 @@ fn visionos_deployment_target() -> (u32, u32) {
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
}
pub fn visionos_llvm_target(arch: Arch) -> String {
pub(crate) fn visionos_llvm_target(arch: Arch) -> String {
let (major, minor) = visionos_deployment_target();
format!("{}-apple-visionos{}.{}.0", arch.target_name(), major, minor)
}
pub fn visionos_sim_llvm_target(arch: Arch) -> String {
pub(crate) fn visionos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = visionos_deployment_target();
format!("{}-apple-visionos{}.{}.0-simulator", arch.target_name(), major, minor)
}

View File

@ -6,7 +6,7 @@ use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
///
/// Requires GNU avr-gcc and avr-binutils on the host system.
/// FIXME: Remove the second parameter when const string concatenation is possible.
pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
pub(crate) fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
Target {
arch: "avr".into(),
metadata: crate::spec::TargetMetadata {

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, TargetOptions};
pub fn opts(endian: Endian) -> TargetOptions {
pub(crate) fn opts(endian: Endian) -> TargetOptions {
TargetOptions {
allow_asm: true,
endian,

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "dragonfly".into(),
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "freebsd".into(),
dynamic_linking: true,

View File

@ -2,7 +2,7 @@ use crate::spec::{
crt_objects, cvs, Cc, FramePointer, LinkOutputKind, LinkerFlavor, Lld, TargetOptions,
};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
// This mirrors the linker options provided by clang. We presume lld for
// now. When using clang as the linker it will supply these options for us,
// so we only list them for ld/lld.

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "haiku".into(),
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "hermit".into(),
linker: Some("rust-lld".into()),

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "hurd".into(),
dynamic_linking: true,

View File

@ -1,5 +1,5 @@
use crate::spec::{base, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions { env: "gnu".into(), ..base::hurd::opts() }
}

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let late_link_args = TargetOptions::link_args(
LinkerFlavor::Unix(Cc::Yes),
&[

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "l4re".into(),
env: "uclibc".into(),

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "linux".into(),
dynamic_linking: true,

View File

@ -1,5 +1,5 @@
use crate::spec::{base, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions { env: "gnu".into(), ..base::linux::opts() }
}

View File

@ -1,6 +1,6 @@
use crate::spec::{base, crt_objects, LinkSelfContainedDefault, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut base = base::linux::opts();
base.env = "musl".into();

View File

@ -1,6 +1,6 @@
use crate::spec::{base, TargetOptions, TlsModel};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut base = base::linux::opts();
base.env = "ohos".into();

View File

@ -1,5 +1,5 @@
use crate::spec::{base, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions { env: "uclibc".into(), ..base::linux::opts() }
}

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
// Suppress the verbose logo and authorship debugging output, which would needlessly
// clog any log files.
let pre_link_args = TargetOptions::link_args(LinkerFlavor::Msvc(Lld::No), &["/NOLOGO"]);

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "netbsd".into(),
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
crt_static_respected: true,
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions, TlsModel};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "openbsd".into(),
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "redox".into(),
env: "relibc".into(),

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, Cc, LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "solaris".into(),
dynamic_linking: true,

View File

@ -1,6 +1,6 @@
use crate::spec::{FramePointer, TargetOptions};
pub fn opts(kernel: &str) -> TargetOptions {
pub(crate) fn opts(kernel: &str) -> TargetOptions {
TargetOptions {
os: format!("solid_{kernel}").into(),
vendor: "kmc".into(),

View File

@ -1,6 +1,6 @@
use crate::spec::{add_link_args, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"];

View File

@ -29,7 +29,7 @@
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
// See rust-lang/rfcs#1645 for a discussion about these defaults
TargetOptions {
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),

View File

@ -11,7 +11,7 @@
use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut base = base::msvc::opts();
base.add_pre_link_args(

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "linux".into(),
env: "musl".into(),

View File

@ -1,6 +1,6 @@
use crate::spec::{cvs, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "vxworks".into(),
env: "gnu".into(),

View File

@ -3,7 +3,7 @@ use crate::spec::{
TargetOptions, TlsModel,
};
pub fn options() -> TargetOptions {
pub(crate) fn options() -> TargetOptions {
macro_rules! args {
($prefix:literal) => {
&[

View File

@ -5,7 +5,7 @@ use crate::spec::{
Lld, SplitDebuginfo, TargetOptions,
};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut pre_link_args = TargetOptions::link_args(
LinkerFlavor::Gnu(Cc::No, Lld::No),
&[

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
// We cannot use `-nodefaultlibs` because compiler-rt has to be passed
// as a path since it's not added to linker search path by the default.
// There were attempts to make it behave like libgcc (so one can just use -l<name>)

View File

@ -1,6 +1,6 @@
use crate::spec::{base, cvs, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let base = base::msvc::opts();
TargetOptions {

View File

@ -1,6 +1,6 @@
use crate::spec::{add_link_args, base, Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let base = base::windows_gnu::opts();
// FIXME: This should be updated for the exception machinery changes from #67502

View File

@ -1,6 +1,6 @@
use crate::spec::{base, LinkerFlavor, Lld, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
let mut opts = base::windows_msvc::opts();
opts.abi = "uwp".into();

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, TargetOptions};
pub fn opts() -> TargetOptions {
pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "none".into(),
endian: Endian::Little,

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{macos_llvm_target, opts, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("macos", arch, TargetAbi::Normal);
base.cpu = "apple-m1".into();

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{ios_llvm_target, opts, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("ios", arch, TargetAbi::Normal);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{mac_catalyst_llvm_target, opts, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("ios", arch, TargetAbi::MacCatalyst);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("ios", arch, TargetAbi::Simulator);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, tvos_llvm_target, Arch, TargetAbi};
use crate::spec::{FramePointer, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
Target {
llvm_target: tvos_llvm_target(arch).into(),

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch, TargetAbi};
use crate::spec::{FramePointer, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
Target {
llvm_target: tvos_sim_llvm_target(arch).into(),

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, visionos_llvm_target, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("visionos", arch, TargetAbi::Normal);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, visionos_sim_llvm_target, Arch, TargetAbi};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("visionos", arch, TargetAbi::Simulator);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, Arch, TargetAbi};
use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let base = opts("watchos", Arch::Arm64, TargetAbi::Normal);
Target {
llvm_target: "aarch64-apple-watchos".into(),

View File

@ -1,7 +1,7 @@
use crate::spec::base::apple::{opts, watchos_sim_llvm_target, Arch, TargetAbi};
use crate::spec::{FramePointer, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let arch = Arch::Arm64;
Target {
// Clang automatically chooses a more specific target based on

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
Target {
llvm_target: "aarch64_be-unknown-linux-gnu".into(),
metadata: crate::spec::TargetMetadata {

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let mut base = base::linux_gnu::opts();
base.max_atomic_width = Some(128);

View File

@ -1,7 +1,7 @@
use crate::abi::Endian;
use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
Target {
llvm_target: "aarch64_be-unknown-netbsd".into(),
metadata: crate::spec::TargetMetadata {

View File

@ -1 +1 @@
pub use crate::spec::targets::aarch64_unknown_fuchsia::target;
pub(crate) use crate::spec::targets::aarch64_unknown_fuchsia::target;

View File

@ -1,6 +1,6 @@
use crate::spec::{base, RelocModel, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
pub(crate) fn target() -> Target {
let base = base::solid::opts("asp3");
Target {
llvm_target: "aarch64-unknown-none".into(),

View File

@ -3,7 +3,7 @@ use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
// for target ABI requirements.
pub fn target() -> Target {
pub(crate) fn target() -> Target {
Target {
llvm_target: "aarch64-linux-android".into(),
metadata: crate::spec::TargetMetadata {

Some files were not shown because too many files have changed in this diff Show More