Change:
| = help: a `loop` may express intention better if this is on purpose <del> error: aborting due to 14 previous errors </del> <ins> error: function cannot return without recursing --> $DIR/lint-unconditional-recursion.rs:162:1 | LL | pub fn drop_and_replace(mut a: Option<String>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing LL |     a = None; LL |     drop_and_replace(a); |     ------------------- recursive call site | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing --> $DIR/lint-unconditional-recursion.rs:168:1 | LL | pub fn call() -> String { | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing LL |     let s = String::new(); LL |     call(); |     ------ recursive call site | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing --> $DIR/lint-unconditional-recursion.rs:175:1 | LL | pub fn overflow_check(a: i32, b: i32) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing LL |     let _ = a + b; LL |     overflow_check(a, b); |     -------------------- recursive call site | = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing --> $DIR/lint-unconditional-recursion.rs:186:5 | LL |     fn default() -> Self { |     ^^^^^^^^^^^^^^^^^^^^ cannot return without recursing ... LL |             ..Default::default() |               ------------------ recursive call site | = help: a `loop` may express intention better if this is on purpose error: aborting due to 18 previous errors </ins>

Discussion:
<!-- Thank you for filing a regression report! A regression is something that changed between versions of Rust but was not supposed to. Please provide a short summary of the regression, along with any information you feel is relevant to replicate it. --I tried this code which causes a stack overflow due to a recursive call of I mistakenly . I expected to see the warning. However, the compiler didn't complain it. <!-- Provide the most recent version this worked on, for example: It most recently worked on: Rust 1.47 --It most recently worked on: 1.43.0 showed the warning. (ref. ) The warning isn't shown on 1.44.0 or later, including the current stable 1.47.0. <!-- Provide the version you are using that has the regression. --<!-- Did the compiler crash? If so, please provide a backtrace. --<!-- If you know when this regression occurred, please add a line like below, replacing with one of stable, beta, or nightly. modify labels: +regression-from-stable-to-{channel} -regression-untriaged --
I think this was caused by , but it looks like expected behavior: If diverges, the self-recursion never happens.
Though maybe the lint should assume that functions returning an inhabited type won't diverge (since otherwise they should be marked ). I can definitely see why people would write code like this, so linting on it makes sense.
I personally feel that we should lint for functions if they don't return an uninhabited type. Even if someone wants to exit recursion by unwinding I do feel that a lint is still appropriate here as it is really bad style imo.
Thanks for the quick response. Yeah, it'd be natural to expect a function whose return type is not to return eventually. Probably, we might want to have the following rules?: for self-recursion unless a function returning an uninhabited type is called in advance. a non-diverge function is called before a self-recursion, show a message like "if this diverges, please annotate it." in addition to the warning. 1 would help my case and 2 would help the case of . (2 is not necessary, though.)
Assigning as and removing .