Skip to content

Move coerce_container_to_any to suspicious#16689

Open
Ralith wants to merge 1 commit intorust-lang:masterfrom
Ralith:push-vnxvslloknyk
Open

Move coerce_container_to_any to suspicious#16689
Ralith wants to merge 1 commit intorust-lang:masterfrom
Ralith:push-vnxvslloknyk

Conversation

@Ralith
Copy link
Contributor

@Ralith Ralith commented Mar 8, 2026

changelog: [coerce_container_to_any]: move from nursery to suspicious

Motivated by organic demand on bsky.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 8, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 8, 2026

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@samueltardieu
Copy link
Member

I would prefer to see more tests before this lint becomes warning-by-default. In particular, tests where part of the expression comes from macros, or embedded inside macro, etc., to make sure that the suggested fix can always be applied.

For example, the following code will trigger the lint while it should probably not:

    macro_rules! mac {
        ($n:ident, $e:expr) => { let $n: &dyn Any = $e; };
    }
    let x: Box<dyn Any> = Box::new(());
    mac!(ref_x, &x);

@Ralith
Copy link
Contributor Author

Ralith commented Mar 8, 2026

Shouldn't it? If I saw such code in the wild I'd strongly expect the intended syntax to be mac!(ref_x, &*x), exactly per the lint.

@samueltardieu
Copy link
Member

If the macro is external, having a message such as "error: coercing &std::boxed::Box<dyn std::any::Any> to &dyn Any" is a bit strange, as the macro is supposedly "opaque" (for example if it's a proc-macro).

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants