Skip to content

rust1: internal compiler error: in TyVar, at rust/typecheck/rust-tyty.cc:238 #1130

@bjorn3

Description

@bjorn3

I tried this code:

pub trait Hasher {
    fn finish(&self) -> u64;
    fn write(&mut self, bytes: &[u8]);
    fn write_u8(&mut self, i: u8) {
        self.write(&[i])
    }
    fn write_u16(&mut self, i: u16) {
        self.write(&i.to_ne_bytes())
    }
    fn write_u32(&mut self, i: u32) {
        self.write(&i.to_ne_bytes())
    }
    fn write_u64(&mut self, i: u64) {
        self.write(&i.to_ne_bytes())
    }
    fn write_u128(&mut self, i: u128) {
        self.write(&i.to_ne_bytes())
    }
    fn write_usize(&mut self, i: usize) {
        self.write(&i.to_ne_bytes())
    }
    fn write_i8(&mut self, i: i8) {
        self.write_u8(i as u8)
    }
    fn write_i16(&mut self, i: i16) {
        self.write_u16(i as u16)
    }
    fn write_i32(&mut self, i: i32) {
        self.write_u32(i as u32)
    }
    fn write_i64(&mut self, i: i64) {
        self.write_u64(i as u64)
    }
    fn write_i128(&mut self, i: i128) {
        self.write_u128(i as u128)
    }
    fn write_isize(&mut self, i: isize) {
        self.write_usize(i as usize)
    }
}

pub struct SipHasher;

impl Hasher for SipHasher {
    #[inline]
    fn write(&mut self, msg: &[u8]) {
    
    }

    #[inline]
    fn finish(&self) -> u64 {
        0
    }
}

I expected to see this happen: Compiles.

Instead, this happened:

<source>:5:21: error: expected [[u8]] got [[u8:CAPACITY]]
    3 |     fn write(&mut self, bytes: &[u8]);
      |                                 ~
    4 |     fn write_u8(&mut self, i: u8) {
    5 |         self.write(&[i])
      |                     ^
<source>:5:20: error: expected [& [u8]] got [& [u8:CAPACITY]]
    3 |     fn write(&mut self, bytes: &[u8]);
      |                                ~
    4 |     fn write_u8(&mut self, i: u8) {
    5 |         self.write(&[i])
      |                    ^
<source>:5:20: error: Type Resolution failure on parameter
<source>:5:9: error: failed to lookup type to MethodCallExpr
    5 |         self.write(&[i])
      |         ^
<source>:5:9: error: failed to type resolve expression
<source>:4:35: error: expected [()] got [<tyty::error>]
    4 |     fn write_u8(&mut self, i: u8) {
      |                            ~      ^
<source>:8:23: error: failed to resolve method for 'to_ne_bytes'
    8 |         self.write(&i.to_ne_bytes())
      |                       ^
<source>:8:21: error: failed to type resolve expression
    8 |         self.write(&i.to_ne_bytes())
      |                     ^
rust1: internal compiler error: in TyVar, at rust/typecheck/rust-tyty.cc:238
0x204e319 internal_error(char const*, ...)
	???:0
0x8027ef fancy_abort(char const*, int, char const*)
	???:0
0x9d0b30 Rust::TyTy::TyVar::TyVar(unsigned int)
	???:0
0x9c4ff2 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BorrowExpr&)
	???:0
0x9c137c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*, bool)
	???:0
0x9d5a10 Rust::TyTy::TypeCheckMethodCallExpr::visit(Rust::TyTy::FnType&)
	???:0
0x9cd012 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::MethodCallExpr&)
	???:0
0x9c137c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*, bool)
	???:0
0x9b7b6a Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
	???:0
0x9c137c Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*, bool)
	???:0
0x9be73b Rust::Resolver::TraitResolver::go(Rust::HIR::TypePath&)
	???:0
0x9cd567 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ImplBlock&)
	???:0
0x9b8d92 Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	???:0
0x8c88a8 Rust::Session::parse_file(char const*)
	???:0
0x8c9548 Rust::Session::parse_files(int, char const**)
	???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Meta

  • What version of Rust GCC were you using, git sha if possible.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions