diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 58 |
2 files changed, 61 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 061229842..a2adbc4b8 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -429,6 +429,9 @@ pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace | |||
429 | (TypableDef::Const(_), Namespace::Types) => Ty::Unknown, | 429 | (TypableDef::Const(_), Namespace::Types) => Ty::Unknown, |
430 | (TypableDef::Static(_), Namespace::Types) => Ty::Unknown, | 430 | (TypableDef::Static(_), Namespace::Types) => Ty::Unknown, |
431 | (TypableDef::BuiltinType(_), Namespace::Values) => Ty::Unknown, | 431 | (TypableDef::BuiltinType(_), Namespace::Values) => Ty::Unknown, |
432 | |||
433 | // Macro is not typeable | ||
434 | (_, Namespace::Macro) => Ty::Unknown, | ||
432 | } | 435 | } |
433 | } | 436 | } |
434 | 437 | ||
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 25716fe8c..38fe62279 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() { |