Skip to content

Commit 56463df

Browse files
authored
Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errors
Effects cleanup - removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers r? compiler-errors
2 parents 42a0e40 + f6fea83 commit 56463df

File tree

23 files changed

+40
-97
lines changed

23 files changed

+40
-97
lines changed

compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ impl DebugContext {
210210
type_names::push_generic_params(
211211
tcx,
212212
tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), args),
213-
enclosing_fn_def_id,
214213
&mut name,
215214
);
216215

compiler/rustc_codegen_gcc/src/callee.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>)
9898
// whether we are sharing generics or not. The important thing here is
9999
// that the visibility we apply to the declaration is the same one that
100100
// has been applied to the definition (wherever that definition may be).
101-
let is_generic =
102-
instance.args.non_erasable_generics(tcx, instance.def_id()).next().is_some();
101+
let is_generic = instance.args.non_erasable_generics().next().is_some();
103102

104103
if is_generic {
105104
// This is a monomorphization. Its expected visibility depends

compiler/rustc_codegen_llvm/src/callee.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
9898
unsafe {
9999
llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::ExternalLinkage);
100100

101-
let is_generic =
102-
instance.args.non_erasable_generics(tcx, instance.def_id()).next().is_some();
101+
let is_generic = instance.args.non_erasable_generics().next().is_some();
103102

104103
let is_hidden = if is_generic {
105104
// This is a monomorphization of a generic function.

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
350350
type_names::push_generic_params(
351351
tcx,
352352
tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), args),
353-
enclosing_fn_def_id,
354353
&mut name,
355354
);
356355

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn exported_symbols_provider_local(
312312

313313
match *mono_item {
314314
MonoItem::Fn(Instance { def: InstanceKind::Item(def), args }) => {
315-
if args.non_erasable_generics(tcx, def).next().is_some() {
315+
if args.non_erasable_generics().next().is_some() {
316316
let symbol = ExportedSymbol::Generic(def, args);
317317
symbols.push((symbol, SymbolExportInfo {
318318
level: SymbolExportLevel::Rust,
@@ -321,27 +321,21 @@ fn exported_symbols_provider_local(
321321
}));
322322
}
323323
}
324-
MonoItem::Fn(Instance { def: InstanceKind::DropGlue(def_id, Some(ty)), args }) => {
324+
MonoItem::Fn(Instance { def: InstanceKind::DropGlue(_, Some(ty)), args }) => {
325325
// A little sanity-check
326-
assert_eq!(
327-
args.non_erasable_generics(tcx, def_id).next(),
328-
Some(GenericArgKind::Type(ty))
329-
);
326+
assert_eq!(args.non_erasable_generics().next(), Some(GenericArgKind::Type(ty)));
330327
symbols.push((ExportedSymbol::DropGlue(ty), SymbolExportInfo {
331328
level: SymbolExportLevel::Rust,
332329
kind: SymbolExportKind::Text,
333330
used: false,
334331
}));
335332
}
336333
MonoItem::Fn(Instance {
337-
def: InstanceKind::AsyncDropGlueCtorShim(def_id, Some(ty)),
334+
def: InstanceKind::AsyncDropGlueCtorShim(_, Some(ty)),
338335
args,
339336
}) => {
340337
// A little sanity-check
341-
assert_eq!(
342-
args.non_erasable_generics(tcx, def_id).next(),
343-
Some(GenericArgKind::Type(ty))
344-
);
338+
assert_eq!(args.non_erasable_generics().next(), Some(GenericArgKind::Type(ty)));
345339
symbols.push((ExportedSymbol::AsyncDropGlueCtorShim(ty), SymbolExportInfo {
346340
level: SymbolExportLevel::Rust,
347341
kind: SymbolExportKind::Text,

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+8-21
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ fn push_debuginfo_type_name<'tcx>(
110110
ty_and_layout,
111111
&|output, visited| {
112112
push_item_name(tcx, def.did(), true, output);
113-
push_generic_params_internal(tcx, args, def.did(), output, visited);
113+
push_generic_params_internal(tcx, args, output, visited);
114114
},
115115
output,
116116
visited,
117117
);
118118
} else {
119119
push_item_name(tcx, def.did(), qualified, output);
120-
push_generic_params_internal(tcx, args, def.did(), output, visited);
120+
push_generic_params_internal(tcx, args, output, visited);
121121
}
122122
}
123123
ty::Tuple(component_types) => {
@@ -251,13 +251,8 @@ fn push_debuginfo_type_name<'tcx>(
251251
let principal =
252252
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), principal);
253253
push_item_name(tcx, principal.def_id, qualified, output);
254-
let principal_has_generic_params = push_generic_params_internal(
255-
tcx,
256-
principal.args,
257-
principal.def_id,
258-
output,
259-
visited,
260-
);
254+
let principal_has_generic_params =
255+
push_generic_params_internal(tcx, principal.args, output, visited);
261256

262257
let projection_bounds: SmallVec<[_; 4]> = trait_data
263258
.projection_bounds()
@@ -538,13 +533,7 @@ pub fn compute_debuginfo_vtable_name<'tcx>(
538533
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), trait_ref);
539534
push_item_name(tcx, trait_ref.def_id, true, &mut vtable_name);
540535
visited.clear();
541-
push_generic_params_internal(
542-
tcx,
543-
trait_ref.args,
544-
trait_ref.def_id,
545-
&mut vtable_name,
546-
&mut visited,
547-
);
536+
push_generic_params_internal(tcx, trait_ref.args, &mut vtable_name, &mut visited);
548537
} else {
549538
vtable_name.push('_');
550539
}
@@ -647,12 +636,11 @@ fn push_unqualified_item_name(
647636
fn push_generic_params_internal<'tcx>(
648637
tcx: TyCtxt<'tcx>,
649638
args: GenericArgsRef<'tcx>,
650-
def_id: DefId,
651639
output: &mut String,
652640
visited: &mut FxHashSet<Ty<'tcx>>,
653641
) -> bool {
654642
assert_eq!(args, tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), args));
655-
let mut args = args.non_erasable_generics(tcx, def_id).peekable();
643+
let mut args = args.non_erasable_generics().peekable();
656644
if args.peek().is_none() {
657645
return false;
658646
}
@@ -736,12 +724,11 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
736724
pub fn push_generic_params<'tcx>(
737725
tcx: TyCtxt<'tcx>,
738726
args: GenericArgsRef<'tcx>,
739-
def_id: DefId,
740727
output: &mut String,
741728
) {
742729
let _prof = tcx.prof.generic_activity("compute_debuginfo_type_name");
743730
let mut visited = FxHashSet::default();
744-
push_generic_params_internal(tcx, args, def_id, output, &mut visited);
731+
push_generic_params_internal(tcx, args, output, &mut visited);
745732
}
746733

