BARE_TRAIT_OBJECTS in rustc_lint::builtin - Rust
Description: The `bare_trait_objects` lint suggests using `dyn Trait` for trait objects.

Skip to main content

## BARE_TRAIT_OBJECTS

# Static BARE_TRAIT_OBJECTS

Source

    pub static BARE_TRAIT_OBJECTS: &'static Lint

Expand description

The `bare_trait_objects` lint suggests using `dyn Trait` for trait objects.

#### §Example

ⓘ

    trait Trait { }

    fn takes_trait_object(_: Box<Trait>) {
    }

{{produces}}

#### §Explanation

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`.