Skip to content

Commit 8c6c542

Browse files
committed
rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
1 parent aec4e81 commit 8c6c542

15 files changed

+22
-22
lines changed

clippy_lints/src/dereference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ impl TyCoercionStability {
771771
DefinedTy::Mir(ty) => Self::for_mir_ty(
772772
cx.tcx,
773773
ty.param_env,
774-
cx.tcx.erase_late_bound_regions(ty.value),
774+
cx.tcx.instantiate_bound_regions_with_erased(ty.value),
775775
for_return,
776776
),
777777
}

clippy_lints/src/functions/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn result_err_ty<'tcx>(
2323
&& let hir::FnRetTy::Return(hir_ty) = decl.output
2424
&& let ty = cx
2525
.tcx
26-
.erase_late_bound_regions(cx.tcx.fn_sig(id).instantiate_identity().output())
26+
.instantiate_bound_regions_with_erased(cx.tcx.fn_sig(id).instantiate_identity().output())
2727
&& is_type_diagnostic_item(cx, ty, sym::Result)
2828
&& let ty::Adt(_, args) = ty.kind()
2929
{

clippy_lints/src/iter_not_returning_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefI
7171
if sig.decl.implicit_self.has_implicit_self() {
7272
let ret_ty = cx
7373
.tcx
74-
.erase_late_bound_regions(cx.tcx.fn_sig(fn_id).instantiate_identity().output());
74+
.instantiate_bound_regions_with_erased(cx.tcx.fn_sig(fn_id).instantiate_identity().output());
7575
let ret_ty = cx
7676
.tcx
7777
.try_normalize_erasing_regions(cx.param_env, ret_ty)

clippy_lints/src/methods/map_flatten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn is_map_to_option(cx: &LateContext<'_>, map_arg: &Expr<'_>) -> bool {
6363
ty::Closure(_, args) => args.as_closure().sig(),
6464
_ => map_closure_ty.fn_sig(cx.tcx),
6565
};
66-
let map_closure_return_ty = cx.tcx.erase_late_bound_regions(map_closure_sig.output());
66+
let map_closure_return_ty = cx.tcx.instantiate_bound_regions_with_erased(map_closure_sig.output());
6767
is_type_diagnostic_item(cx, map_closure_return_ty, sym::Option)
6868
},
6969
_ => false,

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3897,7 +3897,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
38973897
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));
38983898
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind {
38993899
let method_sig = cx.tcx.fn_sig(impl_item.owner_id).instantiate_identity();
3900-
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
3900+
let method_sig = cx.tcx.instantiate_bound_regions_with_erased(method_sig);
39013901
let first_arg_ty_opt = method_sig.inputs().iter().next().copied();
39023902
// if this impl block implements a trait, lint in trait definition instead
39033903
if !implements_trait && cx.effective_visibilities.is_exported(impl_item.owner_id.def_id) {

clippy_lints/src/methods/needless_collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -
225225
&& let sig = cx.tcx.fn_sig(id).instantiate_identity()
226226
&& sig.skip_binder().output().is_bool()
227227
&& let [_, search_ty] = *sig.skip_binder().inputs()
228-
&& let ty::Ref(_, search_ty, Mutability::Not) = *cx.tcx.erase_late_bound_regions(sig.rebind(search_ty)).kind()
228+
&& let ty::Ref(_, search_ty, Mutability::Not) = *cx.tcx.instantiate_bound_regions_with_erased(sig.rebind(search_ty)).kind()
229229
&& let Some(iter_trait) = cx.tcx.get_diagnostic_item(sym::Iterator)
230230
&& let Some(iter_item) = cx.tcx.associated_items(iter_trait).find_by_name_and_kind(
231231
cx.tcx,

clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
165165
match typ.kind() {
166166
ty::FnDef(..) | ty::FnPtr(_) => {
167167
let sig = typ.fn_sig(self.cx.tcx);
168-
if self.cx.tcx.erase_late_bound_regions(sig).output().kind() == &ty::Never {
168+
if self.cx.tcx.instantiate_bound_regions_with_erased(sig).output().kind() == &ty::Never {
169169
self.report_diverging_sub_expr(e);
170170
}
171171
},

clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl MutableKeyType {
143143
for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs().skip_binder()) {
144144
self.check_ty_(cx, hir_ty.span, *ty);
145145
}
146-
self.check_ty_(cx, decl.output.span(), cx.tcx.erase_late_bound_regions(fn_sig.output()));
146+
self.check_ty_(cx, decl.output.span(), cx.tcx.instantiate_bound_regions_with_erased(fn_sig.output()));
147147
}
148148

149149
// We want to lint 1. sets or maps with 2. not immutable key types and 3. no unerased

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'tcx> PassByRefOrValue {
177177
_ => (),
178178
}
179179

180-
let ty = cx.tcx.erase_late_bound_regions(fn_sig.rebind(ty));
180+
let ty = cx.tcx.instantiate_bound_regions_with_erased(fn_sig.rebind(ty));
181181
if is_copy(cx, ty)
182182
&& let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes())
183183
&& size <= self.ref_min_size
@@ -225,7 +225,7 @@ impl<'tcx> PassByRefOrValue {
225225
_ => continue,
226226
}
227227
}
228-
let ty = cx.tcx.erase_late_bound_regions(ty);
228+
let ty = cx.tcx.instantiate_bound_regions_with_erased(ty);
229229

230230
if is_copy(cx, ty)
231231
&& !is_self_ty(input)

clippy_lints/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fn matches_preds<'tcx>(
712712
preds: &'tcx [ty::PolyExistentialPredicate<'tcx>],
713713
) -> bool {
714714
let infcx = cx.tcx.infer_ctxt().build();
715-
preds.iter().all(|&p| match cx.tcx.erase_late_bound_regions(p) {
715+
preds.iter().all(|&p| match cx.tcx.instantiate_bound_regions_with_erased(p) {
716716
ExistentialPredicate::Trait(p) => infcx
717717
.type_implements_trait(p.def_id, [ty.into()].into_iter().chain(p.args.iter()), cx.param_env)
718718
.must_apply_modulo_regions(),

clippy_lints/src/unit_return_expecting_ord.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
4444
let mut preds = Vec::new();
4545
for (pred, _) in generics.predicates {
4646
if let ClauseKind::Trait(poly_trait_pred) = pred.kind().skip_binder()
47-
&& let trait_pred = cx.tcx.erase_late_bound_regions(pred.kind().rebind(poly_trait_pred))
47+
&& let trait_pred = cx.tcx.instantiate_bound_regions_with_erased(pred.kind().rebind(poly_trait_pred))
4848
&& let Some(trait_def_id) = trait_id
4949
&& trait_def_id == trait_pred.trait_ref.def_id
5050
{
@@ -61,7 +61,7 @@ fn get_projection_pred<'tcx>(
6161
) -> Option<ProjectionPredicate<'tcx>> {
6262
generics.predicates.iter().find_map(|(proj_pred, _)| {
6363
if let ClauseKind::Projection(pred) = proj_pred.kind().skip_binder() {
64-
let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred.kind().rebind(pred));
64+
let projection_pred = cx.tcx.instantiate_bound_regions_with_erased(proj_pred.kind().rebind(pred));
6565
if projection_pred.projection_ty.args == trait_pred.trait_ref.args {
6666
return Some(projection_pred);
6767
}
@@ -79,10 +79,10 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
7979
let ord_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.get_diagnostic_item(sym::Ord));
8080
let partial_ord_preds =
8181
get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait());
82-
// Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error
82+
// Trying to call instantiate_bound_regions_with_erased on fn_sig.inputs() gives the following error
8383
// The trait `rustc::ty::TypeFoldable<'_>` is not implemented for
8484
// `&[rustc_middle::ty::Ty<'_>]`
85-
let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output());
85+
let inputs_output = cx.tcx.instantiate_bound_regions_with_erased(fn_sig.inputs_and_output());
8686
inputs_output
8787
.iter()
8888
.rev()
@@ -116,7 +116,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
116116
if let ExprKind::Closure(&Closure { body, fn_decl_span, .. }) = arg.kind
117117
&& let ty::Closure(_def_id, args) = &cx.typeck_results().node_type(arg.hir_id).kind()
118118
&& let ret_ty = args.as_closure().sig().output()
119-
&& let ty = cx.tcx.erase_late_bound_regions(ret_ty)
119+
&& let ty = cx.tcx.instantiate_bound_regions_with_erased(ret_ty)
120120
&& ty.is_unit()
121121
{
122122
let body = cx.tcx.hir().body(body);

clippy_lints/src/unnecessary_box_returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl UnnecessaryBoxReturns {
7171

7272
let return_ty = cx
7373
.tcx
74-
.erase_late_bound_regions(cx.tcx.fn_sig(def_id).skip_binder())
74+
.instantiate_bound_regions_with_erased(cx.tcx.fn_sig(def_id).skip_binder())
7575
.output();
7676

7777
if !return_ty.is_box() {

clippy_lints/src/use_self.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
159159
.trait_item_def_id
160160
.expect("impl method matches a trait method");
161161
let trait_method_sig = cx.tcx.fn_sig(trait_method).instantiate_identity();
162-
let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig);
162+
let trait_method_sig = cx.tcx.instantiate_bound_regions_with_erased(trait_method_sig);
163163

164164
// `impl_inputs_outputs` is an iterator over the types (`hir::Ty`) declared in the
165165
// implementation of the trait.

clippy_utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,13 +1667,13 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
16671667
/// Convenience function to get the return type of a function.
16681668
pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_def_id: hir::OwnerId) -> Ty<'tcx> {
16691669
let ret_ty = cx.tcx.fn_sig(fn_def_id).instantiate_identity().output();
1670-
cx.tcx.erase_late_bound_regions(ret_ty)
1670+
cx.tcx.instantiate_bound_regions_with_erased(ret_ty)
16711671
}
16721672

16731673
/// Convenience function to get the nth argument type of a function.
16741674
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_def_id: hir::OwnerId, nth: usize) -> Ty<'tcx> {
16751675
let arg = cx.tcx.fn_sig(fn_def_id).instantiate_identity().input(nth);
1676-
cx.tcx.erase_late_bound_regions(arg)
1676+
cx.tcx.instantiate_bound_regions_with_erased(arg)
16771677
}
16781678

16791679
/// Checks if an expression is constructing a tuple-like enum variant or struct

clippy_utils/src/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ pub fn make_normalized_projection<'tcx>(
11691169
debug_assert!(
11701170
false,
11711171
"args contain late-bound region at index `{i}` which can't be normalized.\n\
1172-
use `TyCtxt::erase_late_bound_regions`\n\
1172+
use `TyCtxt::instantiate_bound_regions_with_erased`\n\
11731173
note: arg is `{arg:#?}`",
11741174
);
11751175
return None;
@@ -1247,7 +1247,7 @@ pub fn make_normalized_projection_with_regions<'tcx>(
12471247
debug_assert!(
12481248
false,
12491249
"args contain late-bound region at index `{i}` which can't be normalized.\n\
1250-
use `TyCtxt::erase_late_bound_regions`\n\
1250+
use `TyCtxt::instantiate_bound_regions_with_erased`\n\
12511251
note: arg is `{arg:#?}`",
12521252
);
12531253
return None;

0 commit comments

Comments
 (0)