E3049
E3049 — Two impls of the same trait for the same type: impl Describe for Point written twice, in one module or in two. A type has one impl of a trait, so a call could not choose between them. Remove one.
What the compiler reports
Error[E3049]: `impl Describe for Point` is written in '{{.*}}describe_{{left|right}}' and in '{{.*}}describe_{{left|right}}'
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
//
//
// Two imported modules each implement `Describe` for `Point`. The error names both modules,
// and comes even though the program calls neither impl.
//
import tests::modules::describe_shape;
import tests::modules::describe_left;
import tests::modules::describe_right;
fn main() -> i32 {
let p = make();
return p.x;
}
From tests/frontend/fail/two_impls_of_a_trait_for_one_type_in_two_modules.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.
E3048An
if with no else whose value is used, as in let u = if c { .. };. When the condition is false there is no branch to give a value. Add an else, or use the if as a statement.
E3050A pattern inside a variant's payload that is not a name or _, such as the 3 in Val(3) or the Inner::A(v) in Wrap(Inner::A(v)). The compiler does not test such a pattern when it chooses an arm, so the arm would be taken for any payload. Bind the payload to a name and test it in the arm, with an if or another match.