Skip to content

Commit 06c1da2

Browse files
committed
hir: Use InferArg in ArrayLen::Infer
1 parent 0f4d840 commit 06c1da2

File tree

7 files changed

+15
-10
lines changed

7 files changed

+15
-10
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23052305
match c.value.kind {
23062306
ExprKind::Underscore => {
23072307
if self.tcx.features().generic_arg_infer {
2308-
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
2308+
hir::ArrayLen::Infer(hir::InferArg {
2309+
hir_id: self.lower_node_id(c.id),
2310+
span: self.lower_span(c.value.span),
2311+
})
23092312
} else {
23102313
feature_err(
23112314
&self.tcx.sess,

compiler/rustc_hir/src/hir.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1531,14 +1531,16 @@ pub type Lit = Spanned<LitKind>;
15311531

15321532
#[derive(Copy, Clone, Debug, HashStable_Generic)]
15331533
pub enum ArrayLen {
1534-
Infer(HirId, Span),
1534+
Infer(InferArg),
15351535
Body(AnonConst),
15361536
}
15371537

15381538
impl ArrayLen {
15391539
pub fn hir_id(&self) -> HirId {
15401540
match self {
1541-
&ArrayLen::Infer(hir_id, _) | &ArrayLen::Body(AnonConst { hir_id, .. }) => hir_id,
1541+
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(AnonConst { hir_id, .. }) => {
1542+
*hir_id
1543+
}
15421544
}
15431545
}
15441546
}
@@ -2423,7 +2425,7 @@ impl<'hir> Ty<'hir> {
24232425
TyKind::Infer => true,
24242426
TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
24252427
TyKind::Array(ty, length) => {
2426-
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(_, _))
2428+
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(..))
24272429
}
24282430
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
24292431
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),

compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'
669669

670670
pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
671671
match len {
672-
&ArrayLen::Infer(hir_id, _span) => visitor.visit_id(hir_id),
672+
ArrayLen::Infer(InferArg { hir_id, span: _ }) => visitor.visit_id(*hir_id),
673673
ArrayLen::Body(c) => visitor.visit_anon_const(c),
674674
}
675675
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25292529
}
25302530
hir::TyKind::Array(ty, length) => {
25312531
let length = match length {
2532-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(tcx.types.usize, None, span),
2532+
hir::ArrayLen::Infer(inf) => self.ct_infer(tcx.types.usize, None, inf.span),
25332533
hir::ArrayLen::Body(constant) => {
25342534
ty::Const::from_anon_const(tcx, constant.def_id)
25352535
}

compiler/rustc_hir_analysis/src/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
146146
}
147147
}
148148
fn visit_array_length(&mut self, length: &'v hir::ArrayLen) {
149-
if let &hir::ArrayLen::Infer(_, span) = length {
150-
self.0.push(span);
149+
if let hir::ArrayLen::Infer(inf) = length {
150+
self.0.push(inf.span);
151151
}
152152
intravisit::walk_array_len(self, length)
153153
}

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a> State<'a> {
956956

957957
fn print_array_length(&mut self, len: &hir::ArrayLen) {
958958
match len {
959-
hir::ArrayLen::Infer(_, _) => self.word("_"),
959+
hir::ArrayLen::Infer(..) => self.word("_"),
960960
hir::ArrayLen::Body(ct) => self.print_anon_const(ct),
961961
}
962962
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
405405

406406
pub fn array_length_to_const(&self, length: &hir::ArrayLen) -> ty::Const<'tcx> {
407407
match length {
408-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(self.tcx.types.usize, None, span),
408+
hir::ArrayLen::Infer(inf) => self.ct_infer(self.tcx.types.usize, None, inf.span),
409409
hir::ArrayLen::Body(anon_const) => {
410410
let span = self.tcx.def_span(anon_const.def_id);
411411
let c = ty::Const::from_anon_const(self.tcx, anon_const.def_id);

0 commit comments

Comments
 (0)