diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/autoderef.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 23 |
3 files changed, 26 insertions, 3 deletions
diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs index ee48fa537..f32d5786a 100644 --- a/crates/ra_hir_ty/src/autoderef.rs +++ b/crates/ra_hir_ty/src/autoderef.rs | |||
@@ -48,7 +48,7 @@ fn deref_by_trait( | |||
48 | krate: CrateId, | 48 | krate: CrateId, |
49 | ty: InEnvironment<&Canonical<Ty>>, | 49 | ty: InEnvironment<&Canonical<Ty>>, |
50 | ) -> Option<Canonical<Ty>> { | 50 | ) -> Option<Canonical<Ty>> { |
51 | let deref_trait = match db.lang_item(krate.into(), "deref".into())? { | 51 | let deref_trait = match db.lang_item(krate, "deref".into())? { |
52 | LangItemTarget::TraitId(it) => it, | 52 | LangItemTarget::TraitId(it) => it, |
53 | _ => return None, | 53 | _ => return None, |
54 | }; | 54 | }; |
@@ -78,7 +78,7 @@ fn deref_by_trait( | |||
78 | 78 | ||
79 | let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env }; | 79 | let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env }; |
80 | 80 | ||
81 | let solution = db.trait_solve(krate.into(), canonical)?; | 81 | let solution = db.trait_solve(krate, canonical)?; |
82 | 82 | ||
83 | match &solution { | 83 | match &solution { |
84 | Solution::Unique(vars) => { | 84 | Solution::Unique(vars) => { |
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 7310ef10d..48abf97c9 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -919,7 +919,7 @@ impl HirDisplay for ApplicationTy { | |||
919 | { | 919 | { |
920 | Option::None => self.parameters.0.as_ref(), | 920 | Option::None => self.parameters.0.as_ref(), |
921 | Option::Some(default_parameters) => { | 921 | Option::Some(default_parameters) => { |
922 | for (i, parameter) in self.parameters.into_iter().enumerate() { | 922 | for (i, parameter) in self.parameters.iter().enumerate() { |
923 | match (parameter, default_parameters.get(i)) { | 923 | match (parameter, default_parameters.get(i)) { |
924 | (&Ty::Unknown, _) | (_, None) => { | 924 | (&Ty::Unknown, _) | (_, None) => { |
925 | non_default_parameters.push(parameter.clone()) | 925 | non_default_parameters.push(parameter.clone()) |
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 7fdbf996f..69c695cc8 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -202,6 +202,29 @@ fn test() { S.foo()<|>; } | |||
202 | } | 202 | } |
203 | 203 | ||
204 | #[test] | 204 | #[test] |
205 | fn infer_impl_items_generated_by_macros_chain() { | ||
206 | let t = type_at( | ||
207 | r#" | ||
208 | //- /main.rs | ||
209 | macro_rules! m_inner { | ||
210 | () => {fn foo(&self) -> u128 {0}} | ||
211 | } | ||
212 | macro_rules! m { | ||
213 | () => {m_inner!();} | ||
214 | } | ||
215 | |||
216 | struct S; | ||
217 | impl S { | ||
218 | m!(); | ||
219 | } | ||
220 | |||
221 | fn test() { S.foo()<|>; } | ||
222 | "#, | ||
223 | ); | ||
224 | assert_eq!(t, "u128"); | ||
225 | } | ||
226 | |||
227 | #[test] | ||
205 | fn infer_macro_with_dollar_crate_is_correct_in_expr() { | 228 | fn infer_macro_with_dollar_crate_is_correct_in_expr() { |
206 | let (db, pos) = TestDB::with_position( | 229 | let (db, pos) = TestDB::with_position( |
207 | r#" | 230 | r#" |