Skip to content

Implement arbitrary-self dynamic method receivers #1038

Closed
rust-lang/rust
#95071
@RalfJung

Description

@RalfJung

The tests added in rust-lang/rust#54383 fail in Miri:

  15: core::result::unwrap_failed
             at src/libcore/result.rs:1165
  16: core::result::Result<T,E>::unwrap
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/libcore/result.rs:933
  17: rustc_mir::interpret::place::<impl rustc_mir::interpret::operand::OpTy<Tag>>::assert_mem_place
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/place.rs:232
  18: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/terminator.rs:437
  19: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_terminator
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/terminator.rs:94
  20: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::terminator
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/step.rs:293
  21: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::step
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/step.rs:69
  22: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
             at /rustc/e4931eaaa3d95189b30e90d3af9f0db17c41bbb0/src/librustc_mir/interpret/step.rs:40
  23: miri::eval::eval_main::{{closure}}
             at src/eval.rs:190

This is ICEing in this code:

https://github.com/rust-lang/rust/blob/7a76fe76f756895b8cda1e10398f2268656a2e0f/src/librustc_mir/interpret/terminator.rs#L430-L438

Clearly, that code assumes that only things that builtin_deref supports are receivers, and everything else is unsized -- hence the assert_mem_place, which fails.

So, how does one implement arbitrary-self dynamic receivers? What actually happens at run-time here? I don't know.^^

Cc @eddyb @mikeyhew

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterC-bugCategory: This is a bug.I-ICEImpact: makes Miri crash with some ICES-blockedStatus: blocked on something happening somewhere else

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions