diff options
Diffstat (limited to 'crates/hir_ty')
24 files changed, 160 insertions, 132 deletions
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index d1302d749..b9c93f56f 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml | |||
@@ -10,6 +10,7 @@ edition = "2018" | |||
10 | doctest = false | 10 | doctest = false |
11 | 11 | ||
12 | [dependencies] | 12 | [dependencies] |
13 | cov-mark = "1.1" | ||
13 | itertools = "0.10.0" | 14 | itertools = "0.10.0" |
14 | arrayvec = "0.5.1" | 15 | arrayvec = "0.5.1" |
15 | smallvec = "1.2.0" | 16 | smallvec = "1.2.0" |
@@ -17,9 +18,9 @@ ena = "0.14.0" | |||
17 | log = "0.4.8" | 18 | log = "0.4.8" |
18 | rustc-hash = "1.1.0" | 19 | rustc-hash = "1.1.0" |
19 | scoped-tls = "1" | 20 | scoped-tls = "1" |
20 | chalk-solve = { version = "0.59", default-features = false } | 21 | chalk-solve = { version = "0.60", default-features = false } |
21 | chalk-ir = "0.59" | 22 | chalk-ir = "0.60" |
22 | chalk-recursive = "0.59" | 23 | chalk-recursive = "0.60" |
23 | la-arena = { version = "0.2.0", path = "../../lib/arena" } | 24 | la-arena = { version = "0.2.0", path = "../../lib/arena" } |
24 | 25 | ||
25 | stdx = { path = "../stdx", version = "0.0.0" } | 26 | stdx = { path = "../stdx", version = "0.0.0" } |
@@ -28,9 +29,9 @@ hir_expand = { path = "../hir_expand", version = "0.0.0" } | |||
28 | base_db = { path = "../base_db", version = "0.0.0" } | 29 | base_db = { path = "../base_db", version = "0.0.0" } |
29 | profile = { path = "../profile", version = "0.0.0" } | 30 | profile = { path = "../profile", version = "0.0.0" } |
30 | syntax = { path = "../syntax", version = "0.0.0" } | 31 | syntax = { path = "../syntax", version = "0.0.0" } |
31 | test_utils = { path = "../test_utils", version = "0.0.0" } | ||
32 | 32 | ||
33 | [dev-dependencies] | 33 | [dev-dependencies] |
34 | test_utils = { path = "../test_utils" } | ||
34 | expect-test = "1.1" | 35 | expect-test = "1.1" |
35 | tracing = "0.1" | 36 | tracing = "0.1" |
36 | tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } | 37 | tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } |
diff --git a/crates/hir_ty/src/db.rs b/crates/hir_ty/src/db.rs index b3af82444..06714409f 100644 --- a/crates/hir_ty/src/db.rs +++ b/crates/hir_ty/src/db.rs | |||
@@ -130,7 +130,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { | |||
130 | ) -> chalk_ir::ProgramClauses<chalk::Interner>; | 130 | ) -> chalk_ir::ProgramClauses<chalk::Interner>; |
131 | } | 131 | } |
132 | 132 | ||
133 | fn infer_wait(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { | 133 | fn infer_wait(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { |
134 | let _p = profile::span("infer:wait").detail(|| match def { | 134 | let _p = profile::span("infer:wait").detail(|| match def { |
135 | DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(), | 135 | DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(), |
136 | DefWithBodyId::StaticId(it) => { | 136 | DefWithBodyId::StaticId(it) => { |
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 6773ddea3..3605ca581 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs | |||
@@ -28,7 +28,6 @@ use syntax::{ | |||
28 | ast::{self, NameOwner}, | 28 | ast::{self, NameOwner}, |
29 | AstNode, AstPtr, | 29 | AstNode, AstPtr, |
30 | }; | 30 | }; |
31 | use test_utils::mark; | ||
32 | 31 | ||
33 | use crate::{ | 32 | use crate::{ |
34 | db::HirDatabase, | 33 | db::HirDatabase, |
@@ -93,16 +92,21 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
93 | fn validate_func(&mut self, func: FunctionId) { | 92 | fn validate_func(&mut self, func: FunctionId) { |
94 | let data = self.db.function_data(func); | 93 | let data = self.db.function_data(func); |
95 | if data.is_extern { | 94 | if data.is_extern { |
96 | mark::hit!(extern_func_incorrect_case_ignored); | 95 | cov_mark::hit!(extern_func_incorrect_case_ignored); |
97 | return; | 96 | return; |
98 | } | 97 | } |
99 | 98 | ||
100 | let body = self.db.body(func.into()); | 99 | let body = self.db.body(func.into()); |
101 | 100 | ||
102 | // Recursively validate inner scope items, such as static variables and constants. | 101 | // Recursively validate inner scope items, such as static variables and constants. |
103 | for (item_id, _) in body.item_scope.values() { | 102 | let db = self.db; |
104 | let mut validator = DeclValidator::new(self.db, self.krate, self.sink); | 103 | for block_def_map in body.block_scopes.iter().filter_map(|block| db.block_def_map(*block)) { |
105 | validator.validate_item(item_id); | 104 | for (_, module) in block_def_map.modules() { |
105 | for (def_id, _) in module.scope.values() { | ||
106 | let mut validator = DeclValidator::new(self.db, self.krate, self.sink); | ||
107 | validator.validate_item(def_id); | ||
108 | } | ||
109 | } | ||
106 | } | 110 | } |
107 | 111 | ||
108 | // Check whether non-snake case identifiers are allowed for this function. | 112 | // Check whether non-snake case identifiers are allowed for this function. |
@@ -625,7 +629,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
625 | fn validate_static(&mut self, static_id: StaticId) { | 629 | fn validate_static(&mut self, static_id: StaticId) { |
626 | let data = self.db.static_data(static_id); | 630 | let data = self.db.static_data(static_id); |
627 | if data.is_extern { | 631 | if data.is_extern { |
628 | mark::hit!(extern_static_incorrect_case_ignored); | 632 | cov_mark::hit!(extern_static_incorrect_case_ignored); |
629 | return; | 633 | return; |
630 | } | 634 | } |
631 | 635 | ||
@@ -673,8 +677,6 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
673 | 677 | ||
674 | #[cfg(test)] | 678 | #[cfg(test)] |
675 | mod tests { | 679 | mod tests { |
676 | use test_utils::mark; | ||
677 | |||
678 | use crate::diagnostics::tests::check_diagnostics; | 680 | use crate::diagnostics::tests::check_diagnostics; |
679 | 681 | ||
680 | #[test] | 682 | #[test] |
@@ -889,8 +891,8 @@ fn main() { | |||
889 | 891 | ||
890 | #[test] | 892 | #[test] |
891 | fn ignores_extern_items() { | 893 | fn ignores_extern_items() { |
892 | mark::check!(extern_func_incorrect_case_ignored); | 894 | cov_mark::check!(extern_func_incorrect_case_ignored); |
893 | mark::check!(extern_static_incorrect_case_ignored); | 895 | cov_mark::check!(extern_static_incorrect_case_ignored); |
894 | check_diagnostics( | 896 | check_diagnostics( |
895 | r#" | 897 | r#" |
896 | extern { | 898 | extern { |
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 66a88e2b6..2751cd304 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -2,9 +2,7 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use hir_def::{ | 5 | use hir_def::{expr::Statement, path::path, resolver::HasResolver, AssocItemId, DefWithBodyId}; |
6 | expr::Statement, path::path, resolver::HasResolver, AdtId, AssocItemId, DefWithBodyId, | ||
7 | }; | ||
8 | use hir_expand::{diagnostics::DiagnosticSink, name}; | 6 | use hir_expand::{diagnostics::DiagnosticSink, name}; |
9 | use rustc_hash::FxHashSet; | 7 | use rustc_hash::FxHashSet; |
10 | use syntax::{ast, AstPtr}; | 8 | use syntax::{ast, AstPtr}; |
@@ -17,7 +15,7 @@ use crate::{ | |||
17 | MissingPatFields, RemoveThisSemicolon, | 15 | MissingPatFields, RemoveThisSemicolon, |
18 | }, | 16 | }, |
19 | utils::variant_data, | 17 | utils::variant_data, |
20 | InferenceResult, Ty, | 18 | AdtId, InferenceResult, Ty, |
21 | }; | 19 | }; |
22 | 20 | ||
23 | pub(crate) use hir_def::{ | 21 | pub(crate) use hir_def::{ |
@@ -382,10 +380,14 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
382 | }; | 380 | }; |
383 | 381 | ||
384 | let (params, required) = match mismatch.expected { | 382 | let (params, required) = match mismatch.expected { |
385 | Ty::Adt(AdtId::EnumId(enum_id), ref parameters) if enum_id == core_result_enum => { | 383 | Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters) |
384 | if enum_id == core_result_enum => | ||
385 | { | ||
386 | (parameters, "Ok".to_string()) | 386 | (parameters, "Ok".to_string()) |
387 | } | 387 | } |
388 | Ty::Adt(AdtId::EnumId(enum_id), ref parameters) if enum_id == core_option_enum => { | 388 | Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters) |
389 | if enum_id == core_option_enum => | ||
390 | { | ||
389 | (parameters, "Some".to_string()) | 391 | (parameters, "Some".to_string()) |
390 | } | 392 | } |
391 | _ => return, | 393 | _ => return, |
diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 86fee0050..04d39c571 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs | |||
@@ -222,12 +222,12 @@ use hir_def::{ | |||
222 | adt::VariantData, | 222 | adt::VariantData, |
223 | body::Body, | 223 | body::Body, |
224 | expr::{Expr, Literal, Pat, PatId}, | 224 | expr::{Expr, Literal, Pat, PatId}, |
225 | AdtId, EnumVariantId, StructId, VariantId, | 225 | EnumVariantId, StructId, VariantId, |
226 | }; | 226 | }; |
227 | use la_arena::Idx; | 227 | use la_arena::Idx; |
228 | use smallvec::{smallvec, SmallVec}; | 228 | use smallvec::{smallvec, SmallVec}; |
229 | 229 | ||
230 | use crate::{db::HirDatabase, InferenceResult, Ty}; | 230 | use crate::{db::HirDatabase, AdtId, InferenceResult, Ty}; |
231 | 231 | ||
232 | #[derive(Debug, Clone, Copy)] | 232 | #[derive(Debug, Clone, Copy)] |
233 | /// Either a pattern from the source code being analyzed, represented as | 233 | /// Either a pattern from the source code being analyzed, represented as |
@@ -627,7 +627,7 @@ pub(super) fn is_useful( | |||
627 | // - `!` type | 627 | // - `!` type |
628 | // In those cases, no match arm is useful. | 628 | // In those cases, no match arm is useful. |
629 | match cx.infer[cx.match_expr].strip_references() { | 629 | match cx.infer[cx.match_expr].strip_references() { |
630 | Ty::Adt(AdtId::EnumId(enum_id), ..) => { | 630 | Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ..) => { |
631 | if cx.db.enum_data(*enum_id).variants.is_empty() { | 631 | if cx.db.enum_data(*enum_id).variants.is_empty() { |
632 | return Ok(Usefulness::NotUseful); | 632 | return Ok(Usefulness::NotUseful); |
633 | } | 633 | } |
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index d4a8b48e6..ab51cb0a6 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -2,19 +2,20 @@ | |||
2 | 2 | ||
3 | use std::{borrow::Cow, fmt}; | 3 | use std::{borrow::Cow, fmt}; |
4 | 4 | ||
5 | use crate::{ | ||
6 | db::HirDatabase, primitive, utils::generics, AliasTy, CallableDefId, CallableSig, | ||
7 | GenericPredicate, Lifetime, Obligation, OpaqueTy, OpaqueTyId, ProjectionTy, Scalar, Substs, | ||
8 | TraitRef, Ty, | ||
9 | }; | ||
10 | use arrayvec::ArrayVec; | 5 | use arrayvec::ArrayVec; |
11 | use chalk_ir::Mutability; | 6 | use chalk_ir::Mutability; |
12 | use hir_def::{ | 7 | use hir_def::{ |
13 | db::DefDatabase, find_path, generics::TypeParamProvenance, item_scope::ItemInNs, AdtId, | 8 | db::DefDatabase, find_path, generics::TypeParamProvenance, item_scope::ItemInNs, |
14 | AssocContainerId, HasModule, Lookup, ModuleId, TraitId, | 9 | AssocContainerId, Lookup, ModuleId, TraitId, |
15 | }; | 10 | }; |
16 | use hir_expand::name::Name; | 11 | use hir_expand::name::Name; |
17 | 12 | ||
13 | use crate::{ | ||
14 | db::HirDatabase, primitive, utils::generics, AdtId, AliasTy, CallableDefId, CallableSig, | ||
15 | GenericPredicate, Lifetime, Obligation, OpaqueTy, OpaqueTyId, ProjectionTy, Scalar, Substs, | ||
16 | TraitRef, Ty, | ||
17 | }; | ||
18 | |||
18 | pub struct HirFormatter<'a> { | 19 | pub struct HirFormatter<'a> { |
19 | pub db: &'a dyn HirDatabase, | 20 | pub db: &'a dyn HirDatabase, |
20 | fmt: &'a mut dyn fmt::Write, | 21 | fmt: &'a mut dyn fmt::Write, |
@@ -400,13 +401,13 @@ impl HirDisplay for Ty { | |||
400 | write!(f, " -> {}", ret_display)?; | 401 | write!(f, " -> {}", ret_display)?; |
401 | } | 402 | } |
402 | } | 403 | } |
403 | Ty::Adt(def_id, parameters) => { | 404 | Ty::Adt(AdtId(def_id), parameters) => { |
404 | match f.display_target { | 405 | match f.display_target { |
405 | DisplayTarget::Diagnostics | DisplayTarget::Test => { | 406 | DisplayTarget::Diagnostics | DisplayTarget::Test => { |
406 | let name = match *def_id { | 407 | let name = match *def_id { |
407 | AdtId::StructId(it) => f.db.struct_data(it).name.clone(), | 408 | hir_def::AdtId::StructId(it) => f.db.struct_data(it).name.clone(), |
408 | AdtId::UnionId(it) => f.db.union_data(it).name.clone(), | 409 | hir_def::AdtId::UnionId(it) => f.db.union_data(it).name.clone(), |
409 | AdtId::EnumId(it) => f.db.enum_data(it).name.clone(), | 410 | hir_def::AdtId::EnumId(it) => f.db.enum_data(it).name.clone(), |
410 | }; | 411 | }; |
411 | write!(f, "{}", name)?; | 412 | write!(f, "{}", name)?; |
412 | } | 413 | } |
@@ -610,7 +611,7 @@ impl HirDisplay for CallableSig { | |||
610 | } | 611 | } |
611 | 612 | ||
612 | fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = TraitId> { | 613 | fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = TraitId> { |
613 | let krate = trait_.lookup(db).container.module(db).krate(); | 614 | let krate = trait_.lookup(db).container.krate(); |
614 | let fn_traits = [ | 615 | let fn_traits = [ |
615 | db.lang_item(krate, "fn".into()), | 616 | db.lang_item(krate, "fn".into()), |
616 | db.lang_item(krate, "fn_mut".into()), | 617 | db.lang_item(krate, "fn_mut".into()), |
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index cf0a3add4..7e8846f27 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -6,7 +6,6 @@ | |||
6 | 6 | ||
7 | use chalk_ir::{Mutability, TyVariableKind}; | 7 | use chalk_ir::{Mutability, TyVariableKind}; |
8 | use hir_def::lang_item::LangItemTarget; | 8 | use hir_def::lang_item::LangItemTarget; |
9 | use test_utils::mark; | ||
10 | 9 | ||
11 | use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty}; | 10 | use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty}; |
12 | 11 | ||
@@ -35,7 +34,7 @@ impl<'a> InferenceContext<'a> { | |||
35 | ty1.clone() | 34 | ty1.clone() |
36 | } else { | 35 | } else { |
37 | if let (Ty::FnDef(..), Ty::FnDef(..)) = (ty1, ty2) { | 36 | if let (Ty::FnDef(..), Ty::FnDef(..)) = (ty1, ty2) { |
38 | mark::hit!(coerce_fn_reification); | 37 | cov_mark::hit!(coerce_fn_reification); |
39 | // Special case: two function types. Try to coerce both to | 38 | // Special case: two function types. Try to coerce both to |
40 | // pointers to have a chance at getting a match. See | 39 | // pointers to have a chance at getting a match. See |
41 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 | 40 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 |
@@ -45,7 +44,7 @@ impl<'a> InferenceContext<'a> { | |||
45 | let ptr_ty2 = Ty::fn_ptr(sig2); | 44 | let ptr_ty2 = Ty::fn_ptr(sig2); |
46 | self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) | 45 | self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) |
47 | } else { | 46 | } else { |
48 | mark::hit!(coerce_merge_fail_fallback); | 47 | cov_mark::hit!(coerce_merge_fail_fallback); |
49 | ty1.clone() | 48 | ty1.clone() |
50 | } | 49 | } |
51 | } | 50 | } |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index cf1f1038a..262177ffb 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -8,11 +8,10 @@ use hir_def::{ | |||
8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, | 8 | expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, |
9 | path::{GenericArg, GenericArgs}, | 9 | path::{GenericArg, GenericArgs}, |
10 | resolver::resolver_for_expr, | 10 | resolver::resolver_for_expr, |
11 | AdtId, AssocContainerId, FieldId, Lookup, | 11 | AssocContainerId, FieldId, Lookup, |
12 | }; | 12 | }; |
13 | use hir_expand::name::{name, Name}; | 13 | use hir_expand::name::{name, Name}; |
14 | use syntax::ast::RangeOp; | 14 | use syntax::ast::RangeOp; |
15 | use test_utils::mark; | ||
16 | 15 | ||
17 | use crate::{ | 16 | use crate::{ |
18 | autoderef, | 17 | autoderef, |
@@ -21,8 +20,8 @@ use crate::{ | |||
21 | primitive::{self, UintTy}, | 20 | primitive::{self, UintTy}, |
22 | traits::{FnTrait, InEnvironment}, | 21 | traits::{FnTrait, InEnvironment}, |
23 | utils::{generics, variant_data, Generics}, | 22 | utils::{generics, variant_data, Generics}, |
24 | Binders, CallableDefId, FnPointer, FnSig, Obligation, OpaqueTyId, Rawness, Scalar, Substs, | 23 | AdtId, Binders, CallableDefId, FnPointer, FnSig, Obligation, OpaqueTyId, Rawness, Scalar, |
25 | TraitRef, Ty, | 24 | Substs, TraitRef, Ty, |
26 | }; | 25 | }; |
27 | 26 | ||
28 | use super::{ | 27 | use super::{ |
@@ -429,14 +428,14 @@ impl<'a> InferenceContext<'a> { | |||
429 | Ty::Tuple(_, substs) => { | 428 | Ty::Tuple(_, substs) => { |
430 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) | 429 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) |
431 | } | 430 | } |
432 | Ty::Adt(AdtId::StructId(s), parameters) => { | 431 | Ty::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { |
433 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { | 432 | self.db.struct_data(s).variant_data.field(name).map(|local_id| { |
434 | let field = FieldId { parent: s.into(), local_id }; | 433 | let field = FieldId { parent: s.into(), local_id }; |
435 | self.write_field_resolution(tgt_expr, field); | 434 | self.write_field_resolution(tgt_expr, field); |
436 | self.db.field_types(s.into())[field.local_id].clone().subst(¶meters) | 435 | self.db.field_types(s.into())[field.local_id].clone().subst(¶meters) |
437 | }) | 436 | }) |
438 | } | 437 | } |
439 | Ty::Adt(AdtId::UnionId(u), parameters) => { | 438 | Ty::Adt(AdtId(hir_def::AdtId::UnionId(u)), parameters) => { |
440 | self.db.union_data(u).variant_data.field(name).map(|local_id| { | 439 | self.db.union_data(u).variant_data.field(name).map(|local_id| { |
441 | let field = FieldId { parent: u.into(), local_id }; | 440 | let field = FieldId { parent: u.into(), local_id }; |
442 | self.write_field_resolution(tgt_expr, field); | 441 | self.write_field_resolution(tgt_expr, field); |
@@ -498,7 +497,7 @@ impl<'a> InferenceContext<'a> { | |||
498 | _ => (), | 497 | _ => (), |
499 | } | 498 | } |
500 | sb = sb.fill(repeat_with(|| self.table.new_type_var())); | 499 | sb = sb.fill(repeat_with(|| self.table.new_type_var())); |
501 | Ty::Adt(box_, sb.build()) | 500 | Ty::adt_ty(box_, sb.build()) |
502 | } else { | 501 | } else { |
503 | Ty::Unknown | 502 | Ty::Unknown |
504 | } | 503 | } |
@@ -565,7 +564,7 @@ impl<'a> InferenceContext<'a> { | |||
565 | let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone()); | 564 | let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone()); |
566 | 565 | ||
567 | if ret == Ty::Unknown { | 566 | if ret == Ty::Unknown { |
568 | mark::hit!(infer_expr_inner_binary_operator_overload); | 567 | cov_mark::hit!(infer_expr_inner_binary_operator_overload); |
569 | 568 | ||
570 | self.resolve_associated_type_with_params( | 569 | self.resolve_associated_type_with_params( |
571 | lhs_ty, | 570 | lhs_ty, |
@@ -586,31 +585,31 @@ impl<'a> InferenceContext<'a> { | |||
586 | let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); | 585 | let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); |
587 | match (range_type, lhs_ty, rhs_ty) { | 586 | match (range_type, lhs_ty, rhs_ty) { |
588 | (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { | 587 | (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { |
589 | Some(adt) => Ty::Adt(adt, Substs::empty()), | 588 | Some(adt) => Ty::adt_ty(adt, Substs::empty()), |
590 | None => Ty::Unknown, | 589 | None => Ty::Unknown, |
591 | }, | 590 | }, |
592 | (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { | 591 | (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { |
593 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 592 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
594 | None => Ty::Unknown, | 593 | None => Ty::Unknown, |
595 | }, | 594 | }, |
596 | (RangeOp::Inclusive, None, Some(ty)) => { | 595 | (RangeOp::Inclusive, None, Some(ty)) => { |
597 | match self.resolve_range_to_inclusive() { | 596 | match self.resolve_range_to_inclusive() { |
598 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 597 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
599 | None => Ty::Unknown, | 598 | None => Ty::Unknown, |
600 | } | 599 | } |
601 | } | 600 | } |
602 | (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { | 601 | (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { |
603 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 602 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
604 | None => Ty::Unknown, | 603 | None => Ty::Unknown, |
605 | }, | 604 | }, |
606 | (RangeOp::Inclusive, Some(_), Some(ty)) => { | 605 | (RangeOp::Inclusive, Some(_), Some(ty)) => { |
607 | match self.resolve_range_inclusive() { | 606 | match self.resolve_range_inclusive() { |
608 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 607 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
609 | None => Ty::Unknown, | 608 | None => Ty::Unknown, |
610 | } | 609 | } |
611 | } | 610 | } |
612 | (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { | 611 | (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { |
613 | Some(adt) => Ty::Adt(adt, Substs::single(ty)), | 612 | Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), |
614 | None => Ty::Unknown, | 613 | None => Ty::Unknown, |
615 | }, | 614 | }, |
616 | (RangeOp::Inclusive, _, None) => Ty::Unknown, | 615 | (RangeOp::Inclusive, _, None) => Ty::Unknown, |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index eb099311c..a0ac8d80f 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -10,7 +10,6 @@ use hir_def::{ | |||
10 | FieldId, | 10 | FieldId, |
11 | }; | 11 | }; |
12 | use hir_expand::name::Name; | 12 | use hir_expand::name::Name; |
13 | use test_utils::mark; | ||
14 | 13 | ||
15 | use super::{BindingMode, Expectation, InferenceContext}; | 14 | use super::{BindingMode, Expectation, InferenceContext}; |
16 | use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty}; | 15 | use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty}; |
@@ -108,7 +107,7 @@ impl<'a> InferenceContext<'a> { | |||
108 | } | 107 | } |
109 | } | 108 | } |
110 | } else if let Pat::Ref { .. } = &body[pat] { | 109 | } else if let Pat::Ref { .. } = &body[pat] { |
111 | mark::hit!(match_ergonomics_ref); | 110 | cov_mark::hit!(match_ergonomics_ref); |
112 | // When you encounter a `&pat` pattern, reset to Move. | 111 | // When you encounter a `&pat` pattern, reset to Move. |
113 | // This is so that `w` is by value: `let (_, &w) = &(1, &2);` | 112 | // This is so that `w` is by value: `let (_, &w) = &(1, &2);` |
114 | default_bm = BindingMode::Move; | 113 | default_bm = BindingMode::Move; |
@@ -237,7 +236,7 @@ impl<'a> InferenceContext<'a> { | |||
237 | }; | 236 | }; |
238 | 237 | ||
239 | let inner_ty = self.infer_pat(*inner, inner_expected, default_bm); | 238 | let inner_ty = self.infer_pat(*inner, inner_expected, default_bm); |
240 | Ty::Adt(box_adt, Substs::single(inner_ty)) | 239 | Ty::adt_ty(box_adt, Substs::single(inner_ty)) |
241 | } | 240 | } |
242 | None => Ty::Unknown, | 241 | None => Ty::Unknown, |
243 | }, | 242 | }, |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 5d541104e..ae3554bac 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -260,7 +260,7 @@ impl<'a> InferenceContext<'a> { | |||
260 | })); | 260 | })); |
261 | Some(trait_substs) | 261 | Some(trait_substs) |
262 | } | 262 | } |
263 | AssocContainerId::ContainerId(_) => None, | 263 | AssocContainerId::ModuleId(_) => None, |
264 | }; | 264 | }; |
265 | 265 | ||
266 | self.write_assoc_resolution(id, item); | 266 | self.write_assoc_resolution(id, item); |
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 99a89a7f3..54fcfed10 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -5,8 +5,6 @@ use std::borrow::Cow; | |||
5 | use chalk_ir::{FloatTy, IntTy, TyVariableKind}; | 5 | use chalk_ir::{FloatTy, IntTy, TyVariableKind}; |
6 | use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; | 6 | use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; |
7 | 7 | ||
8 | use test_utils::mark; | ||
9 | |||
10 | use super::{InferenceContext, Obligation}; | 8 | use super::{InferenceContext, Obligation}; |
11 | use crate::{ | 9 | use crate::{ |
12 | BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Scalar, | 10 | BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Scalar, |
@@ -387,7 +385,7 @@ impl InferenceTable { | |||
387 | // more than once | 385 | // more than once |
388 | for i in 0..3 { | 386 | for i in 0..3 { |
389 | if i > 0 { | 387 | if i > 0 { |
390 | mark::hit!(type_var_resolves_to_int_var); | 388 | cov_mark::hit!(type_var_resolves_to_int_var); |
391 | } | 389 | } |
392 | match &*ty { | 390 | match &*ty { |
393 | Ty::InferenceVar(tv, _) => { | 391 | Ty::InferenceVar(tv, _) => { |
@@ -416,7 +414,7 @@ impl InferenceTable { | |||
416 | Ty::InferenceVar(tv, kind) => { | 414 | Ty::InferenceVar(tv, kind) => { |
417 | let inner = tv.to_inner(); | 415 | let inner = tv.to_inner(); |
418 | if tv_stack.contains(&inner) { | 416 | if tv_stack.contains(&inner) { |
419 | mark::hit!(type_var_cycles_resolve_as_possible); | 417 | cov_mark::hit!(type_var_cycles_resolve_as_possible); |
420 | // recursive type | 418 | // recursive type |
421 | return self.type_variable_table.fallback_value(tv, kind); | 419 | return self.type_variable_table.fallback_value(tv, kind); |
422 | } | 420 | } |
@@ -443,7 +441,7 @@ impl InferenceTable { | |||
443 | Ty::InferenceVar(tv, kind) => { | 441 | Ty::InferenceVar(tv, kind) => { |
444 | let inner = tv.to_inner(); | 442 | let inner = tv.to_inner(); |
445 | if tv_stack.contains(&inner) { | 443 | if tv_stack.contains(&inner) { |
446 | mark::hit!(type_var_cycles_resolve_completely); | 444 | cov_mark::hit!(type_var_cycles_resolve_completely); |
447 | // recursive type | 445 | // recursive type |
448 | return self.type_variable_table.fallback_value(tv, kind); | 446 | return self.type_variable_table.fallback_value(tv, kind); |
449 | } | 447 | } |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index c2a20c480..e77f24e4e 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -27,9 +27,9 @@ use std::{iter, mem, ops::Deref, sync::Arc}; | |||
27 | 27 | ||
28 | use base_db::salsa; | 28 | use base_db::salsa; |
29 | use hir_def::{ | 29 | use hir_def::{ |
30 | builtin_type::BuiltinType, expr::ExprId, type_ref::Rawness, AdtId, AssocContainerId, | 30 | builtin_type::BuiltinType, expr::ExprId, type_ref::Rawness, AssocContainerId, DefWithBodyId, |
31 | DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, Lookup, TraitId, | 31 | FunctionId, GenericDefId, HasModule, LifetimeParamId, Lookup, TraitId, TypeAliasId, |
32 | TypeAliasId, TypeParamId, | 32 | TypeParamId, |
33 | }; | 33 | }; |
34 | use itertools::Itertools; | 34 | use itertools::Itertools; |
35 | 35 | ||
@@ -47,7 +47,9 @@ pub use lower::{ | |||
47 | }; | 47 | }; |
48 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 48 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; |
49 | 49 | ||
50 | pub use chalk_ir::{BoundVar, DebruijnIndex, Mutability, Scalar, TyVariableKind}; | 50 | pub use chalk_ir::{AdtId, BoundVar, DebruijnIndex, Mutability, Scalar, TyVariableKind}; |
51 | |||
52 | pub(crate) use crate::traits::chalk::Interner; | ||
51 | 53 | ||
52 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 54 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
53 | pub enum Lifetime { | 55 | pub enum Lifetime { |
@@ -131,7 +133,7 @@ pub enum AliasTy { | |||
131 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 133 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
132 | pub enum Ty { | 134 | pub enum Ty { |
133 | /// Structures, enumerations and unions. | 135 | /// Structures, enumerations and unions. |
134 | Adt(AdtId, Substs), | 136 | Adt(AdtId<Interner>, Substs), |
135 | 137 | ||
136 | /// Represents an associated item like `Iterator::Item`. This is used | 138 | /// Represents an associated item like `Iterator::Item`. This is used |
137 | /// when we have tried to normalize a projection like `T::Item` but | 139 | /// when we have tried to normalize a projection like `T::Item` but |
@@ -602,6 +604,10 @@ impl Ty { | |||
602 | Ty::Tuple(0, Substs::empty()) | 604 | Ty::Tuple(0, Substs::empty()) |
603 | } | 605 | } |
604 | 606 | ||
607 | pub fn adt_ty(adt: hir_def::AdtId, substs: Substs) -> Ty { | ||
608 | Ty::Adt(AdtId(adt), substs) | ||
609 | } | ||
610 | |||
605 | pub fn fn_ptr(sig: CallableSig) -> Self { | 611 | pub fn fn_ptr(sig: CallableSig) -> Self { |
606 | Ty::Function(FnPointer { | 612 | Ty::Function(FnPointer { |
607 | num_args: sig.params().len(), | 613 | num_args: sig.params().len(), |
@@ -650,9 +656,9 @@ impl Ty { | |||
650 | t | 656 | t |
651 | } | 657 | } |
652 | 658 | ||
653 | pub fn as_adt(&self) -> Option<(AdtId, &Substs)> { | 659 | pub fn as_adt(&self) -> Option<(hir_def::AdtId, &Substs)> { |
654 | match self { | 660 | match self { |
655 | Ty::Adt(adt_def, parameters) => Some((*adt_def, parameters)), | 661 | Ty::Adt(AdtId(adt), parameters) => Some((*adt, parameters)), |
656 | _ => None, | 662 | _ => None, |
657 | } | 663 | } |
658 | } | 664 | } |
@@ -666,7 +672,7 @@ impl Ty { | |||
666 | 672 | ||
667 | pub fn as_generic_def(&self) -> Option<GenericDefId> { | 673 | pub fn as_generic_def(&self) -> Option<GenericDefId> { |
668 | match *self { | 674 | match *self { |
669 | Ty::Adt(adt, ..) => Some(adt.into()), | 675 | Ty::Adt(AdtId(adt), ..) => Some(adt.into()), |
670 | Ty::FnDef(callable, ..) => Some(callable.into()), | 676 | Ty::FnDef(callable, ..) => Some(callable.into()), |
671 | Ty::AssociatedType(type_alias, ..) => Some(type_alias.into()), | 677 | Ty::AssociatedType(type_alias, ..) => Some(type_alias.into()), |
672 | Ty::ForeignType(type_alias, ..) => Some(type_alias.into()), | 678 | Ty::ForeignType(type_alias, ..) => Some(type_alias.into()), |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 1b5843d48..5fa83567b 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -24,7 +24,6 @@ use hir_expand::name::Name; | |||
24 | use la_arena::ArenaMap; | 24 | use la_arena::ArenaMap; |
25 | use smallvec::SmallVec; | 25 | use smallvec::SmallVec; |
26 | use stdx::impl_from; | 26 | use stdx::impl_from; |
27 | use test_utils::mark; | ||
28 | 27 | ||
29 | use crate::{ | 28 | use crate::{ |
30 | db::HirDatabase, | 29 | db::HirDatabase, |
@@ -760,7 +759,7 @@ fn assoc_type_bindings_from_type_bound<'a>( | |||
760 | 759 | ||
761 | impl ReturnTypeImplTrait { | 760 | impl ReturnTypeImplTrait { |
762 | fn from_hir(ctx: &TyLoweringContext, bounds: &[TypeBound]) -> Self { | 761 | fn from_hir(ctx: &TyLoweringContext, bounds: &[TypeBound]) -> Self { |
763 | mark::hit!(lower_rpit); | 762 | cov_mark::hit!(lower_rpit); |
764 | let self_ty = Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)); | 763 | let self_ty = Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)); |
765 | let predicates = ctx.with_shifted_in(DebruijnIndex::ONE, |ctx| { | 764 | let predicates = ctx.with_shifted_in(DebruijnIndex::ONE, |ctx| { |
766 | bounds | 765 | bounds |
@@ -935,7 +934,7 @@ impl TraitEnvironment { | |||
935 | // add `Self: Trait<T1, T2, ...>` to the environment in trait | 934 | // add `Self: Trait<T1, T2, ...>` to the environment in trait |
936 | // function default implementations (and hypothetical code | 935 | // function default implementations (and hypothetical code |
937 | // inside consts or type aliases) | 936 | // inside consts or type aliases) |
938 | test_utils::mark::hit!(trait_self_implements_self); | 937 | cov_mark::hit!(trait_self_implements_self); |
939 | let substs = Substs::type_params(db, trait_id); | 938 | let substs = Substs::type_params(db, trait_id); |
940 | let trait_ref = TraitRef { trait_: trait_id, substs }; | 939 | let trait_ref = TraitRef { trait_: trait_id, substs }; |
941 | let pred = GenericPredicate::Implemented(trait_ref); | 940 | let pred = GenericPredicate::Implemented(trait_ref); |
@@ -1100,7 +1099,7 @@ fn type_for_enum_variant_constructor(db: &dyn HirDatabase, def: EnumVariantId) - | |||
1100 | fn type_for_adt(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> { | 1099 | fn type_for_adt(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> { |
1101 | let generics = generics(db.upcast(), adt.into()); | 1100 | let generics = generics(db.upcast(), adt.into()); |
1102 | let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); | 1101 | let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST); |
1103 | Binders::new(substs.len(), Ty::Adt(adt, substs)) | 1102 | Binders::new(substs.len(), Ty::adt_ty(adt, substs)) |
1104 | } | 1103 | } |
1105 | 1104 | ||
1106 | fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> { | 1105 | fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> { |
@@ -1131,8 +1130,8 @@ impl CallableDefId { | |||
1131 | let db = db.upcast(); | 1130 | let db = db.upcast(); |
1132 | match self { | 1131 | match self { |
1133 | CallableDefId::FunctionId(f) => f.lookup(db).module(db), | 1132 | CallableDefId::FunctionId(f) => f.lookup(db).module(db), |
1134 | CallableDefId::StructId(s) => s.lookup(db).container.module(db), | 1133 | CallableDefId::StructId(s) => s.lookup(db).container, |
1135 | CallableDefId::EnumVariantId(e) => e.parent.lookup(db).container.module(db), | 1134 | CallableDefId::EnumVariantId(e) => e.parent.lookup(db).container, |
1136 | } | 1135 | } |
1137 | .krate() | 1136 | .krate() |
1138 | } | 1137 | } |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index f301a8477..ccc12c075 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -8,8 +8,8 @@ use arrayvec::ArrayVec; | |||
8 | use base_db::CrateId; | 8 | use base_db::CrateId; |
9 | use chalk_ir::Mutability; | 9 | use chalk_ir::Mutability; |
10 | use hir_def::{ | 10 | use hir_def::{ |
11 | lang_item::LangItemTarget, AdtId, AssocContainerId, AssocItemId, FunctionId, GenericDefId, | 11 | lang_item::LangItemTarget, AssocContainerId, AssocItemId, FunctionId, GenericDefId, HasModule, |
12 | HasModule, ImplId, Lookup, ModuleId, TraitId, TypeAliasId, | 12 | ImplId, Lookup, ModuleId, TraitId, TypeAliasId, |
13 | }; | 13 | }; |
14 | use hir_expand::name::Name; | 14 | use hir_expand::name::Name; |
15 | use rustc_hash::{FxHashMap, FxHashSet}; | 15 | use rustc_hash::{FxHashMap, FxHashSet}; |
@@ -19,8 +19,8 @@ use crate::{ | |||
19 | db::HirDatabase, | 19 | db::HirDatabase, |
20 | primitive::{self, FloatTy, IntTy, UintTy}, | 20 | primitive::{self, FloatTy, IntTy, UintTy}, |
21 | utils::all_super_traits, | 21 | utils::all_super_traits, |
22 | Canonical, DebruijnIndex, FnPointer, FnSig, InEnvironment, Scalar, Substs, TraitEnvironment, | 22 | AdtId, Canonical, DebruijnIndex, FnPointer, FnSig, InEnvironment, Scalar, Substs, |
23 | TraitRef, Ty, TypeWalk, | 23 | TraitEnvironment, TraitRef, Ty, TypeWalk, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | /// This is used as a key for indexing impls. | 26 | /// This is used as a key for indexing impls. |
@@ -32,7 +32,7 @@ pub enum TyFingerprint { | |||
32 | Never, | 32 | Never, |
33 | RawPtr(Mutability), | 33 | RawPtr(Mutability), |
34 | Scalar(Scalar), | 34 | Scalar(Scalar), |
35 | Adt(AdtId), | 35 | Adt(hir_def::AdtId), |
36 | Dyn(TraitId), | 36 | Dyn(TraitId), |
37 | Tuple(usize), | 37 | Tuple(usize), |
38 | ForeignType(TypeAliasId), | 38 | ForeignType(TypeAliasId), |
@@ -50,7 +50,7 @@ impl TyFingerprint { | |||
50 | &Ty::Slice(..) => TyFingerprint::Slice, | 50 | &Ty::Slice(..) => TyFingerprint::Slice, |
51 | &Ty::Array(..) => TyFingerprint::Array, | 51 | &Ty::Array(..) => TyFingerprint::Array, |
52 | &Ty::Scalar(scalar) => TyFingerprint::Scalar(scalar), | 52 | &Ty::Scalar(scalar) => TyFingerprint::Scalar(scalar), |
53 | &Ty::Adt(adt, _) => TyFingerprint::Adt(adt), | 53 | &Ty::Adt(AdtId(adt), _) => TyFingerprint::Adt(adt), |
54 | &Ty::Tuple(cardinality, _) => TyFingerprint::Tuple(cardinality), | 54 | &Ty::Tuple(cardinality, _) => TyFingerprint::Tuple(cardinality), |
55 | &Ty::Raw(mutability, ..) => TyFingerprint::RawPtr(mutability), | 55 | &Ty::Raw(mutability, ..) => TyFingerprint::RawPtr(mutability), |
56 | &Ty::ForeignType(alias_id, ..) => TyFingerprint::ForeignType(alias_id), | 56 | &Ty::ForeignType(alias_id, ..) => TyFingerprint::ForeignType(alias_id), |
@@ -231,7 +231,7 @@ impl Ty { | |||
231 | let mod_to_crate_ids = |module: ModuleId| Some(std::iter::once(module.krate()).collect()); | 231 | let mod_to_crate_ids = |module: ModuleId| Some(std::iter::once(module.krate()).collect()); |
232 | 232 | ||
233 | let lang_item_targets = match self { | 233 | let lang_item_targets = match self { |
234 | Ty::Adt(def_id, _) => { | 234 | Ty::Adt(AdtId(def_id), _) => { |
235 | return mod_to_crate_ids(def_id.module(db.upcast())); | 235 | return mod_to_crate_ids(def_id.module(db.upcast())); |
236 | } | 236 | } |
237 | Ty::ForeignType(type_alias_id) => { | 237 | Ty::ForeignType(type_alias_id) => { |
@@ -267,7 +267,7 @@ impl Ty { | |||
267 | LangItemTarget::ImplDefId(it) => Some(it), | 267 | LangItemTarget::ImplDefId(it) => Some(it), |
268 | _ => None, | 268 | _ => None, |
269 | }) | 269 | }) |
270 | .map(|it| it.lookup(db.upcast()).container.module(db.upcast()).krate()) | 270 | .map(|it| it.lookup(db.upcast()).container.krate()) |
271 | .collect(); | 271 | .collect(); |
272 | Some(res) | 272 | Some(res) |
273 | } | 273 | } |
@@ -588,7 +588,7 @@ fn iterate_inherent_methods( | |||
588 | // already happens in `is_valid_candidate` above; if not, we | 588 | // already happens in `is_valid_candidate` above; if not, we |
589 | // check it here | 589 | // check it here |
590 | if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() { | 590 | if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() { |
591 | test_utils::mark::hit!(impl_self_type_match_without_receiver); | 591 | cov_mark::hit!(impl_self_type_match_without_receiver); |
592 | continue; | 592 | continue; |
593 | } | 593 | } |
594 | if callback(&self_ty.value, item) { | 594 | if callback(&self_ty.value, item) { |
@@ -715,7 +715,7 @@ fn transform_receiver_ty( | |||
715 | .fill_with_unknown() | 715 | .fill_with_unknown() |
716 | .build() | 716 | .build() |
717 | } | 717 | } |
718 | AssocContainerId::ContainerId(_) => unreachable!(), | 718 | AssocContainerId::ModuleId(_) => unreachable!(), |
719 | }; | 719 | }; |
720 | let sig = db.callable_item_signature(function_id.into()); | 720 | let sig = db.callable_item_signature(function_id.into()); |
721 | Some(sig.value.params()[0].clone().subst_bound_vars(&substs)) | 721 | Some(sig.value.params()[0].clone().subst_bound_vars(&substs)) |
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index 7386a4e7b..fc770ea60 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs | |||
@@ -13,7 +13,7 @@ use std::{env, sync::Arc}; | |||
13 | use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; | 13 | use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; |
14 | use expect_test::Expect; | 14 | use expect_test::Expect; |
15 | use hir_def::{ | 15 | use hir_def::{ |
16 | body::{BodySourceMap, SyntheticSyntax}, | 16 | body::{Body, BodySourceMap, SyntheticSyntax}, |
17 | child_by_source::ChildBySource, | 17 | child_by_source::ChildBySource, |
18 | db::DefDatabase, | 18 | db::DefDatabase, |
19 | item_scope::ItemScope, | 19 | item_scope::ItemScope, |
@@ -234,13 +234,13 @@ fn visit_module( | |||
234 | let def = it.into(); | 234 | let def = it.into(); |
235 | cb(def); | 235 | cb(def); |
236 | let body = db.body(def); | 236 | let body = db.body(def); |
237 | visit_scope(db, crate_def_map, &body.item_scope, cb); | 237 | visit_body(db, &body, cb); |
238 | } | 238 | } |
239 | AssocItemId::ConstId(it) => { | 239 | AssocItemId::ConstId(it) => { |
240 | let def = it.into(); | 240 | let def = it.into(); |
241 | cb(def); | 241 | cb(def); |
242 | let body = db.body(def); | 242 | let body = db.body(def); |
243 | visit_scope(db, crate_def_map, &body.item_scope, cb); | 243 | visit_body(db, &body, cb); |
244 | } | 244 | } |
245 | AssocItemId::TypeAliasId(_) => (), | 245 | AssocItemId::TypeAliasId(_) => (), |
246 | } | 246 | } |
@@ -259,19 +259,19 @@ fn visit_module( | |||
259 | let def = it.into(); | 259 | let def = it.into(); |
260 | cb(def); | 260 | cb(def); |
261 | let body = db.body(def); | 261 | let body = db.body(def); |
262 | visit_scope(db, crate_def_map, &body.item_scope, cb); | 262 | visit_body(db, &body, cb); |
263 | } | 263 | } |
264 | ModuleDefId::ConstId(it) => { | 264 | ModuleDefId::ConstId(it) => { |
265 | let def = it.into(); | 265 | let def = it.into(); |
266 | cb(def); | 266 | cb(def); |
267 | let body = db.body(def); | 267 | let body = db.body(def); |
268 | visit_scope(db, crate_def_map, &body.item_scope, cb); | 268 | visit_body(db, &body, cb); |
269 | } | 269 | } |
270 | ModuleDefId::StaticId(it) => { | 270 | ModuleDefId::StaticId(it) => { |
271 | let def = it.into(); | 271 | let def = it.into(); |
272 | cb(def); | 272 | cb(def); |
273 | let body = db.body(def); | 273 | let body = db.body(def); |
274 | visit_scope(db, crate_def_map, &body.item_scope, cb); | 274 | visit_body(db, &body, cb); |
275 | } | 275 | } |
276 | ModuleDefId::TraitId(it) => { | 276 | ModuleDefId::TraitId(it) => { |
277 | let trait_data = db.trait_data(it); | 277 | let trait_data = db.trait_data(it); |
@@ -288,6 +288,14 @@ fn visit_module( | |||
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | |||
292 | fn visit_body(db: &TestDB, body: &Body, cb: &mut dyn FnMut(DefWithBodyId)) { | ||
293 | for def_map in body.block_scopes.iter().filter_map(|block| db.block_def_map(*block)) { | ||
294 | for (mod_id, _) in def_map.modules() { | ||
295 | visit_module(db, &def_map, mod_id, cb); | ||
296 | } | ||
297 | } | ||
298 | } | ||
291 | } | 299 | } |
292 | 300 | ||
293 | fn ellipsize(mut text: String, max_len: usize) -> String { | 301 | fn ellipsize(mut text: String, max_len: usize) -> String { |
diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index 7bc6c79f3..63d9d4e0b 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use super::{check_infer, check_infer_with_mismatches}; | 3 | use super::{check_infer, check_infer_with_mismatches}; |
5 | 4 | ||
@@ -381,7 +380,7 @@ fn infer_match_second_coerce() { | |||
381 | 380 | ||
382 | #[test] | 381 | #[test] |
383 | fn coerce_merge_one_by_one1() { | 382 | fn coerce_merge_one_by_one1() { |
384 | mark::check!(coerce_merge_fail_fallback); | 383 | cov_mark::check!(coerce_merge_fail_fallback); |
385 | 384 | ||
386 | check_infer( | 385 | check_infer( |
387 | r" | 386 | r" |
@@ -589,7 +588,7 @@ fn coerce_fn_item_to_fn_ptr() { | |||
589 | 588 | ||
590 | #[test] | 589 | #[test] |
591 | fn coerce_fn_items_in_match_arms() { | 590 | fn coerce_fn_items_in_match_arms() { |
592 | mark::check!(coerce_fn_reification); | 591 | cov_mark::check!(coerce_fn_reification); |
593 | 592 | ||
594 | check_infer_with_mismatches( | 593 | check_infer_with_mismatches( |
595 | r" | 594 | r" |
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index a9901d7b8..4e3f9a9b6 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -913,7 +913,7 @@ fn test() { S2.into(); } | |||
913 | 913 | ||
914 | #[test] | 914 | #[test] |
915 | fn method_resolution_overloaded_method() { | 915 | fn method_resolution_overloaded_method() { |
916 | test_utils::mark::check!(impl_self_type_match_without_receiver); | 916 | cov_mark::check!(impl_self_type_match_without_receiver); |
917 | check_types( | 917 | check_types( |
918 | r#" | 918 | r#" |
919 | struct Wrapper<T>(T); | 919 | struct Wrapper<T>(T); |
diff --git a/crates/hir_ty/src/tests/patterns.rs b/crates/hir_ty/src/tests/patterns.rs index 2053d8f56..5da19ba5f 100644 --- a/crates/hir_ty/src/tests/patterns.rs +++ b/crates/hir_ty/src/tests/patterns.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use super::{check_infer, check_infer_with_mismatches}; | 3 | use super::{check_infer, check_infer_with_mismatches}; |
5 | 4 | ||
@@ -197,7 +196,7 @@ fn infer_pattern_match_ergonomics() { | |||
197 | 196 | ||
198 | #[test] | 197 | #[test] |
199 | fn infer_pattern_match_ergonomics_ref() { | 198 | fn infer_pattern_match_ergonomics_ref() { |
200 | mark::check!(match_ergonomics_ref); | 199 | cov_mark::check!(match_ergonomics_ref); |
201 | check_infer( | 200 | check_infer( |
202 | r#" | 201 | r#" |
203 | fn test() { | 202 | fn test() { |
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index cffe8630b..69314e245 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use super::{check_infer, check_types}; | 3 | use super::{check_infer, check_types}; |
5 | 4 | ||
@@ -87,8 +86,8 @@ fn bug_651() { | |||
87 | 86 | ||
88 | #[test] | 87 | #[test] |
89 | fn recursive_vars() { | 88 | fn recursive_vars() { |
90 | mark::check!(type_var_cycles_resolve_completely); | 89 | cov_mark::check!(type_var_cycles_resolve_completely); |
91 | mark::check!(type_var_cycles_resolve_as_possible); | 90 | cov_mark::check!(type_var_cycles_resolve_as_possible); |
92 | check_infer( | 91 | check_infer( |
93 | r#" | 92 | r#" |
94 | fn test() { | 93 | fn test() { |
@@ -166,7 +165,7 @@ fn infer_std_crash_1() { | |||
166 | 165 | ||
167 | #[test] | 166 | #[test] |
168 | fn infer_std_crash_2() { | 167 | fn infer_std_crash_2() { |
169 | mark::check!(type_var_resolves_to_int_var); | 168 | cov_mark::check!(type_var_resolves_to_int_var); |
170 | // caused "equating two type variables, ...", taken from std | 169 | // caused "equating two type variables, ...", taken from std |
171 | check_infer( | 170 | check_infer( |
172 | r#" | 171 | r#" |
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 2947857a5..f5069eba5 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use super::{check_infer, check_types}; | 3 | use super::{check_infer, check_types}; |
5 | 4 | ||
@@ -2314,7 +2313,7 @@ fn generic_default_depending_on_other_type_arg_forward() { | |||
2314 | 2313 | ||
2315 | #[test] | 2314 | #[test] |
2316 | fn infer_operator_overload() { | 2315 | fn infer_operator_overload() { |
2317 | mark::check!(infer_expr_inner_binary_operator_overload); | 2316 | cov_mark::check!(infer_expr_inner_binary_operator_overload); |
2318 | 2317 | ||
2319 | check_infer( | 2318 | check_infer( |
2320 | r#" | 2319 | r#" |
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 1298e5a88..e185b1c0a 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use expect_test::expect; | 1 | use expect_test::expect; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use super::{check_infer, check_infer_with_mismatches, check_types}; | 3 | use super::{check_infer, check_infer_with_mismatches, check_types}; |
5 | 4 | ||
@@ -319,7 +318,7 @@ fn infer_from_bound_2() { | |||
319 | 318 | ||
320 | #[test] | 319 | #[test] |
321 | fn trait_default_method_self_bound_implements_trait() { | 320 | fn trait_default_method_self_bound_implements_trait() { |
322 | mark::check!(trait_self_implements_self); | 321 | cov_mark::check!(trait_self_implements_self); |
323 | check_infer( | 322 | check_infer( |
324 | r#" | 323 | r#" |
325 | trait Trait { | 324 | trait Trait { |
@@ -1189,7 +1188,7 @@ fn impl_trait() { | |||
1189 | 1188 | ||
1190 | #[test] | 1189 | #[test] |
1191 | fn simple_return_pos_impl_trait() { | 1190 | fn simple_return_pos_impl_trait() { |
1192 | mark::check!(lower_rpit); | 1191 | cov_mark::check!(lower_rpit); |
1193 | check_infer( | 1192 | check_infer( |
1194 | r#" | 1193 | r#" |
1195 | trait Trait<T> { | 1194 | trait Trait<T> { |
@@ -3175,6 +3174,39 @@ fn f() { | |||
3175 | } | 3174 | } |
3176 | 3175 | ||
3177 | #[test] | 3176 | #[test] |
3177 | fn trait_in_scope_with_inner_item() { | ||
3178 | check_infer( | ||
3179 | r#" | ||
3180 | mod m { | ||
3181 | pub trait Tr { | ||
3182 | fn method(&self) -> u8 { 0 } | ||
3183 | } | ||
3184 | |||
3185 | impl Tr for () {} | ||
3186 | } | ||
3187 | |||
3188 | use m::Tr; | ||
3189 | |||
3190 | fn f() { | ||
3191 | fn inner() { | ||
3192 | ().method(); | ||
3193 | //^^^^^^^^^^^ u8 | ||
3194 | } | ||
3195 | } | ||
3196 | "#, | ||
3197 | expect![[r#" | ||
3198 | 46..50 'self': &Self | ||
3199 | 58..63 '{ 0 }': u8 | ||
3200 | 60..61 '0': u8 | ||
3201 | 115..185 '{ ... } }': () | ||
3202 | 132..183 '{ ... }': () | ||
3203 | 142..144 '()': () | ||
3204 | 142..153 '().method()': u8 | ||
3205 | "#]], | ||
3206 | ); | ||
3207 | } | ||
3208 | |||
3209 | #[test] | ||
3178 | fn inner_use_in_block() { | 3210 | fn inner_use_in_block() { |
3179 | check_types( | 3211 | check_types( |
3180 | r#" | 3212 | r#" |
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index e513fa8f4..565672b6b 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -315,9 +315,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
315 | let id = from_chalk(self.db, trait_id); | 315 | let id = from_chalk(self.db, trait_id); |
316 | self.db.trait_data(id).name.to_string() | 316 | self.db.trait_data(id).name.to_string() |
317 | } | 317 | } |
318 | fn adt_name(&self, adt_id: chalk_ir::AdtId<Interner>) -> String { | 318 | fn adt_name(&self, chalk_ir::AdtId(adt_id): AdtId) -> String { |
319 | let id = from_chalk(self.db, adt_id); | 319 | match adt_id { |
320 | match id { | ||
321 | hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(), | 320 | hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(), |
322 | hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(), | 321 | hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(), |
323 | hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(), | 322 | hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(), |
@@ -425,7 +424,7 @@ pub(crate) fn trait_datum_query( | |||
425 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 424 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
426 | let flags = rust_ir::TraitFlags { | 425 | let flags = rust_ir::TraitFlags { |
427 | auto: trait_data.auto, | 426 | auto: trait_data.auto, |
428 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate() != krate, | 427 | upstream: trait_.lookup(db.upcast()).container.krate() != krate, |
429 | non_enumerable: true, | 428 | non_enumerable: true, |
430 | coinductive: false, // only relevant for Chalk testing | 429 | coinductive: false, // only relevant for Chalk testing |
431 | // FIXME: set these flags correctly | 430 | // FIXME: set these flags correctly |
@@ -488,8 +487,8 @@ pub(crate) fn struct_datum_query( | |||
488 | struct_id: AdtId, | 487 | struct_id: AdtId, |
489 | ) -> Arc<StructDatum> { | 488 | ) -> Arc<StructDatum> { |
490 | debug!("struct_datum {:?}", struct_id); | 489 | debug!("struct_datum {:?}", struct_id); |
491 | let adt_id = from_chalk(db, struct_id); | 490 | let type_ctor = Ty::Adt(struct_id, Substs::empty()); |
492 | let type_ctor = Ty::Adt(adt_id, Substs::empty()); | 491 | let chalk_ir::AdtId(adt_id) = struct_id; |
493 | debug!("struct {:?} = {:?}", struct_id, type_ctor); | 492 | debug!("struct {:?} = {:?}", struct_id, type_ctor); |
494 | let num_params = generics(db.upcast(), adt_id.into()).len(); | 493 | let num_params = generics(db.upcast(), adt_id.into()).len(); |
495 | let upstream = adt_id.module(db.upcast()).krate() != krate; | 494 | let upstream = adt_id.module(db.upcast()).krate() != krate; |
@@ -549,7 +548,7 @@ fn impl_def_datum( | |||
549 | let generic_params = generics(db.upcast(), impl_id.into()); | 548 | let generic_params = generics(db.upcast(), impl_id.into()); |
550 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); | 549 | let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); |
551 | let trait_ = trait_ref.trait_; | 550 | let trait_ = trait_ref.trait_; |
552 | let impl_type = if impl_id.lookup(db.upcast()).container.module(db.upcast()).krate() == krate { | 551 | let impl_type = if impl_id.lookup(db.upcast()).container.krate() == krate { |
553 | rust_ir::ImplType::Local | 552 | rust_ir::ImplType::Local |
554 | } else { | 553 | } else { |
555 | rust_ir::ImplType::External | 554 | rust_ir::ImplType::External |
@@ -684,10 +683,9 @@ pub(crate) fn fn_def_variance_query( | |||
684 | pub(crate) fn adt_variance_query( | 683 | pub(crate) fn adt_variance_query( |
685 | db: &dyn HirDatabase, | 684 | db: &dyn HirDatabase, |
686 | _krate: CrateId, | 685 | _krate: CrateId, |
687 | adt_id: AdtId, | 686 | chalk_ir::AdtId(adt_id): AdtId, |
688 | ) -> Variances { | 687 | ) -> Variances { |
689 | let adt: crate::AdtId = from_chalk(db, adt_id); | 688 | let generic_params = generics(db.upcast(), adt_id.into()); |
690 | let generic_params = generics(db.upcast(), adt.into()); | ||
691 | Variances::from_iter( | 689 | Variances::from_iter( |
692 | &Interner, | 690 | &Interner, |
693 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), | 691 | std::iter::repeat(chalk_ir::Variance::Invariant).take(generic_params.len()), |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index db1760e6c..3a08b67e9 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -86,7 +86,7 @@ impl ToChalk for Ty { | |||
86 | 86 | ||
87 | Ty::Adt(adt_id, substs) => { | 87 | Ty::Adt(adt_id, substs) => { |
88 | let substitution = substs.to_chalk(db); | 88 | let substitution = substs.to_chalk(db); |
89 | chalk_ir::TyKind::Adt(chalk_ir::AdtId(adt_id), substitution).intern(&Interner) | 89 | chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) |
90 | } | 90 | } |
91 | Ty::Alias(AliasTy::Projection(proj_ty)) => { | 91 | Ty::Alias(AliasTy::Projection(proj_ty)) => { |
92 | let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db); | 92 | let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db); |
@@ -183,7 +183,7 @@ impl ToChalk for Ty { | |||
183 | Ty::Dyn(predicates) | 183 | Ty::Dyn(predicates) |
184 | } | 184 | } |
185 | 185 | ||
186 | chalk_ir::TyKind::Adt(struct_id, subst) => Ty::Adt(struct_id.0, from_chalk(db, subst)), | 186 | chalk_ir::TyKind::Adt(adt_id, subst) => Ty::Adt(adt_id, from_chalk(db, subst)), |
187 | chalk_ir::TyKind::AssociatedType(type_id, subst) => Ty::AssociatedType( | 187 | chalk_ir::TyKind::AssociatedType(type_id, subst) => Ty::AssociatedType( |
188 | from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0, | 188 | from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0, |
189 | from_chalk(db, subst), | 189 | from_chalk(db, subst), |
@@ -325,18 +325,6 @@ impl ToChalk for hir_def::ImplId { | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | impl ToChalk for hir_def::AdtId { | ||
329 | type Chalk = AdtId; | ||
330 | |||
331 | fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { | ||
332 | chalk_ir::AdtId(self.into()) | ||
333 | } | ||
334 | |||
335 | fn from_chalk(_db: &dyn HirDatabase, id: AdtId) -> Self { | ||
336 | id.0 | ||
337 | } | ||
338 | } | ||
339 | |||
340 | impl ToChalk for CallableDefId { | 328 | impl ToChalk for CallableDefId { |
341 | type Chalk = FnDefId; | 329 | type Chalk = FnDefId; |
342 | 330 | ||
diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index 65b79df0d..7351e4e54 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs | |||
@@ -259,6 +259,6 @@ fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option<Generic | |||
259 | match container { | 259 | match container { |
260 | AssocContainerId::ImplId(it) => Some(it.into()), | 260 | AssocContainerId::ImplId(it) => Some(it.into()), |
261 | AssocContainerId::TraitId(it) => Some(it.into()), | 261 | AssocContainerId::TraitId(it) => Some(it.into()), |
262 | AssocContainerId::ContainerId(_) => None, | 262 | AssocContainerId::ModuleId(_) => None, |
263 | } | 263 | } |
264 | } | 264 | } |