Skip to content

Commit fb8dfb2

Browse files
committed
Only store a span in ConstArgKind::Infer
1 parent 1c27b70 commit fb8dfb2

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2034,10 +2034,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20342034
match c.value.kind {
20352035
ExprKind::Underscore => {
20362036
if self.tcx.features().generic_arg_infer() {
2037-
let ct_kind = hir::ConstArgKind::Infer(hir::InferArg {
2038-
hir_id: self.lower_node_id(c.id),
2039-
span: self.lower_span(c.value.span),
2040-
});
2037+
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span));
20412038
self.arena.alloc(hir::ConstArg { hir_id: self.next_id(), kind: ct_kind })
20422039
} else {
20432040
feature_err(

compiler/rustc_hir/src/hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'hir> ConstArg<'hir> {
275275
match self.kind {
276276
ConstArgKind::Path(path) => path.span(),
277277
ConstArgKind::Anon(anon) => anon.span,
278-
ConstArgKind::Infer(infer) => infer.span,
278+
ConstArgKind::Infer(span) => span,
279279
}
280280
}
281281
}
@@ -294,7 +294,7 @@ pub enum ConstArgKind<'hir> {
294294
/// `ConstArgKind::Infer`. In cases where it is ambiguous whether
295295
/// a generic arg is a type or a const, inference variables are
296296
/// represented as `GenericArg::Infer` instead.
297-
Infer(InferArg),
297+
Infer(Span),
298298
}
299299

300300
#[derive(Clone, Copy, Debug, HashStable_Generic)]

compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>(
728728
match &const_arg.kind {
729729
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, const_arg.hir_id, qpath.span()),
730730
ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon),
731-
ConstArgKind::Infer(infer) => visitor.visit_infer(infer),
731+
ConstArgKind::Infer(..) => V::Result::output(),
732732
}
733733
}
734734

compiler/rustc_hir_analysis/src/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
151151
}
152152
}
153153
fn visit_const_arg(&mut self, const_arg: &'v hir::ConstArg<'v>) {
154-
if let hir::ConstArgKind::Infer(infer) = const_arg.kind {
155-
self.0.push(infer.span);
154+
if let hir::ConstArgKind::Infer(span) = const_arg.kind {
155+
self.0.push(span);
156156
}
157157
intravisit::walk_const_arg(self, const_arg)
158158
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20892089
format!("Const::lower_const_arg: invalid qpath {qpath:?}"),
20902090
),
20912091
hir::ConstArgKind::Anon(anon) => Const::from_anon_const(tcx, anon.def_id),
2092-
hir::ConstArgKind::Infer(infer) => self.ct_infer(None, infer.span),
2092+
hir::ConstArgKind::Infer(span) => self.ct_infer(None, span),
20932093
}
20942094
}
20952095

0 commit comments

Comments
 (0)