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: borrow-vec associated with bad sty: &ty_err #15663

Closed
benanders opened this issue Jul 14, 2014 · 3 comments
Closed

internal compiler error: borrow-vec associated with bad sty: &ty_err #15663

benanders opened this issue Jul 14, 2014 · 3 comments

Comments

@benanders
Copy link

So I came across this, and the message I received asked me to create a bug report.

Mac OSX 10.9.3, x86_64

Original error:

rustc -L /usr/local/lib/glfw -L lib/glfw-rs/lib -L lib/gl-rs/lib -L lib/cgmath-rs/lib -O --out-dir=target src/main.rs
src/main.rs:79:14: 79:22 error: internal compiler error: borrow-vec associated with bad sty: &ty_err
src/main.rs:79  let size = (vertices.len() * mem::size_of::<GLfloat>()) as GLsizeiptr;
                            ^~~~~~~~
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:112

rustc version is rustc 0.11.0-nightly (b57d272e9908e164a72bd1a688141031705e1208 2014-07-11 01:11:36 +0000)

Code:

#![feature(globs)]

extern crate native;
extern crate glfw;
extern crate cgmath;
extern crate gl;

use glfw::Context;
use gl::types::*;
use std::mem;

mod shader;


#[start]
fn start(argc: int, argv: *const *const u8) -> int {
    native::start(argc, argv, main)
}


fn main() {
    // Init
    let context = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

    // Set window hints to load OpenGL 3.2 on OSX
    context.window_hint(glfw::ContextVersion(3, 2));
    context.window_hint(glfw::OpenglForwardCompat(true));
    context.window_hint(glfw::OpenglProfile(glfw::OpenGlCoreProfile));

    // Create a window
    let (window, events) = context.create_window(1100, 775, "Post Processing Effects",
        glfw::Windowed).expect("Failed to create window!");

    window.set_key_polling(true);
    window.set_size_polling(true);
    window.make_current();

    gl::load_with(|s| context.get_proc_address(s));


    // Shaders
    let mut shader = shader::Shader::new();
    shader.attach_from_file("vertex_shader.glsl", gl::VERTEX_SHADER);
    shader.attach_from_file("fragment_shader.glsl", gl::FRAGMENT_SHADER);
    shader.link();
    shader.bind_frag_color_name("color");
    shader.set();


    // VAO and VBO
    let vertices = [
        -0.5, -0.5,
        0.5, -0.5,
        0.0, 0.5,
    ];

    let mut vao = 0;
    let mut vbo = 0;

    unsafe {
        // Create a vertex array object
        gl::GenVertexArrays(1, &mut vao);
        gl::BindVertexArray(vao);

        // Create a vertex buffer object
        gl::GenBuffers(1, &mut vbo);
        gl::BindBuffer(gl::ARRAY_BUFFER, vbo);
    }

    // Calculate the size of the vertex data in bytes
    let size = (vertices.len() * mem::size_of::<GLfloat>()) as GLsizeiptr;

    unsafe {
        gl::BufferData(
            gl::ARRAY_BUFFER,
            size,
            mem::transmute(&(vertices[0])),
            gl::STATIC_DRAW
        );
    }


    // Shader attributes
    shader.layout_attribs("position_in");


    // Main loop
    while !window.should_close() {
        context.poll_events();
        for (_, event) in glfw::flush_messages(&events) {
            match event {
                glfw::KeyEvent(glfw::KeyEscape, _, glfw::Press, _) => {
                    window.set_should_close(true);
                },
                _ => {},
            }
        }

        gl::ClearColor(0.0, 0.0, 0.0, 1.0);
        gl::Clear(gl::COLOR_BUFFER_BIT);

        let count = (vertices.len() / 2) as i32;
        gl::DrawArrays(gl::TRIANGLES, 0, count);

        window.swap_buffers();
    }
}

I hope this is enough information, I can provide more if needed.

@ghost
Copy link

ghost commented Jul 14, 2014

Duplicate of #7813.

Well... not quite. But most likely, the fix is the same.

@huonw
Copy link
Member

huonw commented Jul 14, 2014

I hope this is enough information, I can provide more if needed.

(It would be convenient if you could reduce the example as much as possible: preferably enough to remove the dependency on external crates to make it easy to reproduce. :) )

@huonw
Copy link
Member

huonw commented Jul 17, 2014

Closing as a dupe of #15730, since that one has a small testcase.

@huonw huonw closed this as completed Jul 17, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 13, 2023
minor: update libc to 0.2.148

This update is a follow-up for [rust-lang#112374](rust-lang#112374).

The command that does this update:

`cargo update -p libc`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants