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:
@@ -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 @@ impl<'tcx> DropckOutlivesResult<'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 @@ impl<T> EarlyBinder<Option<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_errors::{DiagnosticBuilder, ErrorGuaranteed, StashKey};
|
||||
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 @@ impl<'tcx> Predicate<'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 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
.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(
|
||||
|
||||
Reference in New Issue
Block a user