diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 70 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 12 |
2 files changed, 66 insertions, 16 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 25716fe8c..c60e72abf 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2838,6 +2838,64 @@ fn main() { | |||
2838 | ); | 2838 | ); |
2839 | } | 2839 | } |
2840 | 2840 | ||
2841 | #[test] | ||
2842 | fn infer_path_quantified_macros_expanded() { | ||
2843 | assert_snapshot!( | ||
2844 | infer(r#" | ||
2845 | #[macro_export] | ||
2846 | macro_rules! foo { | ||
2847 | () => { 42i32 } | ||
2848 | } | ||
2849 | |||
2850 | mod m { | ||
2851 | pub use super::foo as bar; | ||
2852 | } | ||
2853 | |||
2854 | fn main() { | ||
2855 | let x = crate::foo!(); | ||
2856 | let y = m::bar!(); | ||
2857 | } | ||
2858 | "#), | ||
2859 | @r###" | ||
2860 | ![0; 5) '42i32': i32 | ||
2861 | ![0; 5) '42i32': i32 | ||
2862 | [111; 164) '{ ...!(); }': () | ||
2863 | [121; 122) 'x': i32 | ||
2864 | [148; 149) 'y': i32 | ||
2865 | "### | ||
2866 | ); | ||
2867 | } | ||
2868 | |||
2869 | #[test] | ||
2870 | fn infer_type_value_macro_having_same_name() { | ||
2871 | assert_snapshot!( | ||
2872 | infer(r#" | ||
2873 | #[macro_export] | ||
2874 | macro_rules! foo { | ||
2875 | () => { | ||
2876 | mod foo { | ||
2877 | pub use super::foo; | ||
2878 | } | ||
2879 | }; | ||
2880 | ($x:tt) => { | ||
2881 | $x | ||
2882 | }; | ||
2883 | } | ||
2884 | |||
2885 | foo!(); | ||
2886 | |||
2887 | fn foo() { | ||
2888 | let foo = foo::foo!(42i32); | ||
2889 | } | ||
2890 | "#), | ||
2891 | @r###" | ||
2892 | ![0; 5) '42i32': i32 | ||
2893 | [171; 206) '{ ...32); }': () | ||
2894 | [181; 184) 'foo': i32 | ||
2895 | "### | ||
2896 | ); | ||
2897 | } | ||
2898 | |||
2841 | #[ignore] | 2899 | #[ignore] |
2842 | #[test] | 2900 | #[test] |
2843 | fn method_resolution_trait_before_autoref() { | 2901 | fn method_resolution_trait_before_autoref() { |
@@ -3007,7 +3065,7 @@ impl<T, U> Into<U> for T where U: From<T> {} | |||
3007 | fn test() { S2.into()<|>; } | 3065 | fn test() { S2.into()<|>; } |
3008 | "#, | 3066 | "#, |
3009 | ); | 3067 | ); |
3010 | assert_eq!(t, "S1"); | 3068 | assert_eq!(t, "{unknown}"); |
3011 | } | 3069 | } |
3012 | 3070 | ||
3013 | #[test] | 3071 | #[test] |
@@ -3024,7 +3082,7 @@ impl<T, U: From<T>> Into<U> for T {} | |||
3024 | fn test() { S2.into()<|>; } | 3082 | fn test() { S2.into()<|>; } |
3025 | "#, | 3083 | "#, |
3026 | ); | 3084 | ); |
3027 | assert_eq!(t, "S1"); | 3085 | assert_eq!(t, "{unknown}"); |
3028 | } | 3086 | } |
3029 | 3087 | ||
3030 | #[test] | 3088 | #[test] |
@@ -3066,7 +3124,7 @@ impl<B, C> Trait for S<B, C> where C: FnX, B: SendX {} | |||
3066 | fn test() { (S {}).method()<|>; } | 3124 | fn test() { (S {}).method()<|>; } |
3067 | "#, | 3125 | "#, |
3068 | ); | 3126 | ); |
3069 | assert_eq!(t, "{unknown}"); | 3127 | assert_eq!(t, "()"); |
3070 | } | 3128 | } |
3071 | 3129 | ||
3072 | #[test] | 3130 | #[test] |
@@ -3546,11 +3604,11 @@ fn test(x: Trait, y: &Trait) -> u64 { | |||
3546 | [129; 132) 'bar': fn bar() -> {unknown} | 3604 | [129; 132) 'bar': fn bar() -> {unknown} |
3547 | [129; 134) 'bar()': {unknown} | 3605 | [129; 134) 'bar()': {unknown} |
3548 | [140; 141) 'x': {unknown} | 3606 | [140; 141) 'x': {unknown} |
3549 | [140; 147) 'x.foo()': {unknown} | 3607 | [140; 147) 'x.foo()': u64 |
3550 | [153; 154) 'y': &{unknown} | 3608 | [153; 154) 'y': &{unknown} |
3551 | [153; 160) 'y.foo()': {unknown} | 3609 | [153; 160) 'y.foo()': u64 |
3552 | [166; 167) 'z': {unknown} | 3610 | [166; 167) 'z': {unknown} |
3553 | [166; 173) 'z.foo()': {unknown} | 3611 | [166; 173) 'z.foo()': u64 |
3554 | "### | 3612 | "### |
3555 | ); | 3613 | ); |
3556 | } | 3614 | } |
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 8a127efa1..0367c6560 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -356,14 +356,6 @@ fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T> { | |||
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | fn is_non_enumerable_trait(db: &impl HirDatabase, trait_: Trait) -> bool { | ||
360 | let name = trait_.name(db).unwrap_or_else(crate::Name::missing).to_string(); | ||
361 | match &*name { | ||
362 | "Sized" => true, | ||
363 | _ => false, | ||
364 | } | ||
365 | } | ||
366 | |||
367 | fn convert_where_clauses( | 359 | fn convert_where_clauses( |
368 | db: &impl HirDatabase, | 360 | db: &impl HirDatabase, |
369 | def: GenericDef, | 361 | def: GenericDef, |
@@ -486,7 +478,7 @@ pub(crate) fn trait_datum_query( | |||
486 | associated_ty_ids: Vec::new(), | 478 | associated_ty_ids: Vec::new(), |
487 | where_clauses: Vec::new(), | 479 | where_clauses: Vec::new(), |
488 | flags: chalk_rust_ir::TraitFlags { | 480 | flags: chalk_rust_ir::TraitFlags { |
489 | non_enumerable: false, | 481 | non_enumerable: true, |
490 | auto: false, | 482 | auto: false, |
491 | marker: false, | 483 | marker: false, |
492 | upstream: true, | 484 | upstream: true, |
@@ -503,7 +495,7 @@ pub(crate) fn trait_datum_query( | |||
503 | let flags = chalk_rust_ir::TraitFlags { | 495 | let flags = chalk_rust_ir::TraitFlags { |
504 | auto: trait_.is_auto(db), | 496 | auto: trait_.is_auto(db), |
505 | upstream: trait_.module(db).krate(db) != Some(krate), | 497 | upstream: trait_.module(db).krate(db) != Some(krate), |
506 | non_enumerable: is_non_enumerable_trait(db, trait_), | 498 | non_enumerable: true, |
507 | // FIXME set these flags correctly | 499 | // FIXME set these flags correctly |
508 | marker: false, | 500 | marker: false, |
509 | fundamental: false, | 501 | fundamental: false, |