Skip to content

Commit c293b45

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 fc6ff3d commit c293b45

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

+3-15
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
423423
def_id: DefId,
424424
generic_args: &'a GenericArgs<'tcx>,
425425
span: Span,
426-
inferred_params: Vec<Span>,
427426
infer_args: bool,
428427
}
429428

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

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

472466
match (&param.kind, arg) {
@@ -490,12 +484,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
490484
.type_of(param.def_id)
491485
.no_bound_vars()
492486
.expect("const parameter types cannot be generic");
493-
if self.lowerer.allow_infer() {
494-
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
495-
} else {
496-
self.inferred_params.push(inf.span);
497-
ty::Const::new_misc_error(tcx, ty).into()
498-
}
487+
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
499488
}
500489
(kind, arg) => span_bug!(
501490
self.span,
@@ -577,7 +566,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
577566
def_id,
578567
span,
579568
generic_args: segment.args(),
580-
inferred_params: vec![],
581569
infer_args: segment.infer_args,
582570
};
583571
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness

0 commit comments

Comments
 (0)