Skip to content

&dyn Trait over a str aborts codegen: function-value adapter has no FnAbi descriptor #1818

Closed

Description

@ehartford

Repro

trait Speak:
    fn say(self: &Self) -> str
impl Speak for str:
    fn say(self: &Self) -> str: self ++ "!"
fn show_dyn(d: &dyn Speak): print(d.say())
fn main:
    let a = "abc"
    show_dyn(&a)

with run (fix-lang stage1, and the #1810 branch's):

BUG: function-value adapter has no FnAbi descriptor [src/Codegen.w:1876 Codegen.gen_fn_to_fat_ptr_thunk]

The same with &dyn Display over a str (impl Display for str in std.traits).

Expected

abc! — a str place coerced to &dyn Speak (§11 trait objects) builds the fat {data, vtable} with the str header as data and dispatches say. A codegen phase bug on a well-typed program is the compiler's (No Silent Fallbacks: it is at least loud).

Found while building the #1810 (&str view value) matrix: the &dyn column has no baseline to compare against.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcrash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions