Skip to content

Commit ca3194a

Browse files
committed
allow empty field paths, but deny walking them early
1 parent 3388b75 commit ca3194a

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

compiler/rustc_middle/src/ty/field_path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl<'tcx> FieldPath<'tcx> {
4646
container: Ty<'tcx>,
4747
mut walker: impl FnMut(Ty<'tcx>, Symbol, Ty<'tcx>, bool) -> ControlFlow<T>,
4848
) -> Option<T> {
49+
assert!(!self.0.is_empty(), "tried walking empty field path");
4950
let mut cur = container;
5051
for (i, (variant, field)) in self.iter().enumerate() {
5152
let last = i == self.0.len() - 1;

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ impl<'tcx> Ty<'tcx> {
673673
container: Ty<'tcx>,
674674
field_path: FieldPath<'tcx>,
675675
) -> Ty<'tcx> {
676-
assert!(!field_path.0.is_empty());
677676
Ty::new(tcx, Field(container, field_path))
678677
}
679678

0 commit comments

Comments
 (0)