Files
rust/tests/ui/eii/duplicate/multiple_impls.rs
bjorn3 1a3d919258 Deny multiple EII impls on a single item
This allows implementing EIIs that don't have a default impl without the
involvement of symbol aliases by simply changing the mangled symbol name
of the implementation, which would make them trivially compatible with
all backends and targets. This change will be left to a followup PR.
2026-08-03 11:04:23 +02:00

38 lines
671 B
Rust

//@ ignore-backends: gcc
// FIXME(#125418): linking on Windows GNU targets is not yet supported.
//@ ignore-windows-gnu
// Tests that one item can't implement two EIIs
#![feature(extern_item_impls)]
#[eii]
fn a(x: u64);
//~^ ERROR `#[a]` function required, but not found
#[eii]
fn b(x: u64);
#[a]
#[b]
//~^ ERROR a single item cannot implement multiple EIIs
fn implementation(x: u64) {
println!("{x:?}")
}
#[eii(c)]
//~^ ERROR `#[c]` static required, but not found
static C: u64;
#[eii(d)]
static D: u64;
#[c]
#[d]
//~^ ERROR a single item cannot implement multiple EIIs
static IMPL: u64 = 5;
fn main() {
a(42);
b(42);
println!("{C} {D} {IMPL}")
}