Skip to content

internal compiler error: type_of with ty_param #10954

Closed
@bstrie

Description

@bstrie

There was an old closed bug with this title, I've opened a new issue rather than reopening that one.

Compiling this file exhibits the bug (received from IRC, not minimized yet):

#[allow(dead_code, unused_variable)];

use std::libc::{c_void, c_char};
use std::c_str::{CString};
use std::cast::{transmute};
use std::ptr::{null};

struct _DBusCon;
struct _DBusMsg;

#[repr(C)]
enum DBusHandlerResult {
    DBusHandlerResultHandled,
    DBusHandlerResultNotYetHandled,
    DBusHandlerResultNeedMemory,
}

struct _DBusObjectPathVTable<T> {
    unreg_func: extern "C" fn(con: *_DBusCon, data: *_data<T>),
    msg_func: extern "C" fn(con: *_DBusCon, mes: *_DBusMsg, data: *_data<T>) -> DBusHandlerResult,
    dbus_internal_pad1: *c_void,
    dbus_internal_pad2: *c_void,
    dbus_internal_pad3: *c_void,
    dbus_internal_pad4: *c_void,
    dbus_internal_pad5: *c_void,
}

struct DBusCon {
    priv raw: *_DBusCon,
}

impl DBusCon {
    fn reg_obj_path<T>(&self, path: &str, msg_func: |DBusMsg,&T| -> DBusHandlerResult, unreg_func: |&T|, data: ~T) {
        unsafe {
            let vtable: ~_DBusObjectPathVTable<T> = ~_DBusObjectPathVTable {
                unreg_func: _unreg_func,
                msg_func: _msg_func,
                dbus_internal_pad1: null(),
                dbus_internal_pad2: null(),
                dbus_internal_pad3: null(),
                dbus_internal_pad4: null(),
                dbus_internal_pad5: null(),
            };
            let _path = path.to_c_str().unwrap();
            let _vtable: *_DBusObjectPathVTable<T> = transmute(vtable);
            let _data = ~_data {
                msg_func: msg_func,
                unreg_func: unreg_func,
                path: _path,
                data: data,
                vtable: _vtable,
            };
            let __data: *_data<T> = transmute(_data);
        }
    }
}

extern "C" fn _msg_func<T>(con: *_DBusCon, _msg: *_DBusMsg, data: *_data<T>) -> DBusHandlerResult {
    unsafe {
        let msg = DBusMsg::new(_msg);
        ((*data).msg_func)(msg, (*data).data)
    }
}
extern "C" fn _unreg_func<T>(con: *_DBusCon, data: *_data<T>) {
    unsafe {
        ((*data).unreg_func)((*data).data);
        CString::new((*data).path, true);
        let d: ~_data<T>  = transmute(data);
        let v: ~_DBusObjectPathVTable<T> = transmute(d.vtable);
    }
}

struct _data<'a, T> {
    msg_func: 'a |DBusMsg,&T| -> DBusHandlerResult,
    unreg_func: 'a |&'a T|,
    path: *c_char,
    data: ~T,
    vtable: *_DBusObjectPathVTable<T>,
}

struct DBusMsg {
    priv raw: *_DBusMsg,
}

impl DBusMsg {
    fn new(raw: *_DBusMsg) -> DBusMsg {
        DBusMsg { raw: raw }
    }
}

fn main() {}

Compiler output:

error: internal compiler error: type_of with ty_param
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
task 'rustc' failed at 'explicit failure', /root/catacombs/scrap/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /root/catacombs/scrap/rust/src/librustc/lib.rs:393

Metadata

Metadata

Assignees

No one assigned

    Labels

    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