Skip to content

hax 0.3.6 crashes on RPITIT #1965

@cfm

Description

@cfm

hax 0.3.6 crashes on the "return-position implementation trait in trait" (RPITIT) pattern available since Rust 1.75, e.g.:

pub trait MyTrait {
    fn succeeds(&self) -> u32;
    fn crashes(&self) -> impl Iterator<Item = u32>;
}

Expected behavior

Successful extraction or a HAXNNNN error about an unsupported Rust feature.

Actual behavior

$ cargo hax into fstar
# ...
Explicit_def_id: an invariant has been broken. Expected last path chunk to exist and be of type TypeNs.

did={ Explicit_def_id.T.is_constructor = false;
  def_id =
  { Types.index = (0, 0, None); is_local = true; kind = Types.AssocTy;
    krate = "bug_anonassocty";
    parent =
    (Some { Types.contents =
            { Types.id = 0;
              value =
              { Types.index = (0, 0, None); is_local = true;
                kind = Types.Trait; krate = "bug_anonassocty";
                parent =
                (Some { Types.contents =
                        { Types.id = 0;
                          value =
                          { Types.index = (0, 0, None); is_local = true;
                            kind = Types.Mod; krate = "bug_anonassocty";
                            parent = None; path = [] }
                          }
                        });
                path =
                [{ Types.data = (Types.TypeNs "MyTrait"); disambiguator = 0 }
                  ]
                }
              }
            });
    path =
    [{ Types.data = (Types.TypeNs "MyTrait"); disambiguator = 0 };
      { Types.data = (Types.AnonAssocTy "crashes"); disambiguator = 0 }]
    }
  }
# ...

Seemingly from:

let type_ns (did : Explicit_def_id.t) =
match List.last (Explicit_def_id.to_def_id did).path with
(* This can be `None` for the anonymous types generated for `-> impl Trait` in traits. *)
| Some { data = TypeNs data; disambiguator } ->
DisambiguatedString.{ data; disambiguator }
| _ -> broken_invariant "last path chunk to exist and be of type TypeNs" did

Metadata

Metadata

Assignees

Labels

engineIssue in the engine

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions