Skip to content

ICE when using an object-safe trait with methods marked as extern #51907

Closed
@tuxmark5

Description

@tuxmark5

This snippet causes rustc to ICE:

trait Foo {
    extern fn method(&self);
}

struct Bar;
impl Foo for Bar { 
    extern fn method(&self) { }
}

fn main() {
    let foo: Box<dyn Foo> = Box::new(Bar);
    foo.method();
}

rustc version: rustc 1.28.0-nightly (2a1c4ee 2018-06-25)

Error message:

error: internal compiler error: librustc_codegen_llvm/abi.rs:304: FnType::new_vtable: non-pair self ArgType { layout: TyLayout { ty: &Foo, details: LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [Size { raw: 0 }, Size { raw: 8 }], memory_index: [0, 1] }, abi: ScalarPair(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }, Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }), align: Align { abi_pow2: 3, pref_pow2: 3 }, size: Size { raw: 16 } } }, pad: None, mode: Direct(ArgAttributes { regular: (empty), pointee_size: Size { raw: 0 }, pointee_align: None }) }

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions