Skip to content

Commit acb2eaa

Browse files
authored
Unrolled build for rust-lang#118302
Rollup merge of rust-lang#118302 - mu001999:dead_code/clean, r=cjgillot Clean dead codes Clean dead codes detected by rust-lang#118257
2 parents 3dbb4da + 91aee2d commit acb2eaa

File tree

10 files changed

+4
-260
lines changed

10 files changed

+4
-260
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

-60
Original file line numberDiff line numberDiff line change
@@ -737,18 +737,6 @@ trait InferCtxtExt<'tcx> {
737737
) -> T
738738
where
739739
T: TypeFoldable<TyCtxt<'tcx>>;
740-
741-
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
742-
&self,
743-
mir_def_id: LocalDefId,
744-
indices: &mut UniversalRegionIndices<'tcx>,
745-
);
746-
747-
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
748-
&self,
749-
mir_def_id: LocalDefId,
750-
indices: &mut UniversalRegionIndices<'tcx>,
751-
);
752740
}
753741

754742
impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
@@ -799,54 +787,6 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
799787
});
800788
value
801789
}
802-
803-
/// Finds late-bound regions that do not appear in the parameter listing and adds them to the
804-
/// indices vector. Typically, we identify late-bound regions as we process the inputs and
805-
/// outputs of the closure/function. However, sometimes there are late-bound regions which do
806-
/// not appear in the fn parameters but which are nonetheless in scope. The simplest case of
807-
/// this are unused functions, like fn foo<'a>() { } (see e.g., #51351). Despite not being used,
808-
/// users can still reference these regions (e.g., let x: &'a u32 = &22;), so we need to create
809-
/// entries for them and store them in the indices map. This code iterates over the complete
810-
/// set of late-bound regions and checks for any that we have not yet seen, adding them to the
811-
/// inputs vector.
812-
#[instrument(skip(self, indices))]
813-
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
814-
&self,
815-
mir_def_id: LocalDefId,
816-
indices: &mut UniversalRegionIndices<'tcx>,
817-
) {
818-
for_each_late_bound_region_in_recursive_scope(self.tcx, mir_def_id, |r| {
819-
debug!(?r);
820-
if !indices.indices.contains_key(&r) {
821-
let region_vid = {
822-
let name = r.get_name_or_anon();
823-
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
824-
};
825-
826-
debug!(?region_vid);
827-
indices.insert_late_bound_region(r, region_vid.as_var());
828-
}
829-
});
830-
}
831-
832-
#[instrument(skip(self, indices))]
833-
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
834-
&self,
835-
mir_def_id: LocalDefId,
836-
indices: &mut UniversalRegionIndices<'tcx>,
837-
) {
838-
for_each_late_bound_region_in_item(self.tcx, mir_def_id, |r| {
839-
debug!(?r);
840-
if !indices.indices.contains_key(&r) {
841-
let region_vid = {
842-
let name = r.get_name_or_anon();
843-
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
844-
};
845-
846-
indices.insert_late_bound_region(r, region_vid.as_var());
847-
}
848-
});
849-
}
850790
}
851791

852792
impl<'tcx> UniversalRegionIndices<'tcx> {

compiler/rustc_codegen_llvm/src/type_of.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::{self, Ty, TypeVisitableExt};
99
use rustc_target::abi::HasDataLayout;
1010
use rustc_target::abi::{Abi, Align, FieldsShape};
1111
use rustc_target::abi::{Int, Pointer, F32, F64};
12-
use rustc_target::abi::{PointeeInfo, Scalar, Size, TyAbiInterface, Variants};
12+
use rustc_target::abi::{Scalar, Size, Variants};
1313
use smallvec::{smallvec, SmallVec};
1414

1515
use std::fmt::Write;
@@ -184,7 +184,6 @@ pub trait LayoutLlvmExt<'tcx> {
184184
immediate: bool,
185185
) -> &'a Type;
186186
fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64;
187-
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo>;
188187
fn scalar_copy_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> Option<&'a Type>;
189188
}
190189

@@ -356,20 +355,6 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
356355
}
357356
}
358357

359-
// FIXME(eddyb) this having the same name as `TyAndLayout::pointee_info_at`
360-
// (the inherent method, which is lacking this caching logic) can result in
361-
// the uncached version being called - not wrong, but potentially inefficient.
362-
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo> {
363-
if let Some(&pointee) = cx.pointee_infos.borrow().get(&(self.ty, offset)) {
364-
return pointee;
365-
}
366-
367-
let result = Ty::ty_and_layout_pointee_info_at(*self, cx, offset);
368-
369-
cx.pointee_infos.borrow_mut().insert((self.ty, offset), result);
370-
result
371-
}
372-
373358
fn scalar_copy_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> Option<&'a Type> {
374359
debug_assert!(self.is_sized());
375360

compiler/rustc_hir_typeck/src/mem_categorization.rs

-7
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,18 @@ use rustc_trait_selection::infer::InferCtxtExt;
6666

6767
pub(crate) trait HirNode {
6868
fn hir_id(&self) -> hir::HirId;
69-
fn span(&self) -> Span;
7069
}
7170

7271
impl HirNode for hir::Expr<'_> {
7372
fn hir_id(&self) -> hir::HirId {
7473
self.hir_id
7574
}
76-
fn span(&self) -> Span {
77-
self.span
78-
}
7975
}
8076

8177
impl HirNode for hir::Pat<'_> {
8278
fn hir_id(&self) -> hir::HirId {
8379
self.hir_id
8480
}
85-
fn span(&self) -> Span {
86-
self.span
87-
}
8881
}
8982

9083
#[derive(Clone)]

compiler/rustc_infer/src/infer/nll_relate/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ pub trait TypeRelatingDelegate<'tcx> {
113113
fn forbid_inference_vars() -> bool;
114114
}
115115

116-
#[derive(Copy, Clone)]
117-
struct UniversallyQuantified(bool);
118-
119116
impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D>
120117
where
121118
D: TypeRelatingDelegate<'tcx>,

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+3-149
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1818
use rustc_hir::RangeEnd;
1919
use rustc_index::Idx;
2020
use rustc_middle::mir::interpret::{ErrorHandled, GlobalId, LitToConstError, LitToConstInput};
21-
use rustc_middle::mir::{self, BorrowKind, Const, Mutability, UserTypeProjection};
21+
use rustc_middle::mir::{self, BorrowKind, Const, Mutability};
2222
use rustc_middle::thir::{
2323
Ascription, BindingMode, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary,
2424
};
2525
use rustc_middle::ty::layout::IntegerExt;
26-
use rustc_middle::ty::{
27-
self, AdtDef, CanonicalUserTypeAnnotation, GenericArg, GenericArgsRef, Region, Ty, TyCtxt,
28-
TypeVisitableExt, UserType,
29-
};
26+
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, TypeVisitableExt};
3027
use rustc_span::def_id::LocalDefId;
31-
use rustc_span::{ErrorGuaranteed, Span, Symbol};
28+
use rustc_span::{ErrorGuaranteed, Span};
3229
use rustc_target::abi::{FieldIdx, Integer};
3330

3431
use std::cmp::Ordering;
@@ -701,146 +698,3 @@ impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> {
701698
self.typeck_results
702699
}
703700
}
704-
705-
trait PatternFoldable<'tcx>: Sized {
706-
fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
707-
self.super_fold_with(folder)
708-
}
709-
710-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self;
711-
}
712-
713-
trait PatternFolder<'tcx>: Sized {
714-
fn fold_pattern(&mut self, pattern: &Pat<'tcx>) -> Pat<'tcx> {
715-
pattern.super_fold_with(self)
716-
}
717-
718-
fn fold_pattern_kind(&mut self, kind: &PatKind<'tcx>) -> PatKind<'tcx> {
719-
kind.super_fold_with(self)
720-
}
721-
}
722-
723-
impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Box<T> {
724-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
725-
let content: T = (**self).fold_with(folder);
726-
Box::new(content)
727-
}
728-
}
729-
730-
impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Vec<T> {
731-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
732-
self.iter().map(|t| t.fold_with(folder)).collect()
733-
}
734-
}
735-
736-
impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Box<[T]> {
737-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
738-
self.iter().map(|t| t.fold_with(folder)).collect()
739-
}
740-
}
741-
742-
impl<'tcx, T: PatternFoldable<'tcx>> PatternFoldable<'tcx> for Option<T> {
743-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
744-
self.as_ref().map(|t| t.fold_with(folder))
745-
}
746-
}
747-
748-
macro_rules! ClonePatternFoldableImpls {
749-
(<$lt_tcx:tt> $($ty:ty),+) => {
750-
$(
751-
impl<$lt_tcx> PatternFoldable<$lt_tcx> for $ty {
752-
fn super_fold_with<F: PatternFolder<$lt_tcx>>(&self, _: &mut F) -> Self {
753-
Clone::clone(self)
754-
}
755-
}
756-
)+
757-
}
758-
}
759-
760-
ClonePatternFoldableImpls! { <'tcx>
761-
Span, FieldIdx, Mutability, Symbol, LocalVarId, usize,
762-
Region<'tcx>, Ty<'tcx>, BindingMode, AdtDef<'tcx>,
763-
GenericArgsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
764-
UserTypeProjection, CanonicalUserTypeAnnotation<'tcx>
765-
}
766-
767-
impl<'tcx> PatternFoldable<'tcx> for FieldPat<'tcx> {
768-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
769-
FieldPat { field: self.field.fold_with(folder), pattern: self.pattern.fold_with(folder) }
770-
}
771-
}
772-
773-
impl<'tcx> PatternFoldable<'tcx> for Pat<'tcx> {
774-
fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
775-
folder.fold_pattern(self)
776-
}
777-
778-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
779-
Pat {
780-
ty: self.ty.fold_with(folder),
781-
span: self.span.fold_with(folder),
782-
kind: self.kind.fold_with(folder),
783-
}
784-
}
785-
}
786-
787-
impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> {
788-
fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
789-
folder.fold_pattern_kind(self)
790-
}
791-
792-
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
793-
match *self {
794-
PatKind::Wild => PatKind::Wild,
795-
PatKind::Error(e) => PatKind::Error(e),
796-
PatKind::AscribeUserType {
797-
ref subpattern,
798-
ascription: Ascription { ref annotation, variance },
799-
} => PatKind::AscribeUserType {
800-
subpattern: subpattern.fold_with(folder),
801-
ascription: Ascription { annotation: annotation.fold_with(folder), variance },
802-
},
803-
PatKind::Binding { mutability, name, mode, var, ty, ref subpattern, is_primary } => {
804-
PatKind::Binding {
805-
mutability: mutability.fold_with(folder),
806-
name: name.fold_with(folder),
807-
mode: mode.fold_with(folder),
808-
var: var.fold_with(folder),
809-
ty: ty.fold_with(folder),
810-
subpattern: subpattern.fold_with(folder),
811-
is_primary,
812-
}
813-
}
814-
PatKind::Variant { adt_def, args, variant_index, ref subpatterns } => {
815-
PatKind::Variant {
816-
adt_def: adt_def.fold_with(folder),
817-
args: args.fold_with(folder),
818-
variant_index,
819-
subpatterns: subpatterns.fold_with(folder),
820-
}
821-
}
822-
PatKind::Leaf { ref subpatterns } => {
823-
PatKind::Leaf { subpatterns: subpatterns.fold_with(folder) }
824-
}
825-
PatKind::Deref { ref subpattern } => {
826-
PatKind::Deref { subpattern: subpattern.fold_with(folder) }
827-
}
828-
PatKind::Constant { value } => PatKind::Constant { value },
829-
PatKind::InlineConstant { def, subpattern: ref pattern } => {
830-
PatKind::InlineConstant { def, subpattern: pattern.fold_with(folder) }
831-
}
832-
PatKind::Range(ref range) => PatKind::Range(range.clone()),
833-
PatKind::Slice { ref prefix, ref slice, ref suffix } => PatKind::Slice {
834-
prefix: prefix.fold_with(folder),
835-
slice: slice.fold_with(folder),
836-
suffix: suffix.fold_with(folder),
837-
},
838-
PatKind::Array { ref prefix, ref slice, ref suffix } => PatKind::Array {
839-
prefix: prefix.fold_with(folder),
840-
slice: slice.fold_with(folder),
841-
suffix: suffix.fold_with(folder),
842-
},
843-
PatKind::Or { ref pats } => PatKind::Or { pats: pats.fold_with(folder) },
844-
}
845-
}
846-
}

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ pub(super) trait GoalKind<'tcx>:
3737

3838
fn trait_ref(self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx>;
3939

40-
fn polarity(self) -> ty::ImplPolarity;
41-
4240
fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self;
4341

4442
fn trait_def_id(self, tcx: TyCtxt<'tcx>) -> DefId;

compiler/rustc_trait_selection/src/solve/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum GoalEvaluationKind {
6464

6565
trait CanonicalResponseExt {
6666
fn has_no_inference_or_external_constraints(&self) -> bool;
67-
68-
fn has_only_region_constraints(&self) -> bool;
6967
}
7068

7169
impl<'tcx> CanonicalResponseExt for Canonical<'tcx, Response<'tcx>> {
@@ -74,11 +72,6 @@ impl<'tcx> CanonicalResponseExt for Canonical<'tcx, Response<'tcx>> {
7472
&& self.value.var_values.is_identity()
7573
&& self.value.external_constraints.opaque_types.is_empty()
7674
}
77-
78-
fn has_only_region_constraints(&self) -> bool {
79-
self.value.var_values.is_identity_modulo_regions()
80-
&& self.value.external_constraints.opaque_types.is_empty()
81-
}
8275
}
8376

8477
impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {

compiler/rustc_trait_selection/src/solve/project_goals/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
101101
self.projection_ty.trait_ref(tcx)
102102
}
103103

104-
fn polarity(self) -> ty::ImplPolarity {
105-
ty::ImplPolarity::Positive
106-
}
107-
108104
fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
109105
self.with_self_ty(tcx, self_ty)
110106
}

compiler/rustc_trait_selection/src/solve/trait_goals.rs

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
2424
self.trait_ref
2525
}
2626

27-
fn polarity(self) -> ty::ImplPolarity {
28-
self.polarity
29-
}
30-
3127
fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
3228
self.with_self_ty(tcx, self_ty)
3329
}

library/std/src/error.rs

-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ pub use core::error::Error;
1212
#[unstable(feature = "error_generic_member_access", issue = "99301")]
1313
pub use core::error::{request_ref, request_value, Request};
1414

15-
mod private {
16-
// This is a hack to prevent `type_id` from being overridden by `Error`
17-
// implementations, since that can enable unsound downcasting.
18-
#[unstable(feature = "error_type_id", issue = "60784")]
19-
#[derive(Debug)]
20-
pub struct Internal;
21-
}
22-
2315
/// An error reporter that prints an error and its sources.
2416
///
2517
/// Report also exposes configuration options for formatting the error sources, either entirely on a

0 commit comments

Comments
 (0)