Skip to content

Commit 9a59b05

Browse files
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.
2 parents 6361989 + 57c9eb7 commit 9a59b05

File tree

15 files changed

+5
-248
lines changed

15 files changed

+5
-248
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-7
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ extern "C" {
891891
pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
892892
pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
893893
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
894-
pub fn LLVMIsAFunction(Val: &Value) -> Option<&Value>;
895894

896895
// Operations on constants of any type
897896
pub fn LLVMConstNull(Ty: &Type) -> &Value;
@@ -955,7 +954,6 @@ extern "C" {
955954
pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
956955
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
957956
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
958-
pub fn LLVMConstPointerCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
959957
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
960958

961959
// Operations on global variables, functions, and aliases (globals)
@@ -2346,11 +2344,6 @@ extern "C" {
23462344
len: usize,
23472345
Identifier: *const c_char,
23482346
) -> Option<&Module>;
2349-
pub fn LLVMRustGetBitcodeSliceFromObjectData(
2350-
Data: *const u8,
2351-
len: usize,
2352-
out_len: &mut usize,
2353-
) -> *const u8;
23542347
pub fn LLVMRustGetSliceFromObjectDataByName(
23552348
data: *const u8,
23562349
len: usize,

compiler/rustc_codegen_llvm/src/type_.rs

-4
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
227227
}
228228

229229
impl Type {
230-
pub fn i8_llcx(llcx: &llvm::Context) -> &Type {
231-
unsafe { llvm::LLVMInt8TypeInContext(llcx) }
232-
}
233-
234230
/// Creates an integer type with the given number of bits, e.g., i24
235231
pub fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type {
236232
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }

compiler/rustc_const_eval/src/interpret/projection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ where
256256
}
257257

258258
/// Iterates over all fields of an array. Much more efficient than doing the
259-
/// same by repeatedly calling `operand_index`.
259+
/// same by repeatedly calling `project_index`.
260260
pub fn project_array_fields<'a, P: Projectable<'tcx, M::Provenance>>(
261261
&self,
262262
base: &'a P,
263263
) -> InterpResult<'tcx, ArrayIterator<'tcx, 'a, M::Provenance, P>> {
264264
let abi::FieldsShape::Array { stride, .. } = base.layout().fields else {
265-
span_bug!(self.cur_span(), "operand_array_fields: expected an array layout");
265+
span_bug!(self.cur_span(), "project_array_fields: expected an array layout");
266266
};
267267
let len = base.len(self)?;
268268
let field_layout = base.layout().field(self, 0);

compiler/rustc_const_eval/src/transform/promote_consts.rs

-33
Original file line numberDiff line numberDiff line change
@@ -1023,36 +1023,3 @@ pub fn promote_candidates<'tcx>(
10231023

10241024
promotions
10251025
}
1026-
1027-
/// This function returns `true` if the function being called in the array
1028-
/// repeat expression is a `const` function.
1029-
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
1030-
ccx: &ConstCx<'_, 'tcx>,
1031-
place: &Place<'tcx>,
1032-
body: &Body<'tcx>,
1033-
) -> bool {
1034-
match place.as_local() {
1035-
// rule out cases such as: `let my_var = some_fn(); [my_var; N]`
1036-
Some(local) if body.local_decls[local].is_user_variable() => return false,
1037-
None => return false,
1038-
_ => {}
1039-
}
1040-
1041-
for block in body.basic_blocks.iter() {
1042-
if let Some(Terminator { kind: TerminatorKind::Call { func, destination, .. }, .. }) =
1043-
&block.terminator
1044-
{
1045-
if let Operand::Constant(box ConstOperand { const_, .. }) = func {
1046-
if let ty::FnDef(def_id, _) = *const_.ty().kind() {
1047-
if destination == place {
1048-
if ccx.tcx.is_const_fn(def_id) {
1049-
return true;
1050-
}
1051-
}
1052-
}
1053-
}
1054-
}
1055-
}
1056-
1057-
false
1058-
}

compiler/rustc_graphviz/src/lib.rs

-27
Original file line numberDiff line numberDiff line change
@@ -522,33 +522,6 @@ impl<'a> LabelText<'a> {
522522
HtmlStr(ref s) => format!("<{s}>"),
523523
}
524524
}
525-
526-
/// Decomposes content into string suitable for making EscStr that
527-
/// yields same content as self. The result obeys the law
528-
/// render(`lt`) == render(`EscStr(lt.pre_escaped_content())`) for
529-
/// all `lt: LabelText`.
530-
fn pre_escaped_content(self) -> Cow<'a, str> {
531-
match self {
532-
EscStr(s) => s,
533-
LabelStr(s) => {
534-
if s.contains('\\') {
535-
s.escape_default().to_string().into()
536-
} else {
537-
s
538-
}
539-
}
540-
HtmlStr(s) => s,
541-
}
542-
}
543-
544-
/// Puts `suffix` on a line below this label, with a blank line separator.
545-
pub fn suffix_line(self, suffix: LabelText<'_>) -> LabelText<'static> {
546-
let mut prefix = self.pre_escaped_content().into_owned();
547-
let suffix = suffix.pre_escaped_content();
548-
prefix.push_str(r"\n\n");
549-
prefix.push_str(&suffix);
550-
EscStr(prefix.into())
551-
}
552525
}
553526

554527
pub type Nodes<'a, N> = Cow<'a, [N]>;

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
609609
return false;
610610
}
611611
let pin_did = self.tcx.lang_items().pin_type();
612-
// This guards the `unwrap` and `mk_box` below.
612+
// This guards the `new_box` below.
613613
if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() {
614614
return false;
615615
}

compiler/rustc_infer/src/infer/mod.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
3232
use rustc_middle::ty::fold::BoundVarReplacerDelegate;
3333
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
3434
use rustc_middle::ty::relate::RelateResult;
35-
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
35+
use rustc_middle::ty::visit::TypeVisitableExt;
3636
pub use rustc_middle::ty::IntVarValue;
3737
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
3838
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
@@ -1406,17 +1406,6 @@ impl<'tcx> InferCtxt<'tcx> {
14061406
value.fold_with(&mut r)
14071407
}
14081408

