Saltar al contenido
TE824 · Tipos · error

Ruta calificada de trait inválida

Las rutas calificadas de trait deben ser `core::<módulo>::<Trait>` o `std::<módulo>::<Trait>`, nombrando un `pub trait` realmente declarado allí — tanto en un bound genérico como en una cabecera de `impl`.

Why this fires

A qualified trait path doesn't resolve to a real trait. Qualified trait paths must be core::<module>::<Trait> or std::<module>::<Trait>, naming a pub trait actually declared in that module. This applies both in a generic bound and in an impl header.

fn f<T: core::cmp::Bogus>(a: T) -> T { a }
//      ^^^^^^^^^^^^^^^^^ error[TE824]: invalid qualified trait path `core::cmp::Bogus`

The same check covers the trait position of an impl:

impl core::cmp::Bogus for Money { }
//   ^^^^^^^^^^^^^^^^^ error[TE824]: invalid qualified trait path `core::cmp::Bogus`

impl mymod::Foo for Money { }
//   ^^^^^^^^^^ error[TE824]: invalid qualified trait path `mymod::Foo`

Fix it

Use the correct module and trait name (e.g. core::cmp::Ord, core::ops::Add, core::fmt::Display, core::hash::Hash), or just the bare name since the std traits are in scope via the prelude:

fn f<T: core::cmp::Ord>(a: T) -> T { a }   // or simply  <T: Ord>

Notes

  • A bare unknown trait name (<T: Foo>) is TE822, not TE824.
  • Qualified paths to user-module traits are not supported yet — use the bare name (in scope via use) for those.

See also

Véase también

Buscar en Zolo

9 resultados

en