E3054

E3054 — unsafe impl of a trait other than Send or Sync, or of no trait at all. Only those two traits make a claim that the compiler cannot check. Remove unsafe.

What the compiler reports

Error[E3054]: `unsafe impl Describe for Handle`: only `Send` and `Sync` take `unsafe impl`. Remove `unsafe`
Error[E3054]: `unsafe impl Handle`: an impl with no trait cannot be `unsafe`
{{^}}Semantic check failed on {{.*}}: 4 error(s) emitted

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// An impl of `Send` or `Sync` must be `unsafe impl` (E3053). Any other impl must not be (E3054).
//

import core::marker;

trait Describe {}

struct Handle {
  p : *mut i32,
}

impl Send for Handle {}

impl Sync for Handle {}

unsafe impl Describe for Handle {}

unsafe impl Handle {
  fn id(self : &Handle) -> i32 {
    return 1;
  }
}

fn main() -> i32 {
  return 0;
}

// The errors above are all the errors.

From tests/frontend/fail/unsafe_impl_only_for_send_and_sync.vx, which asserts this diagnostic on every commit.

Related