1409-
/// Returns the first unresolved type or const variable contained in `T`.
1410-
pub fn first_unresolved_const_or_ty_var<T>(
1411-
&self,
1412-
value: &T,
1413-
) -> Option<(ty::Term<'tcx>, Option<Span>)>
1414-
where
1415-
T: TypeVisitable<TyCtxt<'tcx>>,
1416-
{
1417-
value.visit_with(&mut resolve::UnresolvedTypeOrConstFinder::new(self)).break_value()
1418-
}
1419-
14201409
pub fn probe_const_var(&self, vid: ty::ConstVid) -> Result<ty::Const<'tcx>, ty::UniverseIndex> {
14211410
match self.inner.borrow_mut().const_unification_table().probe_value(vid).val {
14221411
ConstVariableValue::Known { value } => Ok(value),

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

-26
Original file line numberDiff line numberDiff line change
@@ -1562,32 +1562,6 @@ LLVMRustParseBitcodeForLTO(LLVMContextRef Context,
15621562
return wrap(std::move(*SrcOrError).release());
15631563
}
15641564

1565-
// Find the bitcode section in the object file data and return it as a slice.
1566-
// Fail if the bitcode section is present but empty.
1567-
//
1568-
// On success, the return value is the pointer to the start of the slice and
1569-
// `out_len` is filled with the (non-zero) length. On failure, the return value
1570-
// is `nullptr` and `out_len` is set to zero.
1571-
extern "C" const char*
1572-
LLVMRustGetBitcodeSliceFromObjectData(const char *data,
1573-
size_t len,
1574-
size_t *out_len) {
1575-
*out_len = 0;
1576-
1577-
StringRef Data(data, len);
1578-
MemoryBufferRef Buffer(Data, ""); // The id is unused.
1579-
1580-
Expected<MemoryBufferRef> BitcodeOrError =
1581-
object::IRObjectFile::findBitcodeInMemBuffer(Buffer);
1582-
if (!BitcodeOrError) {
1583-
LLVMRustSetLastError(toString(BitcodeOrError.takeError()).c_str());
1584-
return nullptr;
1585-
}
1586-
1587-
*out_len = BitcodeOrError->getBufferSize();
1588-
return BitcodeOrError->getBufferStart();
1589-
}
1590-
15911565
// Find a section of an object file by name. Fail if the section is missing or
15921566
// empty.
15931567
extern "C" const char *LLVMRustGetSliceFromObjectDataByName(const char *data,

compiler/rustc_middle/src/mir/query.rs

-58
Original file line numberDiff line numberDiff line change
@@ -42,64 +42,6 @@ pub enum UnsafetyViolationDetails {
4242
CallToFunctionWith,
4343
}
4444

45-
impl UnsafetyViolationDetails {
46-
pub fn description_and_note(&self) -> (&'static str, &'static str) {
47-
use UnsafetyViolationDetails::*;
48-
match self {
49-
CallToUnsafeFunction => (
50-
"call to unsafe function",
51-
"consult the function's documentation for information on how to avoid undefined \
52-
behavior",
53-
),
54-
UseOfInlineAssembly => (
55-
"use of inline assembly",
56-
"inline assembly is entirely unchecked and can cause undefined behavior",
57-
),
58-
InitializingTypeWith => (
59-
"initializing type with `rustc_layout_scalar_valid_range` attr",
60-
"initializing a layout restricted type's field with a value outside the valid \
61-
range is undefined behavior",
62-
),
63-
CastOfPointerToInt => {
64-
("cast of pointer to int", "casting pointers to integers in constants")
65-
}
66-
UseOfMutableStatic => (
67-
"use of mutable static",
68-
"mutable statics can be mutated by multiple threads: aliasing violations or data \
69-
races will cause undefined behavior",
70-
),
71-
UseOfExternStatic => (
72-
"use of extern static",
73-
"extern statics are not controlled by the Rust type system: invalid data, \
74-
aliasing violations or data races will cause undefined behavior",
75-
),
76-
DerefOfRawPointer => (
77-
"dereference of raw pointer",
78-
"raw pointers may be null, dangling or unaligned; they can violate aliasing rules \
79-
and cause data races: all of these are undefined behavior",
80-
),
81-
AccessToUnionField => (
82-
"access to union field",
83-
"the field may not be properly initialized: using uninitialized data will cause \
84-
undefined behavior",
85-
),
86-
MutationOfLayoutConstrainedField => (
87-
"mutation of layout constrained field",
88-
"mutating layout constrained fields cannot statically be checked for valid values",
89-
),
90-
BorrowOfLayoutConstrainedField => (
91-
"borrow of layout constrained field with interior mutability",
92-
"references to fields of layout constrained fields lose the constraints. Coupled \
93-
with interior mutability, the field can be changed to invalid values",
94-
),
95-
CallToFunctionWith => (
96-
"call to function with `#[target_feature]`",
97-
"can only be called if the required target features are available",
98-
),
99-
}
100-
}
101-
}
102-
10345
#[derive(Copy, Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
10446
pub struct UnsafetyViolation {
10547
pub source_info: SourceInfo,

compiler/rustc_middle/src/traits/query.rs

-11
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
108108
tcx.sess.emit_err(DropCheckOverflow { span, ty, overflow_ty: *overflow_ty });
109109
}
110110
}
111-
112-
pub fn into_kinds_reporting_overflows(
113-
self,
114-
tcx: TyCtxt<'tcx>,
115-
span: Span,
116-
ty: Ty<'tcx>,
117-
) -> Vec<GenericArg<'tcx>> {
118-
self.report_overflows(tcx, span, ty);
119-
let DropckOutlivesResult { kinds, overflows: _ } = self;
120-
kinds
121-
}
122111
}
123112

124113
/// A set of constraints that need to be satisfied in order for

compiler/rustc_middle/src/ty/generic_args.rs

-7
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,6 @@ impl<T> EarlyBinder<Option<T>> {
604604
}
605605
}
606606

607-
impl<T, U> EarlyBinder<(T, U)> {
608-
pub fn transpose_tuple2(self) -> (EarlyBinder<T>, EarlyBinder<U>) {
609-
let EarlyBinder { value: (lhs, rhs) } = self;
610-
(EarlyBinder { value: lhs }, EarlyBinder { value: rhs })
611-
}
612-
}
613-
614607
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
615608
where
616609
I::Item: TypeFoldable<TyCtxt<'tcx>>,

compiler/rustc_middle/src/ty/mod.rs

