Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/semantics.rs')
| -rw-r--r-- | crates/hir/src/semantics.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index f51fe80931..fdb94a6d5a 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -433,7 +433,7 @@ impl<'db> SemanticsImpl<'db> { .find_map(|token| { self.resolve_offset_in_format_args( ast::String::cast(token)?, - offset - quote.end(), + offset.checked_sub(quote.end())?, ) }) .map(|(range, res)| (range + quote.end(), res)); @@ -659,10 +659,8 @@ impl<'db> SemanticsImpl<'db> { // First expand into attribute invocations let containing_attribute_macro_call = self.with_ctx(|ctx| { token.parent_ancestors().filter_map(ast::Item::cast).find_map(|item| { - if item.attrs().next().is_none() { - // Don't force populate the dyn cache for items that don't have an attribute anyways - return None; - } + // Don't force populate the dyn cache for items that don't have an attribute anyways + item.attrs().next()?; Some(( ctx.item_to_macro_call(InFile::new(file_id, item.clone()))?, item, @@ -1008,9 +1006,7 @@ impl<'db> SemanticsImpl<'db> { // Update `source_ty` for the next adjustment let source = mem::replace(&mut source_ty, target.clone()); - let adjustment = Adjustment { source, target, kind }; - - adjustment + Adjustment { source, target, kind } }) .collect() }) @@ -1255,7 +1251,7 @@ impl<'db> SemanticsImpl<'db> { assert!(root_node.parent().is_none()); let mut cache = self.cache.borrow_mut(); let prev = cache.insert(root_node, file_id); - assert!(prev == None || prev == Some(file_id)) + assert!(prev.is_none() || prev == Some(file_id)) } pub fn assert_contains_node(&self, node: &SyntaxNode) { |