add ConstArgKind::Error

This commit is contained in:
Boxy Uwu 2025-10-14 03:21:02 +01:00 committed by Noah Lev
parent 901664a7dd
commit 838684b11a
5 changed files with 9 additions and 1 deletions

View file

@ -474,6 +474,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
match self.kind {
ConstArgKind::Path(path) => path.span(),
ConstArgKind::Anon(anon) => anon.span,
ConstArgKind::Error(span, _) => span,
ConstArgKind::Infer(span, _) => span,
}
}
@ -490,6 +491,8 @@ pub enum ConstArgKind<'hir, Unambig = ()> {
/// However, in the future, we'll be using it for all of those.
Path(QPath<'hir>),
Anon(&'hir AnonConst),
/// Error const
Error(Span, ErrorGuaranteed),
/// This variant is not always used to represent inference consts, sometimes
/// [`GenericArg::Infer`] is used instead.
Infer(Span, Unambig),

View file

@ -1058,6 +1058,7 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>(
match kind {
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, qpath.span()),
ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon),
ConstArgKind::Error(_, _) => V::Result::output(), // errors and spans are not important
}
}

View file

@ -2242,6 +2242,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon),
hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span),
hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e),
}
}

View file

@ -1131,6 +1131,7 @@ impl<'a> State<'a> {
match &const_arg.kind {
ConstArgKind::Path(qpath) => self.print_qpath(qpath, true),
ConstArgKind::Anon(anon) => self.print_anon_const(anon),
ConstArgKind::Error(_, _) => self.word("/*ERROR*/"),
ConstArgKind::Infer(..) => self.word("_"),
}
}

View file

@ -1428,7 +1428,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
&& match tcx.hir_node_by_def_id(local_id) {
hir::Node::ConstArg(hir::ConstArg { kind, .. }) => match kind {
// Skip encoding defs for these as they should not have had a `DefId` created
hir::ConstArgKind::Path(..) | hir::ConstArgKind::Infer(..) => true,
hir::ConstArgKind::Error(..)
| hir::ConstArgKind::Path(..)
| hir::ConstArgKind::Infer(..) => true,
hir::ConstArgKind::Anon(..) => false,
},
_ => false,