Skip to content

Commit 8c6aa6b

Browse files
committed
Simplify some code paths and remove an unused field
`ct_infer` and `lower_ty` will correctly result in an error constant or type respectively, as they go through a `HirTyLowerer` method (just like `HirTyLowerer::allow_infer` is a method implemented by both implementors
1 parent 872fae6 commit 8c6aa6b

File tree

1 file changed

+3
-15
lines changed
  • compiler/rustc_hir_analysis/src/hir_ty_lowering

1 file changed

+3
-15
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
424424
def_id: DefId,
425425
generic_args: &'a GenericArgs<'tcx>,
426426
span: Span,
427-
inferred_params: Vec<Span>,
428427
infer_args: bool,
429428
}
430429

@@ -445,7 +444,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
445444
) -> ty::GenericArg<'tcx> {
446445
let tcx = self.lowerer.tcx();
447446

448-
let mut handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
447+
let handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
449448
if has_default {
450449
tcx.check_optional_stability(
451450
param.def_id,
@@ -462,12 +461,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
462461
},
463462
);
464463
}
465-
if let (hir::TyKind::Infer, false) = (&ty.kind, self.lowerer.allow_infer()) {
466-
self.inferred_params.push(ty.span);
467-
Ty::new_misc_error(tcx).into()
468-
} else {
469-
self.lowerer.lower_ty(ty).into()
470-
}
464+
self.lowerer.lower_ty(ty).into()
471465
};
472466

473467
match (&param.kind, arg) {
@@ -491,12 +485,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
491485
.type_of(param.def_id)
492486
.no_bound_vars()
493487
.expect("const parameter types cannot be generic");
494-
if self.lowerer.allow_infer() {
495-
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
496-
} else {
497-
self.inferred_params.push(inf.span);
498-
ty::Const::new_misc_error(tcx, ty).into()
499-
}
488+
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
500489
}
501490
(kind, arg) => span_bug!(
502491
self.span,
@@ -578,7 +567,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
578567
def_id,
579568
span,
580569
generic_args: segment.args(),
581-
inferred_params: vec![],
582570
infer_args: segment.infer_args,
583571
};
584572
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness

0 commit comments

Comments
 (0)