Skip to content

Infinite loop in macro expansion #3829

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

Closed
nikomatsakis opened this issue Oct 22, 2012 · 2 comments
Closed

Infinite loop in macro expansion #3829

nikomatsakis opened this issue Oct 22, 2012 · 2 comments
Labels
A-syntaxext Area: Syntax extensions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@nikomatsakis
Copy link
Contributor

This program (which, as far as I can tell, is ok?) seems to loop infinitely:

fn macros() {
    macro_rules! if_ok(
        ($inp: expr) => (
            match $inp {
                Ok(move v) => { move v }
                Err(move e) => { return Err(e); }
            }
        )
    );
}

fn main() {
    let r = Ok(2);
    let p = if_ok!(move r);
    assert p == 2;
}
@paulstansifer
Copy link
Contributor

I wasn't able to get it to compile as-is (it needed a definition for Ok and Err, and to be called in a function that could return Err(...), so I changed it to the following. However, it now Works For Me™; perhaps it's been fixed?

enum Result {
    Ok(int), Err(int)
}

fn macros() {
    macro_rules! if_ok(
        ($inp: expr) => (
            match $inp {
                Ok(move v) => { move v }
                Err(move e) => { return Err(e); }
            }
        )
    );
}

fn f() -> Result {
    let r = Ok(2);
    let p = if_ok!(move r);
    assert p == 2;
    return Ok(p);
}

fn main() {
    f();
}

@nikomatsakis
Copy link
Contributor Author

this was user error on my part, I thought I closed this bug a long time ago!

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Add `init_log()` function which attempts to init logger, and
ignores failure. The function is called at the beginning of
every test, and will fail if the logger is already initialized.
The logger must be initialized in every test, becuase cargo runs
the tests in parallel, with no garentees about the order and time
each starts.
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 30, 2024
epoll: handle edge case for epoll_ctl

There is a test case that revealed that our implementation differs from the real system:
 - Set up an epoll watching the FD
- Call epoll_wait
- Set up another epoll watching the same FD
- Call epoll_wait on the first epoll. Nothing should be reported!

This happened because, in ``epoll_ctl``, we used ``check_and_update_readiness``, which is a function that would return notification for all epoll file description that registered a particular file description. But we shouldn't do that because no notification should be returned if there is no I/O activity between two ``epoll_wait`` (every first ``epoll_wait`` that happens after ``epoll_ctl`` is an exception, we should return notification that reflects the readiness of file description).

r? `@oli-obk`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants