Skip to content

type_id_on_box for supertraits of Any #11349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ved-s opened this issue Aug 18, 2023 · 0 comments · Fixed by #11350
Closed

type_id_on_box for supertraits of Any #11349

Ved-s opened this issue Aug 18, 2023 · 0 comments · Fixed by #11350
Labels
A-lint Area: New lints

Comments

@Ved-s
Copy link

Ved-s commented Aug 18, 2023

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

@Ved-s Ved-s added the A-lint Area: New lints label Aug 18, 2023
@bors bors closed this as completed in 3787a0c Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant