Skip to content

Commit 040001e

Browse files
authored
Rollup merge of rust-lang#109477 - lcnr:cleanup, r=cjgillot
`HirId` to `LocalDefId` cleanup revival of the still relevant parts of rust-lang#109125
2 parents 8139f47 + 0882def commit 040001e

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12081208
fn_sig,
12091209
Applicability::MachineApplicable,
12101210
);
1211-
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, hir_id, def_id) {
1211+
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, def_id) {
12121212
diag.span_suggestion(
12131213
ty.span,
12141214
"replace with an appropriate return type",
@@ -1240,12 +1240,10 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12401240
}
12411241
}
12421242

1243-
// FIXME(vincenzopalazzo): remove the hir item when the refactoring is stable
12441243
fn suggest_impl_trait<'tcx>(
12451244
tcx: TyCtxt<'tcx>,
12461245
ret_ty: Ty<'tcx>,
12471246
span: Span,
1248-
_hir_id: hir::HirId,
12491247
def_id: LocalDefId,
12501248
) -> Option<String> {
12511249
let format_as_assoc: fn(_, _, _, _, _) -> _ =

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
165165
&self,
166166
ty: Ty<'tcx>,
167167
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
168-
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id);
169-
self.err_ctxt().extract_callable_info(body_hir_id, self.param_env, ty)
168+
self.err_ctxt().extract_callable_info(self.body_id, self.param_env, ty)
170169
}
171170

172171
pub fn suggest_two_fn_call(

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ impl<'tcx> TyCtxt<'tcx> {
25252525
ident
25262526
}
25272527

2528-
// FIXME(vincenzoapalzzo): move the HirId to a LocalDefId
2528+
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
25292529
pub fn adjust_ident_and_get_scope(
25302530
self,
25312531
mut ident: Ident,

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub trait TypeErrCtxtExt<'tcx> {
212212

213213
fn extract_callable_info(
214214
&self,
215-
hir_id: HirId,
215+
body_id: LocalDefId,
216216
param_env: ty::ParamEnv<'tcx>,
217217
found: Ty<'tcx>,
218218
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)>;
@@ -909,9 +909,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
909909
trait_pred.self_ty(),
910910
);
911911

912-
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
913912
let Some((def_id_or_name, output, inputs)) = self.extract_callable_info(
914-
body_hir_id,
913+
obligation.cause.body_id,
915914
obligation.param_env,
916915
self_ty,
917916
) else { return false; };
@@ -1113,10 +1112,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
11131112
/// Extracts information about a callable type for diagnostics. This is a
11141113
/// heuristic -- it doesn't necessarily mean that a type is always callable,
11151114
/// because the callable type must also be well-formed to be called.
1116-
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
11171115
fn extract_callable_info(
11181116
&self,
1119-
hir_id: HirId,
1117+
body_id: LocalDefId,
11201118
param_env: ty::ParamEnv<'tcx>,
11211119
found: Ty<'tcx>,
11221120
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
@@ -1168,7 +1166,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
11681166
})
11691167
}
11701168
ty::Param(param) => {
1171-
let generics = self.tcx.generics_of(hir_id.owner.to_def_id());
1169+
let generics = self.tcx.generics_of(body_id);
11721170
let name = if generics.count() > param.index as usize
11731171
&& let def = generics.param_at(param.index as usize, self.tcx)
11741172
&& matches!(def.kind, ty::GenericParamDefKind::Type { .. })

0 commit comments

Comments
 (0)