Skip to content

Commit 2200911

Browse files
committed
Rename many interner functions.
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
1 parent 29b51cd commit 2200911

File tree

111 files changed

+364
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+364
-363
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14941494
assert!(root_place.projection.is_empty());
14951495
let proper_span = self.body.local_decls[root_place.local].source_info.span;
14961496

1497-
let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection);
1497+
let root_place_projection = self.infcx.tcx.mk_place_elems(root_place.projection);
14981498

14991499
if self.access_place_error_reported.contains(&(
15001500
Place { local: root_place.local, projection: root_place_projection },

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2633,7 +2633,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
26332633
DefKind::InlineConst => substs.as_inline_const().parent_substs(),
26342634
other => bug!("unexpected item {:?}", other),
26352635
};
2636-
let parent_substs = tcx.intern_substs(parent_substs);
2636+
let parent_substs = tcx.mk_substs(parent_substs);
26372637

26382638
assert_eq!(typeck_root_substs.len(), parent_substs.len());
26392639
if let Err(_) = self.eq_substs(

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
516516
let va_list_ty =
517517
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
518518

519-
unnormalized_input_tys = self.infcx.tcx.mk_type_list(
519+
unnormalized_input_tys = self.infcx.tcx.mk_type_list_from_iter(
520520
unnormalized_input_tys.iter().copied().chain(iter::once(va_list_ty)),
521521
);
522522
}
@@ -656,7 +656,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
656656
assert_eq!(self.mir_def.did.to_def_id(), def_id);
657657
let closure_sig = substs.as_closure().sig();
658658
let inputs_and_output = closure_sig.inputs_and_output();
659-
let bound_vars = tcx.mk_bound_variable_kinds(
659+
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
660660
inputs_and_output
661661
.bound_vars()
662662
.iter()
@@ -680,7 +680,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
680680
};
681681

682682
ty::Binder::bind_with_vars(
683-
tcx.mk_type_list(
683+
tcx.mk_type_list_from_iter(
684684
iter::once(closure_ty).chain(inputs).chain(iter::once(output)),
685685
),
686686
bound_vars,
@@ -693,7 +693,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
693693
let output = substs.as_generator().return_ty();
694694
let generator_ty = tcx.mk_generator(def_id, substs, movability);
695695
let inputs_and_output =
696-
self.infcx.tcx.intern_type_list(&[generator_ty, resume_ty, output]);
696+
self.infcx.tcx.mk_type_list(&[generator_ty, resume_ty, output]);
697697
ty::Binder::dummy(inputs_and_output)
698698
}
699699

@@ -709,13 +709,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
709709
assert_eq!(self.mir_def.did.to_def_id(), def_id);
710710
let ty = tcx.type_of(self.mir_def.def_id_for_type_of()).subst_identity();
711711
let ty = indices.fold_to_region_vids(tcx, ty);
712-
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
712+
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
713713
}
714714

715715
DefiningTy::InlineConst(def_id, substs) => {
716716
assert_eq!(self.mir_def.did.to_def_id(), def_id);
717717
let ty = substs.as_inline_const().ty();
718-
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
718+
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
719719
}
720720
}
721721
}

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
405405
};
406406

407407
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
408-
let extra_args = fx
409-
.tcx
410-
.mk_type_list(extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))));
408+
let extra_args = fx.tcx.mk_type_list_from_iter(
409+
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))),
410+
);
411411
let fn_abi = if let Some(instance) = instance {
412412
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
413413
} else {

compiler/rustc_codegen_cranelift/src/codegen_i128.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(crate) fn maybe_codegen<'tcx>(
5656
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
5757
}
5858
} else {
59-
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
59+
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
6060
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
6161
let lhs = lhs.load_scalar(fx);
6262
let rhs = rhs.load_scalar(fx);
@@ -78,7 +78,7 @@ pub(crate) fn maybe_codegen<'tcx>(
7878
}
7979
BinOp::Add | BinOp::Sub | BinOp::Mul => {
8080
assert!(checked);
81-
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
81+
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
8282
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
8383
let (param_types, args) = if fx.tcx.sess.target.is_like_windows {
8484
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn llvm_add_sub<'tcx>(
191191
// carry0 | carry1 -> carry or borrow respectively
192192
let cb_out = fx.bcx.ins().bor(cb0, cb1);
193193

194-
let layout = fx.layout_of(fx.tcx.intern_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
194+
let layout = fx.layout_of(fx.tcx.mk_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
195195
let val = CValue::by_val_pair(cb_out, c, layout);
196196
ret.write_cvalue(fx, val);
197197
}

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub(crate) fn maybe_create_entry_wrapper(
119119
tcx,
120120
ParamEnv::reveal_all(),
121121
report.def_id,
122-
tcx.intern_substs(&[GenericArg::from(main_ret_ty)]),
122+
tcx.mk_substs(&[GenericArg::from(main_ret_ty)]),
123123
)
124124
.unwrap()
125125
.unwrap()
@@ -146,7 +146,7 @@ pub(crate) fn maybe_create_entry_wrapper(
146146
tcx,
147147
ParamEnv::reveal_all(),
148148
start_def_id,
149-
tcx.intern_substs(&[main_ret_ty.into()]),
149+
tcx.mk_substs(&[main_ret_ty.into()]),
150150
)
151151
.unwrap()
152152
.unwrap()

compiler/rustc_codegen_cranelift/src/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
289289
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
290290
};
291291

292-
let out_layout = fx.layout_of(fx.tcx.intern_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
292+
let out_layout = fx.layout_of(fx.tcx.mk_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
293293
CValue::by_val_pair(res, has_overflow, out_layout)
294294
}
295295

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
383383
tcx,
384384
ty::ParamEnv::reveal_all(),
385385
def_id,
386-
tcx.intern_substs(&[]),
386+
tcx.mk_substs(&[]),
387387
)
388388
.unwrap().unwrap(),
389389
),

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,9 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
520520
let tcx = self.tcx;
521521
let llfn = match tcx.lang_items().eh_personality() {
522522
Some(def_id) if !wants_msvc_seh(self.sess()) => self.get_fn_addr(
523-
ty::Instance::resolve(
524-
tcx,
525-
ty::ParamEnv::reveal_all(),
526-
def_id,
527-
tcx.intern_substs(&[]),
528-
)
529-
.unwrap()
530-
.unwrap(),
523+
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, tcx.mk_substs(&[]))
524+
.unwrap()
525+
.unwrap(),
531526
),
532527
_ => {
533528
let name = if wants_msvc_seh(self.sess()) {

0 commit comments

Comments
 (0)