Skip to content

ICE when matching on DST structs. #23261

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

Closed
hugoduncan opened this issue Mar 10, 2015 · 3 comments · Fixed by #25060
Closed

ICE when matching on DST structs. #23261

hugoduncan opened this issue Mar 10, 2015 · 3 comments · Fixed by #25060
Labels
A-codegen Area: Code generation A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@hugoduncan
Copy link

The following code causes

Assertion failed: (getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/llvm/lib/IR/Instructions.cpp, line 1083.
use std::collections::HashMap;
use std::path::{Path, PathBuf};

#[derive(Debug)]
pub struct FileMeta;

struct S {
    h2 : HashMap<PathBuf, FileMeta>,
}

impl S {
    fn new() -> S {
        S {
            h2: HashMap::new(),
        }
    }

    fn f(&self, path: &Path) -> FileMeta {
        let m = FileMeta;
        match self.h2.get(path) {
            Some(meta) => m,
            None => m
        }
    }
}

Using rustc 1.0.0-nightly (12b846ab8 2015-03-09) (built 2015-03-09).

@hugoduncan hugoduncan changed the title Compiler assertion Compiler assertion "Ptr must be a pointer to Val type!" Mar 10, 2015
@hugoduncan
Copy link
Author

Changing the function, f above to the following prevents the assertion from triggering.

    fn f(&self, path: &Path) -> FileMeta {
        let m = FileMeta;
        let p = PathBuf::new(path);
        match self.h2.get(&p) {
            Some(meta) => m,
            None => m
        }
    }

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 10, 2015
@blaenk
Copy link
Contributor

blaenk commented Mar 19, 2015

Yeah this one is ridiculous. It's been going on for a loooong while. Having to create a pathbuf kind of defeats the purpose of path. I think this should be higher priority.

btw you can make that self.h2.get(&path.to_path_buf()). Still dumb though.

@luqmana
Copy link
Member

luqmana commented Apr 25, 2015

Problem seems to be with matching on DST structs. Here's a reduced test case:

pub struct MyPath {
    inner: [u8]
}

pub fn bar(t: &MyPath) {
    match *t {
        MyPath { ref inner } => {}
    }
}

fn main() {}

Playpen

@luqmana luqmana added A-DSTs Area: Dynamically-sized types (DSTs) A-codegen Area: Code generation labels Apr 25, 2015
@luqmana luqmana changed the title Compiler assertion "Ptr must be a pointer to Val type!" ICE when matching on DST structs. May 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants