charon icon indicating copy to clipboard operation
charon copied to clipboard

Bug: Panicked when getting FullDef from Hax for impl traits with associated types

Open ssyram opened this issue 5 months ago • 4 comments

This problem should be somehow related to #790 .

Code snippet to reproduce the bug: I simplified the production, and simply have:

trait Internal {
    type IntAssoc;
    fn internal_method(&self) -> Self::IntAssoc;
}

impl Internal for i32 {
    type IntAssoc = i32;
    fn internal_method(&self) -> Self::IntAssoc {
        *self + 1
    }
}

fn main() { }

Then, I run by:

RUST_LOG=trace RUST_BACKTRACE=full ./bin/charon rustc --print-llbc -- --crate-type=rlib charon/tests/ui/vtables.rs

Then, there is a panic reported in Rustc:

thread 'rustc' panicked at compiler/rustc_middle/src/ty/generic_args.rs:54:14:
index out of bounds: the len is 0 but the index is 0

After tracing, I found the problem does not seem to be in Charon, but is in Hax, when we try to get the FullDef of trait impl.

ssyram avatar Jul 30 '25 08:07 ssyram

I cannot reproduce this bug

Nadrieril avatar Jul 30 '25 08:07 Nadrieril

(After private discussion) Closing for now, please reopen if you manage to find a reproducer that triggers the error with make test.

Nadrieril avatar Jul 30 '25 09:07 Nadrieril

The issue is still there?

ssyram avatar Jul 31 '25 07:07 ssyram

Yep, managed to reproduce in the end: it's a panic that only occurs when tracing is on, it's in the printing routine of a rustc_middle::TraitRefwith no Self.

Nadrieril avatar Jul 31 '25 08:07 Nadrieril