747734
fn push_closure_or_coroutine_name<'tcx>(
@@ -786,7 +773,7 @@ fn push_closure_or_coroutine_name<'tcx>(
786773
// FIXME(async_closures): This is probably not going to be correct w.r.t.
787774
// multiple coroutine flavors. Maybe truncate to (parent + 1)?
788775
let args = args.truncate_to(tcx, generics);
789-
push_generic_params_internal(tcx, args, enclosing_fn_def_id, output, visited);
776+
push_generic_params_internal(tcx, args, output, visited);
790777
}
791778

792779
fn push_close_angle_bracket(cpp_like_debuginfo: bool, output: &mut String) {

compiler/rustc_hir_analysis/src/bounds.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Bounds are restrictions applied to some types after they've been lowered from the HIR to the
22
//! [`rustc_middle::ty`] form.
33
4-
use rustc_data_structures::fx::FxIndexMap;
54
use rustc_hir::LangItem;
65
use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
76
use rustc_span::Span;
@@ -25,7 +24,6 @@ use rustc_span::Span;
2524
#[derive(Default, PartialEq, Eq, Clone, Debug)]
2625
pub(crate) struct Bounds<'tcx> {
2726
clauses: Vec<(ty::Clause<'tcx>, Span)>,
28-
effects_min_tys: FxIndexMap<Ty<'tcx>, Span>,
2927
}
3028

3129
impl<'tcx> Bounds<'tcx> {
@@ -96,15 +94,7 @@ impl<'tcx> Bounds<'tcx> {
9694
}
9795
}
9896

99-
pub(crate) fn clauses(
100-
&self,
101-
// FIXME(effects): remove tcx
102-
_tcx: TyCtxt<'tcx>,
103-
) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
97+
pub(crate) fn clauses(&self) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
10498
self.clauses.iter().cloned()
10599
}
106-
107-
pub(crate) fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
108-
self.effects_min_tys.keys().copied()
109-
}
110100
}

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn associated_type_bounds<'tcx>(
6767
)
6868
});
6969

70-
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses(tcx).chain(bounds_from_parent));
70+
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
7171
debug!(
7272
"associated_type_bounds({}) = {:?}",
7373
tcx.def_path_str(assoc_item_def_id.to_def_id()),
@@ -339,7 +339,7 @@ fn opaque_type_bounds<'tcx>(
339339
}
340340
debug!(?bounds);
341341

342-
tcx.arena.alloc_from_iter(bounds.clauses(tcx))
342+
tcx.arena.alloc_from_iter(bounds.clauses())
343343
})
344344
}
345345

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
106106
return ty::GenericPredicates {
107107
parent: Some(tcx.parent(def_id.to_def_id())),
108108
predicates: tcx.arena.alloc_from_iter(predicates),
109-
effects_min_tys: ty::List::empty(),
110109
};
111110
}
112111

@@ -128,7 +127,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
128127
return ty::GenericPredicates {
129128
parent: Some(impl_def_id),
130129
predicates: tcx.arena.alloc_from_iter(impl_predicates),
131-
effects_min_tys: ty::List::empty(),
132130
};
133131
}
134132

@@ -154,7 +152,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
154152
// We use an `IndexSet` to preserve order of insertion.
155153
// Preserving the order of insertion is important here so as not to break UI tests.
156154
let mut predicates: FxIndexSet<(ty::Clause<'_>, Span)> = FxIndexSet::default();
157-
let mut effects_min_tys = Vec::new();
158155

159156
let hir_generics = node.generics().unwrap_or(NO_GENERICS);
160157
if let Node::Item(item) = node {
@@ -189,8 +186,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
189186
ty::List::empty(),
190187
PredicateFilter::All,
191188
);
192-
predicates.extend(bounds.clauses(tcx));
193-
effects_min_tys.extend(bounds.effects_min_tys());
189+
predicates.extend(bounds.clauses());
194190
}
195191

196192
// In default impls, we can assume that the self type implements
@@ -223,7 +219,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
223219
param.span,
224220
);
225221
trace!(?bounds);
226-
predicates.extend(bounds.clauses(tcx));
222+
predicates.extend(bounds.clauses());
227223
trace!(?predicates);
228224
}
229225
hir::GenericParamKind::Const { .. } => {
@@ -275,8 +271,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
275271
bound_vars,
276272
PredicateFilter::All,
277273
);
278-
predicates.extend(bounds.clauses(tcx));
279-
effects_min_tys.extend(bounds.effects_min_tys());
274+
predicates.extend(bounds.clauses());
280275
}
281276

282277
hir::WherePredicate::RegionPredicate(region_pred) => {
@@ -348,7 +343,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
348343
ty::GenericPredicates {
349344
parent: generics.parent,
350345
predicates: tcx.arena.alloc_from_iter(predicates),
351-
effects_min_tys: tcx.mk_type_list(&effects_min_tys),
352346
}
353347
}
354348

@@ -499,7 +493,6 @@ pub(super) fn explicit_predicates_of<'tcx>(
499493
ty::GenericPredicates {
500494
parent: predicates_and_bounds.parent,
501495
predicates: tcx.arena.alloc_slice(&predicates),
502-
effects_min_tys: predicates_and_bounds.effects_min_tys,
503496
}
504497
}
505498
} else {
@@ -551,7 +544,6 @@ pub(super) fn explicit_predicates_of<'tcx>(
551544
return GenericPredicates {
552545
parent: parent_preds.parent,
553546
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
554-
effects_min_tys: parent_preds.effects_min_tys,
555547
};
556548
}
557549
gather_explicit_predicates_of(tcx, def_id)
@@ -630,7 +622,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
630622

631623
// Combine the two lists to form the complete set of superbounds:
632624
let implied_bounds =
633-
&*tcx.arena.alloc_from_iter(bounds.clauses(tcx).chain(where_bounds_that_match));
625+
&*tcx.arena.alloc_from_iter(bounds.clauses().chain(where_bounds_that_match));
634626
debug!(?implied_bounds);
635627

636628
// Now require that immediate supertraits are lowered, which will, in
@@ -874,7 +866,7 @@ impl<'tcx> ItemCtxt<'tcx> {
874866
);
875867
}
876868

877-
bounds.clauses(self.tcx).collect()
869+
bounds.clauses().collect()
878870
}
879871
}
880872

@@ -966,7 +958,7 @@ pub(super) fn const_conditions<'tcx>(
966958

967959
ty::ConstConditions {
968960
parent: has_parent.then(|| tcx.local_parent(def_id).to_def_id()),
969-
predicates: tcx.arena.alloc_from_iter(bounds.clauses(tcx).map(|(clause, span)| {
961+
predicates: tcx.arena.alloc_from_iter(bounds.clauses().map(|(clause, span)| {
970962
(
971963
clause.kind().map_bound(|clause| match clause {
972964
ty::ClauseKind::HostEffect(ty::HostEffectPredicate {

compiler/rustc_hir_analysis/src/delegation.rs

-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ impl<'tcx> PredicatesBuilder<'tcx> {
278278
ty::GenericPredicates {
279279
parent: self.parent,
280280
predicates: self.tcx.arena.alloc_from_iter(preds),
281-
// FIXME(fn_delegation): Support effects.
282-
effects_min_tys: ty::List::empty(),
283281
}
284282
}
285283
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
6262

6363
let mut trait_bounds = vec![];
6464
let mut projection_bounds = vec![];
65-
for (pred, span) in bounds.clauses(tcx) {
65+
for (pred, span) in bounds.clauses() {
6666
let bound_pred = pred.kind();
6767
match bound_pred.skip_binder() {
6868
ty::ClauseKind::Trait(trait_pred) => {

compiler/rustc_middle/src/mir/mono.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@ impl<'tcx> MonoItem<'tcx> {
8686
}
8787
}
8888

89-
pub fn is_generic_fn(&self, tcx: TyCtxt<'tcx>) -> bool {
89+
pub fn is_generic_fn(&self) -> bool {
9090
match self {
91-
MonoItem::Fn(instance) => {
92-
instance.args.non_erasable_generics(tcx, instance.def_id()).next().is_some()
93-
}
91+
MonoItem::Fn(instance) => instance.args.non_erasable_generics().next().is_some(),
9492
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => false,
9593
}
9694
}

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'tcx> Ty<'tcx> {
7070
/// ADTs with no type arguments.
7171
pub fn is_simple_text(self, tcx: TyCtxt<'tcx>) -> bool {
7272
match self.kind() {
73-
Adt(def, args) => args.non_erasable_generics(tcx, def.did()).next().is_none(),
73+
Adt(_, args) => args.non_erasable_generics().next().is_none(),
7474
Ref(_, ty, _) => ty.is_simple_text(tcx),
7575
_ => self.is_simple_ty(),
7676
}

compiler/rustc_middle/src/ty/generic_args.rs

-3
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,6 @@ impl<'tcx> GenericArgs<'tcx> {
501501
#[inline]
502502
pub fn non_erasable_generics(
503503
&'tcx self,
504-
// FIXME(effects): Remove these
505-
_tcx: TyCtxt<'tcx>,
506-
_def_id: DefId,
507504
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'tcx {
508505
self.iter().filter_map(|k| match k.unpack() {
509506
ty::GenericArgKind::Lifetime(_) => None,

compiler/rustc_middle/src/ty/generics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ impl<'tcx> Generics {
360360
pub struct GenericPredicates<'tcx> {
361361
pub parent: Option<DefId>,
362362
pub predicates: &'tcx [(Clause<'tcx>, Span)],
363-
pub effects_min_tys: &'tcx ty::List<Ty<'tcx>>,
364363
}
365364

366365
impl<'tcx> GenericPredicates<'tcx> {

compiler/rustc_middle/src/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'tcx> Instance<'tcx> {
204204
}
205205

206206
// If this a non-generic instance, it cannot be a shared monomorphization.
207-
self.args.non_erasable_generics(tcx, self.def_id()).next()?;
207+
self.args.non_erasable_generics().next()?;
208208

209209
// compiler_builtins cannot use upstream monomorphizations.
210210
if tcx.is_compiler_builtins(LOCAL_CRATE) {

compiler/rustc_mir_transform/src/inline.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,7 @@ impl<'tcx> Inliner<'tcx> {
439439

440440
// Reachability pass defines which functions are eligible for inlining. Generally inlining
441441
// other functions is incorrect because they could reference symbols that aren't exported.
442-
let is_generic = callsite
443-
.callee
444-
.args
445-
.non_erasable_generics(self.tcx, callsite.callee.def_id())
446-
.next()
447-
.is_some();
442+
let is_generic = callsite.callee.args.non_erasable_generics().next().is_some();
448443
if !is_generic && !cross_crate_inlinable {
449444
return Err("not exported");
450445
}

0 commit comments

Comments
 (0)