diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-14 20:44:59 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-14 20:44:59 +0100 |
commit | 447d849c9ecb3d0f7783a56db429ccc526d0d8dc (patch) | |
tree | b6325f21f742f55d225caebad4d5ac057f683855 /crates/hir_def | |
parent | ce8fdf3ab05b59b517dee985e4b3828c6e373a91 (diff) | |
parent | c2015e7d182f3cb2cebe686127dd6a3e683df9e6 (diff) |
Merge #9277
9277: internal: more natural order of sources for TypeParam r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/generics.rs | 10 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 6933f6e3c..0f04b2bae 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs | |||
@@ -92,7 +92,7 @@ pub enum WherePredicateTypeTarget { | |||
92 | 92 | ||
93 | #[derive(Default)] | 93 | #[derive(Default)] |
94 | pub(crate) struct SourceMap { | 94 | pub(crate) struct SourceMap { |
95 | pub(crate) type_params: ArenaMap<LocalTypeParamId, Either<ast::Trait, ast::TypeParam>>, | 95 | pub(crate) type_params: ArenaMap<LocalTypeParamId, Either<ast::TypeParam, ast::Trait>>, |
96 | lifetime_params: ArenaMap<LocalLifetimeParamId, ast::LifetimeParam>, | 96 | lifetime_params: ArenaMap<LocalLifetimeParamId, ast::LifetimeParam>, |
97 | const_params: ArenaMap<LocalConstParamId, ast::ConstParam>, | 97 | const_params: ArenaMap<LocalConstParamId, ast::ConstParam>, |
98 | } | 98 | } |
@@ -199,7 +199,7 @@ impl GenericParams { | |||
199 | default: None, | 199 | default: None, |
200 | provenance: TypeParamProvenance::TraitSelf, | 200 | provenance: TypeParamProvenance::TraitSelf, |
201 | }); | 201 | }); |
202 | sm.type_params.insert(self_param_id, Either::Left(src.value.clone())); | 202 | sm.type_params.insert(self_param_id, Either::Right(src.value.clone())); |
203 | // add super traits as bounds on Self | 203 | // add super traits as bounds on Self |
204 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar | 204 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar |
205 | let self_param = TypeRef::Path(name![Self].into()); | 205 | let self_param = TypeRef::Path(name![Self].into()); |
@@ -277,7 +277,7 @@ impl GenericParams { | |||
277 | provenance: TypeParamProvenance::TypeParamList, | 277 | provenance: TypeParamProvenance::TypeParamList, |
278 | }; | 278 | }; |
279 | let param_id = self.types.alloc(param); | 279 | let param_id = self.types.alloc(param); |
280 | sm.type_params.insert(param_id, Either::Right(type_param.clone())); | 280 | sm.type_params.insert(param_id, Either::Left(type_param.clone())); |
281 | 281 | ||
282 | let type_ref = TypeRef::Path(name.into()); | 282 | let type_ref = TypeRef::Path(name.into()); |
283 | self.fill_bounds(lower_ctx, &type_param, Either::Left(type_ref)); | 283 | self.fill_bounds(lower_ctx, &type_param, Either::Left(type_ref)); |
@@ -413,7 +413,7 @@ impl GenericParams { | |||
413 | } | 413 | } |
414 | 414 | ||
415 | impl HasChildSource<LocalTypeParamId> for GenericDefId { | 415 | impl HasChildSource<LocalTypeParamId> for GenericDefId { |
416 | type Value = Either<ast::Trait, ast::TypeParam>; | 416 | type Value = Either<ast::TypeParam, ast::Trait>; |
417 | fn child_source( | 417 | fn child_source( |
418 | &self, | 418 | &self, |
419 | db: &dyn DefDatabase, | 419 | db: &dyn DefDatabase, |
@@ -449,7 +449,7 @@ impl ChildBySource for GenericDefId { | |||
449 | let sm = sm.as_ref(); | 449 | let sm = sm.as_ref(); |
450 | for (local_id, src) in sm.value.type_params.iter() { | 450 | for (local_id, src) in sm.value.type_params.iter() { |
451 | let id = TypeParamId { parent: *self, local_id }; | 451 | let id = TypeParamId { parent: *self, local_id }; |
452 | if let Either::Right(type_param) = src { | 452 | if let Either::Left(type_param) = src { |
453 | res[keys::TYPE_PARAM].insert(sm.with_value(type_param.clone()), id) | 453 | res[keys::TYPE_PARAM].insert(sm.with_value(type_param.clone()), id) |
454 | } | 454 | } |
455 | } | 455 | } |
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 3f90bda74..5b1386406 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -674,7 +674,7 @@ impl<'a> Ctx<'a> { | |||
674 | default: None, | 674 | default: None, |
675 | provenance: TypeParamProvenance::TraitSelf, | 675 | provenance: TypeParamProvenance::TraitSelf, |
676 | }); | 676 | }); |
677 | sm.type_params.insert(self_param_id, Either::Left(trait_def.clone())); | 677 | sm.type_params.insert(self_param_id, Either::Right(trait_def.clone())); |
678 | // add super traits as bounds on Self | 678 | // add super traits as bounds on Self |
679 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar | 679 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar |
680 | let self_param = TypeRef::Path(name![Self].into()); | 680 | let self_param = TypeRef::Path(name![Self].into()); |