Skip to content

Commit c596c91

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 b40fee9 commit c596c91

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
@@ -421,7 +421,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
421421
def_id: DefId,
422422
generic_args: &'a GenericArgs<'tcx>,
423423
span: Span,
424-
inferred_params: Vec<Span>,
425424
infer_args: bool,
426425
incorrect_args: &'a Result<(), GenericArgCountMismatch>,
427426
}
@@ -450,7 +449,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
450449
}
451450
}
452451

453-
let mut handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
452+
let handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
454453
if has_default {
455454
tcx.check_optional_stability(
456455
param.def_id,
@@ -467,12 +466,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
467466
},
468467
);
469468
}
470-
if let (hir::TyKind::Infer, false) = (&ty.kind, self.lowerer.allow_infer()) {
471-
self.inferred_params.push(ty.span);
472-
Ty::new_misc_error(tcx).into()
473-
} else {
474-
self.lowerer.lower_ty(ty).into()
475-
}
469+
self.lowerer.lower_ty(ty).into()
476470
};
477471

478472
match (&param.kind, arg) {
@@ -496,12 +490,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
496490
.type_of(param.def_id)
497491
.no_bound_vars()
498492
.expect("const parameter types cannot be generic");
499-
if self.lowerer.allow_infer() {
500-
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
501-
} else {
502-
self.inferred_params.push(inf.span);
503-
ty::Const::new_misc_error(tcx, ty).into()
504-
}
493+
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
505494
}
506495
(kind, arg) => span_bug!(
507496
self.span,
@@ -604,7 +593,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
604593
def_id,
605594
span,
606595
generic_args: segment.args(),
607-
inferred_params: vec![],
608596
infer_args: segment.infer_args,
609597
incorrect_args: &arg_count.correct,
610598
};

0 commit comments

Comments
 (0)