E3053
E3053 — An impl ofSendorSyncwith nounsafe, as inimpl Send for Handle {}. The compiler derives both from the fields, and a raw pointer is neither. An impl claims one for a type that holds a raw pointer, and the compiler cannot check the claim. Writeunsafe impl Send for Handle {}.
What the compiler reports
Error[E3053]: `impl Send for Handle` must be `unsafe impl`: the compiler derives `Send` from the fields, and cannot check this claim
Error[E3053]: `impl Sync for Handle` must be `unsafe impl`
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
A tour of VxThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E3052Arithmetic on fp8 or fp4 values (
f8e4m3, f8e5m2 or f4e2m1) with no written result type, as in print(a * b). The compiler computes in f32 and rounds once to the written type, so the program must write it: let c : f32 = a * b;. Also += and the other compound operators on these values, and any operator on tensors of them.
E3054unsafe 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.