From 61fd6c6270f9ebc37f4156ae1a4d41053a78cdb1 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 27 Feb 2020 10:06:48 +0800 Subject: Use text_range::extend_to --- crates/ra_hir/src/semantics.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 5b0b94e34..c3d8ee1ae 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -388,7 +388,7 @@ fn original_range_and_origin( let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; - return Some(node.value.descendants().find_map(|it| { + Some(node.value.descendants().find_map(|it| { let first = skip_trivia_token(it.first_token()?, Direction::Next)?; let last = skip_trivia_token(it.last_token()?, Direction::Prev)?; @@ -404,16 +404,9 @@ fn original_range_and_origin( return None; } - // FIXME: Add union method in TextRange Some(( - first.with_value(union_range(first.value.text_range(), last.value.text_range())), + first.with_value(first.value.text_range().extend_to(&last.value.text_range())), first_origin, )) - })?); - - fn union_range(a: TextRange, b: TextRange) -> TextRange { - let start = a.start().min(b.start()); - let end = a.end().max(b.end()); - TextRange::from_to(start, end) - } + })?) } -- cgit v1.2.3