Rollup merge of #117871 - klensy:unused-pub, r=cjgillot
remove unused pub fns This removes some unused `pub fn`; also fixes few obsoleted fn names or added fixmes with reminders to update them.
This commit is contained in:
commit
9a59b059d5
@ -891,7 +891,6 @@ pub fn LLVMStructTypeInContext<'a>(
|
||||
pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
|
||||
pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
|
||||
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
|
||||
pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
|
||||
|
||||
// Operations on constants of any type
|
||||
pub fn LLVMConstNull(Ty: &Type) -> &Value;
|
||||
@ -955,7 +954,6 @@ pub fn LLVMConstInBoundsGEP2<'a>(
|
||||
pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
||||
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
|
||||
|
||||
// Operations on global variables, functions, and aliases (globals)
|
||||
@ -2346,11 +2344,6 @@ pub fn LLVMRustParseBitcodeForLTO(
|
||||
len: usize,
|
||||
Identifier: *const c_char,
|
||||
) -> Option<&Module>;
|
||||
pub fn LLVMRustGetBitcodeSliceFromObjectData(
|
||||
Data: *const u8,
|
||||
len: usize,
|
||||
out_len: &mut usize,
|
||||
) -> *const u8;
|
||||
pub fn LLVMRustGetSliceFromObjectDataByName(
|
||||
data: *const u8,
|
||||
len: usize,
|
||||
|
@ -227,10 +227,6 @@ fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
|
||||
}
|
||||
|
||||
impl Type {
|
||||
pub fn i8_llcx(llcx: &llvm::Context) -> &Type {
|
||||
unsafe { llvm::LLVMInt8TypeInContext(llcx) }
|
||||
}
|
||||
|
||||
/// Creates an integer type with the given number of bits, e.g., i24
|
||||
pub fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type {
|
||||
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
|
||||
|
@ -256,13 +256,13 @@ fn project_constant_index<P: Projectable<'tcx, M::Provenance>>(
|
||||
}
|
||||
|
||||
/// Iterates over all fields of an array. Much more efficient than doing the
|
||||
/// same by repeatedly calling `operand_index`.
|
||||
/// same by repeatedly calling `project_index`.
|
||||
pub fn project_array_fields<'a, P: Projectable<'tcx, M::Provenance>>(
|
||||
&self,
|
||||
base: &'a P,
|
||||
) -> InterpResult<'tcx, ArrayIterator<'tcx, 'a, M::Provenance, P>> {
|
||||
let abi::FieldsShape::Array { stride, .. } = base.layout().fields else {
|
||||
span_bug!(self.cur_span(), "operand_array_fields: expected an array layout");
|
||||
span_bug!(self.cur_span(), "project_array_fields: expected an array layout");
|
||||
};
|
||||
let len = base.len(self)?;
|
||||
let field_layout = base.layout().field(self, 0);
|
||||
|
@ -1023,36 +1023,3 @@ pub fn promote_candidates<'tcx>(
|
||||
|
||||
promotions
|
||||
}
|
||||
|
||||
/// This function returns `true` if the function being called in the array
|
||||
/// repeat expression is a `const` function.
|
||||
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
place: &Place<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
) -> bool {
|
||||
match place.as_local() {
|
||||
// rule out cases such as: `let my_var = some_fn(); [my_var; N]`
|
||||
Some(local) if body.local_decls[local].is_user_variable() => return false,
|
||||
None => return false,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
for block in body.basic_blocks.iter() {
|
||||
if let Some(Terminator { kind: TerminatorKind::Call { func, destination, .. }, .. }) =
|
||||
&block.terminator
|
||||
{
|
||||
if let Operand::Constant(box ConstOperand { const_, .. }) = func {
|
||||
if let ty::FnDef(def_id, _) = *const_.ty().kind() {
|
||||
if destination == place {
|
||||
if ccx.tcx.is_const_fn(def_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
@ -522,33 +522,6 @@ pub fn to_dot_string(&self) -> String {
|
||||
HtmlStr(ref s) => format!("<{s}>"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Decomposes content into string suitable for making EscStr that
|
||||
/// yields same content as self. The result obeys the law
|
||||
/// render(`lt`) == render(`EscStr(lt.pre_escaped_content())`) for
|
||||
/// all `lt: LabelText`.
|
||||
fn pre_escaped_content(self) -> Cow<'a, str> {
|
||||
match self {
|
||||
EscStr(s) => s,
|
||||
LabelStr(s) => {
|
||||
if s.contains('\\') {
|
||||
s.escape_default().to_string().into()
|
||||
} else {
|
||||
s
|
||||
}
|
||||
}
|
||||
HtmlStr(s) => s,
|
||||
}
|
||||
}
|
||||
|
||||
/// Puts `suffix` on a line below this label, with a blank line separator.
|
||||
pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
|
||||
let mut prefix = self.pre_escaped_content().into_owned();
|
||||
let suffix = suffix.pre_escaped_content();
|
||||
prefix.push_str(r"\n\n");
|
||||
prefix.push_str(&suffix);
|
||||
EscStr(prefix.into())
|
||||
}
|
||||
}
|
||||
|
||||
pub type Nodes<'a, N> = Cow<'a, [N]>;
|
||||
|
@ -609,7 +609,7 @@ pub(in super::super) fn suggest_calling_boxed_future_when_appropriate(
|
||||
return false;
|
||||
}
|
||||
let pin_did = self.tcx.lang_items().pin_type();
|
||||
// This guards the `unwrap` and `mk_box` below.
|
||||
// This guards the `new_box` below.
|
||||
if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() {
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
use rustc_middle::ty::fold::BoundVarReplacerDelegate;
|
||||
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_middle::ty::relate::RelateResult;
|
||||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||
use rustc_middle::ty::visit::TypeVisitableExt;
|
||||
pub use rustc_middle::ty::IntVarValue;
|
||||
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
||||
@ -1406,17 +1406,6 @@ pub fn resolve_numeric_literals_with_default<T>(&self, value: T) -> T
|
||||
value.fold_with(&mut r)
|
||||
}
|
||||
|
||||
/// Returns the first unresolved type or const variable contained in `T`.
|
||||
pub fn first_unresolved_const_or_ty_var<T>(
|
||||
&self,
|
||||
value: &T,
|
||||
) -> Option<(ty::Term<'tcx>, Option<Span>)>
|
||||
where
|
||||
T: TypeVisitable<TyCtxt<'tcx>>,
|
||||
{
|
||||
value.visit_with(&mut resolve::UnresolvedTypeOrConstFinder::new(self)).break_value()
|
||||
}
|
||||
|
||||
pub fn probe_const_var(&self, vid: ty::ConstVid) -> Result<ty::Const<'tcx>, ty::UniverseIndex> {
|
||||
match self.inner.borrow_mut().const_unification_table().probe_value(vid).val {
|
||||
ConstVariableValue::Known { value } => Ok(value),
|
||||
|
@ -1562,32 +1562,6 @@ LLVMRustParseBitcodeForLTO(LLVMContextRef Context,
|
||||
return wrap(std::move(*SrcOrError).release());
|
||||
}
|
||||
|
||||
// Find the bitcode section in the object file data and return it as a slice.
|
||||
// Fail if the bitcode section is present but empty.
|
||||
//
|
||||
// On success, the return value is the pointer to the start of the slice and
|
||||
// `out_len` is filled with the (non-zero) length. On failure, the return value
|
||||
// is `nullptr` and `out_len` is set to zero.
|
||||
extern "C" const char*
|
||||
LLVMRustGetBitcodeSliceFromObjectData(const char *data,
|
||||
size_t len,
|
||||
size_t *out_len) {
|
||||
*out_len = 0;
|
||||
|
||||
StringRef Data(data, len);
|
||||
MemoryBufferRef Buffer(Data, ""); // The id is unused.
|
||||
|
||||
Expected<MemoryBufferRef> BitcodeOrError =
|
||||
object::IRObjectFile::findBitcodeInMemBuffer(Buffer);
|
||||
if (!BitcodeOrError) {
|
||||
LLVMRustSetLastError(toString(BitcodeOrError.takeError()).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*out_len = BitcodeOrError->getBufferSize();
|
||||
return BitcodeOrError->getBufferStart();
|
||||
}
|
||||
|
||||
// Find a section of an object file by name. Fail if the section is missing or
|
||||
// empty.
|
||||
extern "C" const char *LLVMRustGetSliceFromObjectDataByName(const char *data,
|
||||
|
@ -42,64 +42,6 @@ pub enum UnsafetyViolationDetails {
|
||||
CallToFunctionWith,
|
||||
}
|
||||
|
||||
impl UnsafetyViolationDetails {
|
||||
pub fn description_and_note(&self) -> (&'static str, &'static str) {
|
||||
use UnsafetyViolationDetails::*;
|
||||
match self {
|
||||
CallToUnsafeFunction => (
|
||||
"call to unsafe function",
|
||||
"consult the function's documentation for information on how to avoid undefined \
|
||||
behavior",
|
||||
),
|
||||
UseOfInlineAssembly => (
|
||||
"use of inline assembly",
|
||||
"inline assembly is entirely unchecked and can cause undefined behavior",
|
||||
),
|
||||
InitializingTypeWith => (
|
||||
"initializing type with `rustc_layout_scalar_valid_range` attr",
|
||||
"initializing a layout restricted type's field with a value outside the valid \
|
||||
range is undefined behavior",
|
||||
),
|
||||
CastOfPointerToInt => {
|
||||
("cast of pointer to int", "casting pointers to integers in constants")
|
||||
}
|
||||
UseOfMutableStatic => (
|
||||
"use of mutable static",
|
||||
"mutable statics can be mutated by multiple threads: aliasing violations or data \
|
||||
races will cause undefined behavior",
|
||||
),
|
||||
UseOfExternStatic => (
|
||||
"use of extern static",
|
||||
"extern statics are not controlled by the Rust type system: invalid data, \
|
||||
aliasing violations or data races will cause undefined behavior",
|
||||
),
|
||||
DerefOfRawPointer => (
|
||||
"dereference of raw pointer",
|
||||
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
|
||||
and cause data races: all of these are undefined behavior",
|
||||
),
|
||||
AccessToUnionField => (
|
||||
"access to union field",
|
||||
"the field may not be properly initialized: using uninitialized data will cause \
|
||||
undefined behavior",
|
||||
),
|
||||
MutationOfLayoutConstrainedField => (
|
||||
"mutation of layout constrained field",
|
||||
"mutating layout constrained fields cannot statically be checked for valid values",
|
||||
),
|
||||
BorrowOfLayoutConstrainedField => (
|
||||
"borrow of layout constrained field with interior mutability",
|
||||
"references to fields of layout constrained fields lose the constraints. Coupled \
|
||||
with interior mutability, the field can be changed to invalid values",
|
||||
),
|
||||
CallToFunctionWith => (
|
||||
"call to function with `#[target_feature]`",
|
||||
"can only be called if the required target features are available",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
|
||||
pub struct UnsafetyViolation {
|
||||
pub source_info: SourceInfo,
|
||||
|
@ -108,17 +108,6 @@ pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
|
||||
tcx.sess.emit_err(DropCheckOverflow { span, ty, overflow_ty: *overflow_ty });
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_kinds_reporting_overflows(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Vec<GenericArg<'tcx>> {
|
||||
self.report_overflows(tcx, span, ty);
|
||||
let DropckOutlivesResult { kinds, overflows: _ } = self;
|
||||
kinds
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of constraints that need to be satisfied in order for
|
||||
|
@ -604,13 +604,6 @@ pub fn transpose(self) -> Option<EarlyBinder<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> EarlyBinder<(T, U)> {
|
||||
pub fn transpose_tuple2(self) -> (EarlyBinder<T>, EarlyBinder<U>) {
|
||||
let EarlyBinder { value: (lhs, rhs) } = self;
|
||||
(EarlyBinder { value: lhs }, EarlyBinder { value: rhs })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
|
||||
where
|
||||
I::Item: TypeFoldable<TyCtxt<'tcx>>,
|
||||
|
@ -42,7 +42,6 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
|
||||
use rustc_hir::Node;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
@ -1301,25 +1300,6 @@ pub fn to_opt_poly_projection_pred(self) -> Option<PolyProjectionPredicate<'tcx>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(ClauseKind::TypeOutlives(data)) => Some(predicate.rebind(data)),
|
||||
PredicateKind::Clause(ClauseKind::Trait(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::Clause(ClauseKind::Projection(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::Coerce(..)
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::Ambiguous => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches a `PredicateKind::Clause` and turns it into a `Clause`, otherwise returns `None`.
|
||||
pub fn as_clause(self) -> Option<Clause<'tcx>> {
|
||||
match self.kind().skip_binder() {
|
||||
@ -2532,22 +2512,6 @@ pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition.
|
||||
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<LocalDefId> {
|
||||
let def_id = def_id.as_local()?;
|
||||
if let Node::Item(item) = tcx.hir().get_by_def_id(def_id) {
|
||||
if let hir::ItemKind::OpaqueTy(opaque_ty) = item.kind {
|
||||
return match opaque_ty.origin {
|
||||
hir::OpaqueTyOrigin::FnReturn(parent) | hir::OpaqueTyOrigin::AsyncFn(parent) => {
|
||||
Some(parent)
|
||||
}
|
||||
hir::OpaqueTyOrigin::TyAlias { .. } => None,
|
||||
};
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn int_ty(ity: ast::IntTy) -> IntTy {
|
||||
match ity {
|
||||
ast::IntTy::Isize => IntTy::Isize,
|
||||
|
@ -701,22 +701,6 @@ pub fn coroutine_hidden_types(
|
||||
.map(|decl| ty::EarlyBinder::bind(decl.ty))
|
||||
}
|
||||
|
||||
/// Normalizes all opaque types in the given value, replacing them
|
||||
/// with their underlying types.
|
||||
pub fn expand_opaque_types(self, val: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let mut visitor = OpaqueTypeExpander {
|
||||
seen_opaque_tys: FxHashSet::default(),
|
||||
expanded_cache: FxHashMap::default(),
|
||||
primary_def_id: None,
|
||||
found_recursion: false,
|
||||
found_any_recursion: false,
|
||||
check_recursion: false,
|
||||
expand_coroutines: false,
|
||||
tcx: self,
|
||||
};
|
||||
val.fold_with(&mut visitor)
|
||||
}
|
||||
|
||||
/// Expands the given impl trait type, stopping if the type is recursive.
|
||||
#[instrument(skip(self), level = "debug", ret)]
|
||||
pub fn try_expand_impl_trait_type(
|
||||
|
@ -139,13 +139,6 @@ pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnO
|
||||
SESSION_GLOBALS.set(session_globals, f)
|
||||
}
|
||||
|
||||
pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
|
||||
where
|
||||
F: FnOnce(&SessionGlobals) -> R,
|
||||
{
|
||||
create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
|
||||
}
|
||||
|
||||
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&SessionGlobals) -> R,
|
||||
|
@ -330,7 +330,7 @@ fn equate_impl_headers<'tcx>(
|
||||
impl1.self_ty,
|
||||
impl2.self_ty,
|
||||
),
|
||||
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
|
||||
_ => bug!("equate_impl_headers given mismatched impl kinds"),
|
||||
};
|
||||
|
||||
result.map(|infer_ok| infer_ok.obligations).ok()
|
||||
|
Loading…
Reference in New Issue
Block a user