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
This commit is contained in:
Oli Scherer 2024-05-31 10:52:00 +00:00
parent dc020ae5d8
commit 9d387d14e0

View file

@ -421,7 +421,6 @@ struct GenericArgsCtxt<'a, 'tcx> {
def_id: DefId,
generic_args: &'a GenericArgs<'tcx>,
span: Span,
inferred_params: Vec<Span>,
infer_args: bool,
incorrect_args: &'a Result<(), GenericArgCountMismatch>,
}
@ -450,7 +449,7 @@ fn provided_kind(
}
}
let mut handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
let handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
if has_default {
tcx.check_optional_stability(
param.def_id,
@ -467,12 +466,7 @@ fn provided_kind(
},
);
}
if let (hir::TyKind::Infer, false) = (&ty.kind, self.lowerer.allow_infer()) {
self.inferred_params.push(ty.span);
Ty::new_misc_error(tcx).into()
} else {
self.lowerer.lower_ty(ty).into()
}
};
match (&param.kind, arg) {
@ -496,12 +490,7 @@ fn provided_kind(
.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic");
if self.lowerer.allow_infer() {
self.lowerer.ct_infer(ty, Some(param), inf.span).into()
} else {
self.inferred_params.push(inf.span);
ty::Const::new_misc_error(tcx, ty).into()
}
}
(kind, arg) => span_bug!(
self.span,
@ -604,7 +593,6 @@ fn inferred_kind(
def_id,
span,
generic_args: segment.args(),
inferred_params: vec![],
infer_args: segment.infer_args,
incorrect_args: &arg_count.correct,
};