Skip to content

type_id_on_box for supertraits of Any #11349

Closed
@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

Activity

added a commit that references this issue on Mar 30, 2024

Auto merge of #11350 - y21:issue11349, r=xFrednet

3787a0c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Ved-s

      Issue actions

        `type_id_on_box` for supertraits of Any · Issue #11349 · rust-lang/rust-clippy