Skip to content

Commit 5ea5bde

Browse files
committed
add ConstArgKind::Error
1 parent 101757c commit 5ea5bde

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
@@ -473,6 +473,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
473473
match self.kind {
474474
ConstArgKind::Path(path) => path.span(),
475475
ConstArgKind::Anon(anon) => anon.span,
476+
ConstArgKind::Error(span, _) => span,
476477
ConstArgKind::Infer(span, _) => span,
477478
}
478479
}
@@ -489,6 +490,8 @@ pub enum ConstArgKind<'hir, Unambig = ()> {
489490
/// However, in the future, we'll be using it for all of those.
490491
Path(QPath<'hir>),
491492
Anon(&'hir AnonConst),
493+
/// Error const
494+
Error(Span, ErrorGuaranteed),
492495
/// This variant is not always used to represent inference consts, sometimes
493496
/// [`GenericArg::Infer`] is used instead.
494497
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
@@ -2204,6 +2204,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
22042204
}
22052205
hir::ConstArgKind::Anon(anon) => self.lower_anon_const(anon),
22062206
hir::ConstArgKind::Infer(span, ()) => self.ct_infer(None, span),
2207+
hir::ConstArgKind::Error(_, e) => ty::Const::new_error(tcx, e),
22072208
}
22082209
}
22092210

compiler/rustc_hir_pretty/src/lib.rs

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

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)