Skip to content

Commit 2e5a0dc

Browse files
committed
add a miscompilation test
1 parent 31ad5f6 commit 2e5a0dc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/run-pass/issue-73223.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn main() {
2+
let mut state = State { prev: None, next: Some(8) };
3+
let path = "/nested/some/more";
4+
assert_eq!(state.rest(path), "some/more");
5+
}
6+
7+
struct State {
8+
prev: Option<usize>,
9+
next: Option<usize>,
10+
}
11+
12+
impl State {
13+
fn rest<'r>(&mut self, path: &'r str) -> &'r str {
14+
let start = match self.next.take() {
15+
Some(v) => v,
16+
None => return "",
17+
};
18+
19+
self.prev = Some(start);
20+
&path[start..]
21+
}
22+
}

0 commit comments

Comments
 (0)