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

Internal compiler error with unreachable nested if-expression #11865

Closed
nmsmith opened this issue Jan 28, 2014 · 2 comments
Closed

Internal compiler error with unreachable nested if-expression #11865

nmsmith opened this issue Jan 28, 2014 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nmsmith
Copy link

nmsmith commented Jan 28, 2014

The following code causes a compiler error:

fn main() {
    not(true);
}

fn not(b: bool) -> bool {
    if b {
        !b
    } else {
        fail!("Break the compiler");
        if !b {

        }
    }
}

The error message:

error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: the compiler hit an unexpected failure path. this is a bug
task 'rustc' failed at 'assertion failed: dest == expr::Ignore || bcx.unreachable.get()', /home/nick/workspace/rust/src/librustc/middle/trans/controlflow.rs:91
@Armavica
Copy link
Contributor

I can reproduce it with the latest build, but not with

virgile@Serenno:~/tmp$ rustc -v
rustc 0.10-pre (77eedda 2014-01-13 23:26:36 -0800)
host: x86_64-unknown-linux-gnu

So the problem probably comes from something that happened meanwhile.

@huonw
Copy link
Member

huonw commented Feb 1, 2014

cc #11709

(They fail on the same assertion, but the triggering code seems quite different.)

flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 11, 2024
feat: add `manual_is_variant_and` lint

changelog: add a new lint [`manual_is_variant_and`].
- Replace `option.map(f).unwrap_or_default()` and `result.map(f).unwrap_or_default()` with `option.is_some_and(f)` and `result.is_ok_and(f)` where `f` is a function or closure that returns `bool`.
- MSRV is set to 1.70.0 for this lint; when `is_some_and` and `is_ok_and` was stabilised

---

For example, for the following code:

```rust
let opt = Some(0);
opt.map(|x| x > 1).unwrap_or_default();
```

It suggests to instead write:

```rust
let opt = Some(0);
opt.is_some_and(|x| x > 1)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants