Static rustc_lint_defs::builtin::BARE_TRAIT_OBJECTS

source ·
pub static BARE_TRAIT_OBJECTS: &Lint
Expand description

The bare_trait_objects lint suggests using dyn Trait for trait objects.


trait Trait { }

fn takes_trait_object(_: Box<Trait>) {



Without the dyn indicator, it can be ambiguous or confusing when reading code as to whether or not you are looking at a trait object. The dyn keyword makes it explicit, and adds a symmetry to contrast with impl Trait.