Skip to content

Out of bound idx for struct #17

Description

@zjp-CN

We got idx=2 for core::fmt::Arguments, but the struct only has two fields, and thus out of bounds:

                    if let Some(idx) = idx.as_field_idx()
                        && adt.def.kind().is_struct()
                    {
                        if let Some(field) = self.fields.get_mut(idx) {
                            field.read = v_fn.iter().map(|f| f.fn_def).collect();
                        } else {
                            panic!("adt={adt:#?} self={self:#?}")
                        }
                    }
thread 'rustc' (4100844) panicked at src/info_adt.rs:94:29:
adt=Adt {
    def: AdtDef(
        DefId {
            id: 22841,
            name: "fmt::Arguments",
        },
    ),
    args: GenericArgs(
        [
            Lifetime(
                Region {
                    kind: ReErased,
                },
            ),
        ],
    ),
    variant_fields: [
        VaraintField {
            idx: VariantIdx(None)-FieldIdx(Some(0)),
            name: "template",
        },
        VaraintField {
            idx: VariantIdx(None)-FieldIdx(Some(1)),
            name: "args",
        },
    ],
}

For simplicity, we choose to mute the case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions