Skip to content

Commit 838684b

Browse files
BoxyUwUcamelid
authored andcommitted
add ConstArgKind::Error
1 parent 901664a commit 838684b

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
474474
match self.kind {
475475
ConstArgKind::Path(path) => path.span(),
476476
ConstArgKind::Anon(anon) => anon.span,
477+
ConstArgKind::Error(span, _) => span,
477478
ConstArgKind::Infer(span, _) => span,
478479
}
479480
}
@@ -490,6 +491,8 @@ pub enum ConstArgKind<'hir, Unambig = ()> {
490491
/// However, in the future, we'll be using it for all of those.
491492
Path(QPath<'hir>),
492493
Anon(&'hir AnonConst),
494+
/// Error const
495+
Error(Span, ErrorGuaranteed),
493496
/// This variant is not always used to represent inference consts, sometimes
494497
/// [`GenericArg::Infer`] is used instead.
495498
Infer(Span, Unambig),

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>(
10581058
match kind {
10591059
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, qpath.span()),
10601060
ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon),
1061+
ConstArgKind::Error(_, _) => V::Result::output(), // errors and spans are not important
10611062
}
10621063
}
10631064

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
22422242
}
22432243
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon),
22442244
hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span),
2245+
hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e),
22452246
}
22462247
}
22472248

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ impl<'a> State<'a> {
11311131
match &const_arg.kind {
11321132
ConstArgKind::Path(qpath) => self.print_qpath(qpath, true),
11331133
ConstArgKind::Anon(anon) => self.print_anon_const(anon),
1134+
ConstArgKind::Error(_, _) => self.word("/*ERROR*/"),
11341135
ConstArgKind::Infer(..) => self.word("_"),
11351136
}
11361137
}

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14281428
&& match tcx.hir_node_by_def_id(local_id) {
14291429
hir::Node::ConstArg(hir::ConstArg { kind, .. }) => match kind {
14301430
// Skip encoding defs for these as they should not have had a `DefId` created
1431-
hir::ConstArgKind::Path(..) | hir::ConstArgKind::Infer(..) => true,
1431+
hir::ConstArgKind::Error(..)
1432+
| hir::ConstArgKind::Path(..)
1433+
| hir::ConstArgKind::Infer(..) => true,
14321434
hir::ConstArgKind::Anon(..) => false,
14331435
},
14341436
_ => false,

0 commit comments

Comments
 (0)