Skip to content

Commit

Permalink
Provide previous generic arguments to provided_kind
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 3, 2024
1 parent 108a1e5 commit d498eb5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub fn lower_generic_args<'tcx: 'a, 'a>(
GenericParamDefKind::Const { .. },
_,
) => {
args.push(ctx.provided_kind(param, arg));
args.push(ctx.provided_kind(&args, param, arg));
args_iter.next();
params.next();
}
Expand Down
19 changes: 3 additions & 16 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ pub trait GenericArgsLowerer<'a, 'tcx> {

fn provided_kind(
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
arg: &GenericArg<'tcx>,
) -> ty::GenericArg<'tcx>;
Expand Down Expand Up @@ -437,29 +438,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

fn provided_kind(
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
arg: &GenericArg<'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)) {
// FIXME: use `param.to_error` once `provided_kind` is supplied a list of
// all previous generic args.
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(),
};
return param.to_error(tcx, preceding_args);
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

fn provided_kind(
&mut self,
_preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
arg: &GenericArg<'tcx>,
) -> ty::GenericArg<'tcx> {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {

fn provided_kind(
&mut self,
_preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
arg: &GenericArg<'tcx>,
) -> ty::GenericArg<'tcx> {
Expand Down

0 comments on commit d498eb5

Please sign in to comment.