1
Fork 0

Mark all extraneous generic args as errors

This commit is contained in:
Oli Scherer 2024-06-03 13:21:17 +00:00
parent 2e3842b6d0
commit adb2ac0165
8 changed files with 77 additions and 63 deletions

View file

@ -442,6 +442,25 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
) -> ty::GenericArg<'tcx> {
let tcx = self.lowerer.tcx();
if let Err(incorrect) = self.incorrect_args {
if incorrect.invalid_args.contains(&(param.index as usize)) {
return match param.kind {
GenericParamDefKind::Lifetime => {
ty::Region::new_error(tcx, incorrect.reported).into()
}
GenericParamDefKind::Type { .. } => {
Ty::new_error(tcx, incorrect.reported).into()
}
GenericParamDefKind::Const { .. } => ty::Const::new_error(
tcx,
incorrect.reported,
Ty::new_error(tcx, incorrect.reported),
)
.into(),
};
}
}
let mut handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
if has_default {
tcx.check_optional_stability(