diff options
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 6 | ||||
-rw-r--r-- | crates/hir_def/src/path/lower.rs | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 8d3862811..124dcc866 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -174,6 +174,12 @@ impl Ctx { | |||
174 | let forced_vis = self.forced_visibility.take(); | 174 | let forced_vis = self.forced_visibility.take(); |
175 | 175 | ||
176 | let mut block_stack = Vec::new(); | 176 | let mut block_stack = Vec::new(); |
177 | |||
178 | // if container itself is block, add it to the stack | ||
179 | if let Some(block) = ast::BlockExpr::cast(container.clone()) { | ||
180 | block_stack.push(self.source_ast_id_map.ast_id(&block)); | ||
181 | } | ||
182 | |||
177 | for event in container.preorder().skip(1) { | 183 | for event in container.preorder().skip(1) { |
178 | match event { | 184 | match event { |
179 | WalkEvent::Enter(node) => { | 185 | WalkEvent::Enter(node) => { |
diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs index 505493a74..4de951fd3 100644 --- a/crates/hir_def/src/path/lower.rs +++ b/crates/hir_def/src/path/lower.rs | |||
@@ -74,6 +74,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> | |||
74 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo | 74 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo |
75 | Some(trait_ref) => { | 75 | Some(trait_ref) => { |
76 | let path = Path::from_src(trait_ref.path()?, hygiene)?; | 76 | let path = Path::from_src(trait_ref.path()?, hygiene)?; |
77 | let num_segments = path.mod_path.segments.len(); | ||
77 | kind = path.mod_path.kind; | 78 | kind = path.mod_path.kind; |
78 | 79 | ||
79 | let mut prefix_segments = path.mod_path.segments; | 80 | let mut prefix_segments = path.mod_path.segments; |
@@ -85,7 +86,8 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path> | |||
85 | generic_args.extend(prefix_args); | 86 | generic_args.extend(prefix_args); |
86 | 87 | ||
87 | // Insert the type reference (T in the above example) as Self parameter for the trait | 88 | // Insert the type reference (T in the above example) as Self parameter for the trait |
88 | let last_segment = generic_args.last_mut()?; | 89 | let last_segment = |
90 | generic_args.iter_mut().rev().nth(num_segments.saturating_sub(1))?; | ||
89 | if last_segment.is_none() { | 91 | if last_segment.is_none() { |
90 | *last_segment = Some(Arc::new(GenericArgs::empty())); | 92 | *last_segment = Some(Arc::new(GenericArgs::empty())); |
91 | }; | 93 | }; |