Skip to content

error: internal compiler error: unexpected panic #21253

@kompass

Description

@kompass

Hello, I have a compiler error (possible that this is due to my code, but still a compiler bug) !

You can see here the error :

Compiling inb4command v0.0.1 (file:///home/nicolas/workspace/inb4command)
src/readline.rs:38:15: 38:16 error: numeric character escape is too short
src/readline.rs:38      write(2, "\x7");
                                    ^
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'index 2 and/or 4 in `\x7` do not lie on character boundary', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/str/mod.rs:1244


Could not compile `inb4command`.

To learn more, run the command again with --verbose.

You can see the failing code here :


use posix::termios::{termios, tcgetattr, tcsetattr, VMIN, VTIME, TCSAFLUSH, OPOST, CS8};
use posix::termios::{BRKINT, ICRNL, INPCK, ISTRIP, IXON, ECHO, ICANON, IEXTEN, ISIG};
use posix::unistd::{isatty, write};
use util::bitinv;

struct TermState {
    rawmode: bool,
    orig_state: termios,
}

impl TermState {
    fn new() -> Option<TermState> {
        if isatty(0) == 1 {
            let mut state = termios::new();
            tcgetattr(0, &mut state);
            Some(TermState {rawmode: false, orig_state: state})
        }
        else {
            None
        }
    }

    fn enable_rawmode(&self) {
        if self.rawmode == false {
            let mut raw = self.orig_state;
            raw.c_iflag &= bitinv(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
            raw.c_oflag &= bitinv(OPOST);
            raw.c_cflag |= (CS8);
            raw.c_lflag &= bitinv(ECHO | ICANON | IEXTEN | ISIG);
            raw.c_cc[VMIN] = 1;
            raw.c_cc[VTIME] = 0;

            tcsetattr(0, TCSAFLUSH, &raw);
        }
    }

    fn beep(&self) {
        write(2, "\x7");
    }
}

Good luck for the resolution, I am at your disposal !

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions