diff options
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | crates/hir/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/hir_ty/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/display.rs | 33 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 3 | ||||
-rw-r--r-- | crates/hir_ty/src/traits.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 4 | ||||
-rw-r--r-- | crates/syntax/Cargo.toml | 2 |
9 files changed, 35 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock index 05383d8b7..e40c12a92 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -49,9 +49,9 @@ checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" | |||
49 | 49 | ||
50 | [[package]] | 50 | [[package]] |
51 | name = "arrayvec" | 51 | name = "arrayvec" |
52 | version = "0.6.1" | 52 | version = "0.7.0" |
53 | source = "registry+https://github.com/rust-lang/crates.io-index" | 53 | source = "registry+https://github.com/rust-lang/crates.io-index" |
54 | checksum = "269d0f5e68353a7cab87f81e7c736adc008d279a36ebc6a05dfe01193a89f0c9" | 54 | checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7" |
55 | 55 | ||
56 | [[package]] | 56 | [[package]] |
57 | name = "atty" | 57 | name = "atty" |
diff --git a/crates/hir/Cargo.toml b/crates/hir/Cargo.toml index 2ef5bcbc9..9e329656f 100644 --- a/crates/hir/Cargo.toml +++ b/crates/hir/Cargo.toml | |||
@@ -13,7 +13,7 @@ doctest = false | |||
13 | log = "0.4.8" | 13 | log = "0.4.8" |
14 | rustc-hash = "1.1.0" | 14 | rustc-hash = "1.1.0" |
15 | either = "1.5.3" | 15 | either = "1.5.3" |
16 | arrayvec = "0.6" | 16 | arrayvec = "0.7" |
17 | itertools = "0.10.0" | 17 | itertools = "0.10.0" |
18 | smallvec = "1.4.0" | 18 | smallvec = "1.4.0" |
19 | 19 | ||
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index 030b7eebe..abc0e7532 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml | |||
@@ -12,7 +12,7 @@ doctest = false | |||
12 | [dependencies] | 12 | [dependencies] |
13 | cov-mark = { version = "1.1", features = ["thread-local"] } | 13 | cov-mark = { version = "1.1", features = ["thread-local"] } |
14 | itertools = "0.10.0" | 14 | itertools = "0.10.0" |
15 | arrayvec = "0.6" | 15 | arrayvec = "0.7" |
16 | smallvec = "1.2.0" | 16 | smallvec = "1.2.0" |
17 | ena = "0.14.0" | 17 | ena = "0.14.0" |
18 | log = "0.4.8" | 18 | log = "0.4.8" |
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 5ff70c893..1108e5a10 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -251,7 +251,7 @@ impl HirDisplay for ProjectionTy { | |||
251 | } | 251 | } |
252 | 252 | ||
253 | let trait_ = f.db.trait_data(self.trait_(f.db)); | 253 | let trait_ = f.db.trait_data(self.trait_(f.db)); |
254 | let first_parameter = self.self_type_parameter().into_displayable( | 254 | let first_parameter = self.self_type_parameter(&Interner).into_displayable( |
255 | f.db, | 255 | f.db, |
256 | f.max_size, | 256 | f.max_size, |
257 | f.omit_verbose_types, | 257 | f.omit_verbose_types, |
@@ -592,20 +592,21 @@ impl HirDisplay for Ty { | |||
592 | } | 592 | } |
593 | TypeParamProvenance::ArgumentImplTrait => { | 593 | TypeParamProvenance::ArgumentImplTrait => { |
594 | let substs = generics.type_params_subst(f.db); | 594 | let substs = generics.type_params_subst(f.db); |
595 | let bounds = f | 595 | let bounds = |
596 | .db | 596 | f.db.generic_predicates(id.parent) |
597 | .generic_predicates(id.parent) | 597 | .into_iter() |
598 | .into_iter() | 598 | .map(|pred| pred.clone().subst(&substs)) |
599 | .map(|pred| pred.clone().subst(&substs)) | 599 | .filter(|wc| match &wc.skip_binders() { |
600 | .filter(|wc| match &wc.skip_binders() { | 600 | WhereClause::Implemented(tr) => { |
601 | WhereClause::Implemented(tr) => tr.self_type_parameter() == self, | 601 | tr.self_type_parameter(&Interner) == self |
602 | WhereClause::AliasEq(AliasEq { | 602 | } |
603 | alias: AliasTy::Projection(proj), | 603 | WhereClause::AliasEq(AliasEq { |
604 | ty: _, | 604 | alias: AliasTy::Projection(proj), |
605 | }) => proj.self_type_parameter() == self, | 605 | ty: _, |
606 | _ => false, | 606 | }) => proj.self_type_parameter(&Interner) == self, |
607 | }) | 607 | _ => false, |
608 | .collect::<Vec<_>>(); | 608 | }) |
609 | .collect::<Vec<_>>(); | ||
609 | write_bounds_like_dyn_trait_with_prefix("impl", &bounds, f)?; | 610 | write_bounds_like_dyn_trait_with_prefix("impl", &bounds, f)?; |
610 | } | 611 | } |
611 | } | 612 | } |
@@ -780,7 +781,7 @@ impl TraitRef { | |||
780 | return write!(f, "{}", TYPE_HINT_TRUNCATION); | 781 | return write!(f, "{}", TYPE_HINT_TRUNCATION); |
781 | } | 782 | } |
782 | 783 | ||
783 | self.self_type_parameter().hir_fmt(f)?; | 784 | self.self_type_parameter(&Interner).hir_fmt(f)?; |
784 | if use_as { | 785 | if use_as { |
785 | write!(f, " as ")?; | 786 | write!(f, " as ")?; |
786 | } else { | 787 | } else { |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index d1513df1f..adfdcaa37 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -78,8 +78,8 @@ impl ProjectionTy { | |||
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | pub fn self_type_parameter(&self) -> &Ty { | 81 | pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { |
82 | &self.substitution.interned()[0].assert_ty_ref(&Interner) | 82 | &self.substitution.interned()[0].assert_ty_ref(interner) |
83 | } | 83 | } |
84 | 84 | ||
85 | fn trait_(&self, db: &dyn HirDatabase) -> TraitId { | 85 | fn trait_(&self, db: &dyn HirDatabase) -> TraitId { |
@@ -165,8 +165,8 @@ impl<T: TypeWalk> Binders<T> { | |||
165 | } | 165 | } |
166 | 166 | ||
167 | impl TraitRef { | 167 | impl TraitRef { |
168 | pub fn self_type_parameter(&self) -> &Ty { | 168 | pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { |
169 | &self.substitution.at(&Interner, 0).assert_ty_ref(&Interner) | 169 | &self.substitution.at(interner, 0).assert_ty_ref(interner) |
170 | } | 170 | } |
171 | 171 | ||
172 | pub fn hir_trait_id(&self) -> TraitId { | 172 | pub fn hir_trait_id(&self) -> TraitId { |
@@ -473,11 +473,13 @@ impl Ty { | |||
473 | .into_iter() | 473 | .into_iter() |
474 | .map(|pred| pred.clone().subst(&substs)) | 474 | .map(|pred| pred.clone().subst(&substs)) |
475 | .filter(|wc| match &wc.skip_binders() { | 475 | .filter(|wc| match &wc.skip_binders() { |
476 | WhereClause::Implemented(tr) => tr.self_type_parameter() == self, | 476 | WhereClause::Implemented(tr) => { |
477 | tr.self_type_parameter(&Interner) == self | ||
478 | } | ||
477 | WhereClause::AliasEq(AliasEq { | 479 | WhereClause::AliasEq(AliasEq { |
478 | alias: AliasTy::Projection(proj), | 480 | alias: AliasTy::Projection(proj), |
479 | ty: _, | 481 | ty: _, |
480 | }) => proj.self_type_parameter() == self, | 482 | }) => proj.self_type_parameter(&Interner) == self, |
481 | _ => false, | 483 | _ => false, |
482 | }) | 484 | }) |
483 | .collect_vec(); | 485 | .collect_vec(); |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index ba48be4ad..e9e4e69ad 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -941,7 +941,8 @@ pub(crate) fn trait_environment_query( | |||
941 | for pred in resolver.where_predicates_in_scope() { | 941 | for pred in resolver.where_predicates_in_scope() { |
942 | for pred in ctx.lower_where_predicate(pred, false) { | 942 | for pred in ctx.lower_where_predicate(pred, false) { |
943 | if let WhereClause::Implemented(tr) = &pred.skip_binders() { | 943 | if let WhereClause::Implemented(tr) = &pred.skip_binders() { |
944 | traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id())); | 944 | traits_in_scope |
945 | .push((tr.self_type_parameter(&Interner).clone(), tr.hir_trait_id())); | ||
945 | } | 946 | } |
946 | let program_clause: chalk_ir::ProgramClause<Interner> = | 947 | let program_clause: chalk_ir::ProgramClause<Interner> = |
947 | pred.clone().to_chalk(db).cast(&Interner); | 948 | pred.clone().to_chalk(db).cast(&Interner); |
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 66d600bfc..c8883485c 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs | |||
@@ -89,7 +89,7 @@ pub(crate) fn trait_solve_query( | |||
89 | .. | 89 | .. |
90 | })) = &goal.value.goal | 90 | })) = &goal.value.goal |
91 | { | 91 | { |
92 | if let TyKind::BoundVar(_) = projection_ty.self_type_parameter().kind(&Interner) { | 92 | if let TyKind::BoundVar(_) = projection_ty.self_type_parameter(&Interner).kind(&Interner) { |
93 | // Hack: don't ask Chalk to normalize with an unknown self type, it'll say that's impossible | 93 | // Hack: don't ask Chalk to normalize with an unknown self type, it'll say that's impossible |
94 | return Some(Solution::Ambig(Guidance::Unknown)); | 94 | return Some(Solution::Ambig(Guidance::Unknown)); |
95 | } | 95 | } |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 59aaa5560..67e88ebf4 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -539,7 +539,7 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
539 | let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE); | 539 | let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE); |
540 | match &pred.value { | 540 | match &pred.value { |
541 | WhereClause::Implemented(trait_ref) => { | 541 | WhereClause::Implemented(trait_ref) => { |
542 | if trait_ref.self_type_parameter() != &self_ty_shifted_in { | 542 | if trait_ref.self_type_parameter(&Interner) != &self_ty_shifted_in { |
543 | // we can only convert predicates back to type bounds if they | 543 | // we can only convert predicates back to type bounds if they |
544 | // have the expected self type | 544 | // have the expected self type |
545 | return None; | 545 | return None; |
@@ -552,7 +552,7 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
552 | Some(make_binders(rust_ir::InlineBound::TraitBound(trait_bound), pred.num_binders)) | 552 | Some(make_binders(rust_ir::InlineBound::TraitBound(trait_bound), pred.num_binders)) |
553 | } | 553 | } |
554 | WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { | 554 | WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { |
555 | if projection_ty.self_type_parameter() != &self_ty_shifted_in { | 555 | if projection_ty.self_type_parameter(&Interner) != &self_ty_shifted_in { |
556 | return None; | 556 | return None; |
557 | } | 557 | } |
558 | let trait_ = projection_ty.trait_(db); | 558 | let trait_ = projection_ty.trait_(db); |
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 9f01acc26..10024366e 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -16,7 +16,7 @@ itertools = "0.10.0" | |||
16 | rowan = "0.13.0-pre.3" | 16 | rowan = "0.13.0-pre.3" |
17 | rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" } | 17 | rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" } |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | arrayvec = "0.6" | 19 | arrayvec = "0.7" |
20 | once_cell = "1.3.1" | 20 | once_cell = "1.3.1" |
21 | indexmap = "1.4.0" | 21 | indexmap = "1.4.0" |
22 | smol_str = { version = "0.1.15", features = ["serde"] } | 22 | smol_str = { version = "0.1.15", features = ["serde"] } |