-36
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, StashKey};
4242
use rustc_hir as hir;
4343
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
4444
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
45-
use rustc_hir::Node;
4645
use rustc_index::IndexVec;
4746
use rustc_macros::HashStable;
4847
use rustc_query_system::ich::StableHashingContext;
@@ -1301,25 +1300,6 @@ impl<'tcx> Predicate<'tcx> {
13011300
}
13021301
}
13031302

1304-
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
1305-
let predicate = self.kind();
1306-
match predicate.skip_binder() {
1307-
PredicateKind::Clause(ClauseKind::TypeOutlives(data)) => Some(predicate.rebind(data)),
1308-
PredicateKind::Clause(ClauseKind::Trait(..))
1309-
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
1310-
| PredicateKind::Clause(ClauseKind::Projection(..))
1311-
| PredicateKind::AliasRelate(..)
1312-
| PredicateKind::Subtype(..)
1313-
| PredicateKind::Coerce(..)
1314-
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
1315-
| PredicateKind::Clause(ClauseKind::WellFormed(..))
1316-
| PredicateKind::ObjectSafe(..)
1317-
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
1318-
| PredicateKind::ConstEquate(..)
1319-
| PredicateKind::Ambiguous => None,
1320-
}
1321-
}
1322-
13231303
/// Matches a `PredicateKind::Clause` and turns it into a `Clause`, otherwise returns `None`.
13241304
pub fn as_clause(self) -> Option<Clause<'tcx>> {
13251305
match self.kind().skip_binder() {
@@ -2532,22 +2512,6 @@ impl<'tcx> TyCtxt<'tcx> {
25322512
}
25332513
}
25342514

2535-
/// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition.
2536-
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<LocalDefId> {
2537-
let def_id = def_id.as_local()?;
2538-
if let Node::Item(item) = tcx.hir().get_by_def_id(def_id) {
2539-
if let hir::ItemKind::OpaqueTy(opaque_ty) = item.kind {
2540-
return match opaque_ty.origin {
2541-
hir::OpaqueTyOrigin::FnReturn(parent) | hir::OpaqueTyOrigin::AsyncFn(parent) => {
2542-
Some(parent)
2543-
}
2544-
hir::OpaqueTyOrigin::TyAlias { .. } => None,
2545-
};
2546-
}
2547-
}
2548-
None
2549-
}
2550-
25512515
pub fn int_ty(ity: ast::IntTy) -> IntTy {
25522516
match ity {
25532517
ast::IntTy::Isize => IntTy::Isize,

compiler/rustc_middle/src/ty/util.rs

-16
Original file line numberDiff line numberDiff line change
@@ -701,22 +701,6 @@ impl<'tcx> TyCtxt<'tcx> {
701701
.map(|decl| ty::EarlyBinder::bind(decl.ty))
702702
}
703703

704-
/// Normalizes all opaque types in the given value, replacing them
705-
/// with their underlying types.
706-
pub fn expand_opaque_types(self, val: Ty<'tcx>) -> Ty<'tcx> {
707-
let mut visitor = OpaqueTypeExpander {
708-
seen_opaque_tys: FxHashSet::default(),
709-
expanded_cache: FxHashMap::default(),
710-
primary_def_id: None,
711-
found_recursion: false,
712-
found_any_recursion: false,
713-
check_recursion: false,
714-
expand_coroutines: false,
715-
tcx: self,
716-
};
717-
val.fold_with(&mut visitor)
718-
}
719-
720704
/// Expands the given impl trait type, stopping if the type is recursive.
721705
#[instrument(skip(self), level = "debug", ret)]
722706
pub fn try_expand_impl_trait_type(

compiler/rustc_span/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnO
139139
SESSION_GLOBALS.set(session_globals, f)
140140
}
141141

142-
pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
143-
where
144-
F: FnOnce(&SessionGlobals) -> R,
145-
{
146-
create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
147-
}
148-
149142
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
150143
where
151144
F: FnOnce(&SessionGlobals) -> R,

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn equate_impl_headers<'tcx>(
330330
impl1.self_ty,
331331
impl2.self_ty,
332332
),
333-
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
333+
_ => bug!("equate_impl_headers given mismatched impl kinds"),
334334
};
335335

336336
result.map(|infer_ok| infer_ok.obligations).ok()

0 commit comments

Comments
 (0)