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

ICE with non-procedure type in 'do' expression #10700

Closed
KokaKiwi opened this issue Nov 28, 2013 · 3 comments
Closed

ICE with non-procedure type in 'do' expression #10700

KokaKiwi opened this issue Nov 28, 2013 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@KokaKiwi
Copy link

When I compile this:

type Cb<'self> = 'self |buf: &[u8]| -> bool;
// type Cb = proc(&[u8]) -> bool; // Works with this.

fn bug(cb: Cb) -> bool
{
    let arg = "hello";

    cb(arg.as_bytes())
}

fn main()
{
    do bug |s| {
        true
    };
}

Rust output this:

rustc -o bug bug.rs
bug.rs:12:7: 14:5 error: last argument in `do` call has non-procedure type: |&[u8]| -> bool
bug.rs:12     do bug |s| {
bug.rs:13         true
bug.rs:14     };
task 'rustc' failed at 'assertion failed: !ty::type_needs_infer(ty)', /build/rust-git/src/rust/src/librustc/middle/typeck/mod.rs:241
error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task '<main>' failed at 'explicit failure', /build/rust-git/src/rust/src/librustc/lib.rs:395
Makefile:6: recipe for target 'bug' failed
make: *** [bug] Error 101

This seems to me to be a lack of type checking, but I'm not sure.

PS: I'm using latest nightly Rust build from thestinger Arch repo.

@LeoTestard
Copy link
Contributor

This is not a bug. The do form has changed, and is now only valid for proc functions.

I agree that the compiler should not fail on an ICE but instead display the error message and exit, but the new way to write this is:

bug(|x| {
    // ...
});

@KokaKiwi
Copy link
Author

Yep I already know that, I posted this issue because of the ICE, not because the error message ;)
Even if the dev did a mistake, the compiler should not crash :)

@luqmana
Copy link
Member

luqmana commented Mar 1, 2014

Closing this since the do-syntax is gone now.

@luqmana luqmana closed this as completed Mar 1, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2023
add lint [`incorrect_clone_impl_on_copy_type`]

Split off from rust-lang#10788.

Closes rust-lang#10700

----

changelog: new lint [`incorrect_clone_impl_on_copy_type`]
[rust-lang#10925](rust-lang/rust-clippy#10925)
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