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

LLVM assert with explicit self and objects #4152

Closed
brson opened this issue Dec 10, 2012 · 2 comments
Closed

LLVM assert with explicit self and objects #4152

brson opened this issue Dec 10, 2012 · 2 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@brson
Copy link
Contributor

brson commented Dec 10, 2012

pub trait Reader {
    // FIXME (#2004): Seekable really should be orthogonal.

    /// Read up to len bytes (or EOF) and put them into bytes (which
    /// must be at least len bytes long). Return number of bytes read.
    // FIXME (#2982): This should probably return an error.
    fn read(&self, bytes: &[mut u8], len: uint) -> uint;
}

pub trait ReaderUtil {

    /// Read len bytes into a new vec.
    fn read_bytes(&self, len: uint) -> ~[u8];
}

impl<T: Reader> T : ReaderUtil {

    fn read_bytes(&self, len: uint) -> ~[u8] {
        let mut bytes = vec::with_capacity(len);
        unsafe { vec::raw::set_len(&mut bytes, len); }

        let count = (&*self).read(bytes, len);

        unsafe { vec::raw::set_len(&mut bytes, count); }
        move bytes
    }

}

impl int: Reader {
    fn read(&self, bytes: &[mut u8], len: uint) -> uint {
        0
    }
}

fn main() {
    let x = @0;
    let x = x as @Reader;
    x.read_bytes(0);
}
rustc: /home/brian/dev/rust/src/llvm/include/llvm/Instructions.h:705: llvm::Type* llvm::checkGEPType(llvm::Type*): Assertion `Ty && "Invalid GetElementPtrInst indices for type!"' failed.

@kvark
Copy link
Contributor

kvark commented Dec 13, 2012

I'd really like to know how to work around this on Rust-0.4. A shorter code sample:

trait Element {
    fn draw( &self );
}
struct Frame {
    element : @Element,
}
impl Frame {
    fn draw_all() {
        self.element.draw();
    }
}
fn main() {}

@graydon
Copy link
Contributor

graydon commented Dec 18, 2012

(works in 0.5)

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
…#4166)

Previously the indetation of a line was compared with the configured
number of spaces per tab, which could cause lines that were formatted
with hard tabs not to be recognized as indented ("\t".len() < "    ".len()).

Closes rust-lang#4152
RalfJung added a commit to RalfJung/rust that referenced this issue Jan 26, 2025
many-seeds: do not use more than 8 threads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants