pub static RECURSION_DEPTH_EXCEEDING_LIMIT: &LintExpand description
The recursion_depth_exceeding_limit lint detects cases where the compiler does not
correctly track the recursion depth in obligation evaluation.
§Example
rustc -Znext-solver example.rsⓘ
#![recursion_limit = "8"]
struct Foo<T> {
t: T,
opt_t: Option<T>,
}
fn require_sync<T: Sync>() {}
fn main() {
require_sync::<Foo<Foo<Foo<Foo<Foo<Foo<()>>>>>>>();
}This will produces:
error[E0275]: overflow evaluating the requirement `Foo<Foo<Foo<Foo<Foo<Foo<()>>>>>>: Sync`
--> example.rs:12:20
|
| require_sync::<Foo<Foo<Foo<Foo<Foo<Foo<()>>>>>>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "16"]` attribute to your crate
note: required by a bound in `require_sync`
--> example.rs:9:20
|
| fn require_sync<T: Sync>() {}
| ^^^^ required by this bound in `require_sync`§Explanation
The compiler uses a recursion limit in obligation evaluation to avoid hangs.
However, the old trait solver sometimes ignores the recursion depth, whereas the new solver correctly tracks it. This reveals cases where overflow should have occurred previously.
This is a future-incompatible lint to transition this to a hard error in the future.