summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/next-solver/dyn-any-dont-prefer-impl.rs
blob: bb1c24a001fb41150b685682fa47a176bfcf7786 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// compile-flags: -Znext-solver
// check-pass

// Test that selection prefers the builtin trait object impl for `Any`
// instead of the user defined impl. Both impls apply to the trait
// object.

use std::any::Any;

fn needs_usize(_: &usize) {}

fn main() {
    let x: &dyn Any = &1usize;
    if let Some(x) = x.downcast_ref::<usize>() {
        needs_usize(x);
    }
}