From afe83aa7f766d3722e5e89f7c119a3854f2ca0ae Mon Sep 17 00:00:00 2001 From: Yifan Wu Date: Tue, 29 Nov 2022 11:13:44 +0800 Subject: [PATCH] Update stack_overflow --- user/src/bin/stack_overflow.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/user/src/bin/stack_overflow.rs b/user/src/bin/stack_overflow.rs index 5d365f5d..3bec557a 100644 --- a/user/src/bin/stack_overflow.rs +++ b/user/src/bin/stack_overflow.rs @@ -4,9 +4,12 @@ #[macro_use] extern crate user_lib; -fn f(d: usize) { - println!("d = {}", d); - f(d + 1); +#[allow(unconditional_recursion)] +fn f(depth: usize) { + if depth % 10 == 0 { + println!("depth = {}", depth); + } + f(depth + 1); } #[no_mangle]