Skip to content

type_id_on_box for supertraits of Any #11349

@Ved-s

Description

@Ved-s

What it does

Detect .type_id() calls on Box<dyn Trait> when trait Trait: Any {...}

Advantage

Less annoying-to-find mistakes on Any traits

Drawbacks

No response

Example

use std::any::Any;

trait Test: Any {}

impl Test for i32 {}

fn main() {
    let b: Box<dyn Test> = Box::new(0);
    let ty = b.type_id();
    dbg!(ty);
}

playground link

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions