Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monomorphization recursion limit error should be caught earlier #18874

Open
jonasp opened this issue Nov 11, 2014 · 3 comments
Open

monomorphization recursion limit error should be caught earlier #18874

jonasp opened this issue Nov 11, 2014 · 3 comments
Labels
A-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one. I-monomorphization Issue: An error at monomorphization time. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@jonasp
Copy link

jonasp commented Nov 11, 2014

This little program gives a "reached the recursion limit during monomorphization" error.

fn main() {
    go(range(0, 5u));
}

fn go<T>(it: T) where T: Iterator<uint> {
    let mut p = it;
    match p.next() {
        Some(_) => {
            go(p.by_ref());
        }
        None => {}
    }
}

http://is.gd/3iN5Kf

The recursion limit is reached due to wrapping the iterator into ByRefs for every recursion step. IRC suggested that this could be a bug as this should be caught before monomorphization.

@steveklabnik steveklabnik added the A-type-system Area: Type system label Jan 27, 2015
@nikomatsakis
Copy link
Contributor

This is actually fairly non-trivial to do. Nonetheless we could certainly catch simple instances of it, even though we'd still have to check in trans. This may be worth the effort for the improved user experience.

@steveklabnik
Copy link
Member

Traige, no change, but updated code: http://is.gd/ODEW7P

@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 22, 2017
@steveklabnik
Copy link
Member

Triage; no change

@varkor varkor added the I-monomorphization Issue: An error at monomorphization time. label Sep 18, 2019
@fmease fmease added A-type-system Area: Type system T-types Relevant to the types team, which will review and decide on the PR/issue. and removed A-type-system Area: Type system labels Dec 21, 2024
lnicola added a commit to lnicola/rust that referenced this issue Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one. I-monomorphization Issue: An error at monomorphization time. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants