Skip to content

#![recursion_limit] behaves strangely #75602

Open
@RaphiJS6-13

Description

@RaphiJS6-13

I was playing around with recursion_limit, and I realized that recursion_limit doesn't check for bad values. #![recursion_limit = "malformed"] fn main() {}, for example, compiles without error. Moreover, when set to 1, the Rust compiler raises a weird error:

error[E0275]: overflow evaluating the requirement `&Self: std::ops::DispatchFromDyn<&RustaceansAreAwesome>`
  |
  = help: consider adding a `#![recursion_limit="2"]` attribute to your crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.

What is RustaceansAreAwesome? This code doesn't make any macro calls, yet somehow exceeds the recursion limit.

Version

rustc --version --verbose:

rustc 1.41.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.41.0
LLVM version: 9.0

Code

#![recursion_limit = "1"]
fn main() { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions