Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_ty/src/tests/method_resolution.rs')
| -rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 9700b388aa..56b8db1319 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -925,7 +925,6 @@ fn test() { S2.into(); } #[test] fn method_resolution_overloaded_method() { - cov_mark::check!(impl_self_type_match_without_receiver); check_types( r#" struct Wrapper<T>(T); @@ -955,6 +954,33 @@ fn main() { } #[test] +fn method_resolution_overloaded_const() { + cov_mark::check!(const_candidate_self_type_mismatch); + check_types( + r#" +struct Wrapper<T>(T); +struct Foo<T>(T); +struct Bar<T>(T); + +impl<T> Wrapper<Foo<T>> { + pub const VALUE: Foo<T>; +} + +impl<T> Wrapper<Bar<T>> { + pub const VALUE: Bar<T>; +} + +fn main() { + let a = Wrapper::<Foo<f32>>::VALUE; + let b = Wrapper::<Bar<f32>>::VALUE; + (a, b); + //^^^^^^ (Foo<f32>, Bar<f32>) +} +"#, + ); +} + +#[test] fn method_resolution_encountering_fn_type() { check_types( r#" @@ -1258,6 +1284,37 @@ mod b { } #[test] +fn trait_vs_private_inherent_const() { + cov_mark::check!(const_candidate_not_visible); + check( + r#" +mod a { + pub struct Foo; + impl Foo { + const VALUE: u32 = 2; + } + pub trait Trait { + const VALUE: usize; + } + impl Trait for Foo { + const VALUE: usize = 3; + } + + fn foo() { + let x = Foo::VALUE; + // ^^^^^^^^^^ type: u32 + } +} +use a::Trait; +fn foo() { + let x = a::Foo::VALUE; + // ^^^^^^^^^^^^^ type: usize +} +"#, + ) +} + +#[test] fn trait_impl_in_unnamed_const() { check_types( r#" |