Skip to content

Commit b7cfb30

Browse files
committed
pr comments
1 parent de00776 commit b7cfb30

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

crates/ide/src/runnables.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
208208
// |===
209209
pub(crate) fn selected_test(db: &RootDatabase, position: FilePosition) -> Option<Runnable> {
210210
let sema = Semantics::new(db);
211-
let syntax = sema.parse(position.file_id).syntax().clone();
211+
let parsed = sema.parse(position.file_id);
212+
let syntax = parsed.syntax();
213+
212214
return find_selected_test(&sema, &syntax, position);
213215
}
214216

@@ -219,11 +221,11 @@ fn find_selected_test(
219221
) -> Option<Runnable> {
220222
syntax
221223
.token_at_offset(position.offset)
222-
.find(|_| true)
224+
.next()
223225
.and_then(|token| token.parent())
224226
.and_then(|node| {
225227
node.ancestors().find_map(|ancestor| {
226-
let fn_def = ast::Fn::cast(ancestor.clone())?;
228+
let fn_def = ast::Fn::cast(ancestor)?;
227229
test_related_attribute(&fn_def)?;
228230
as_test_runnable(sema, &fn_def)
229231
})
@@ -249,7 +251,8 @@ pub(crate) fn related_tests(
249251
) -> Vec<Runnable> {
250252
let sema = Semantics::new(db);
251253
let mut res: FxHashSet<Runnable> = FxHashSet::default();
252-
let syntax = sema.parse(position.file_id).syntax().clone();
254+
let parsed = sema.parse(position.file_id);
255+
let syntax = parsed.syntax();
253256

254257
find_related_tests(&sema, &syntax, position, search_scope, &mut res);
255258

0 commit comments

Comments
 (0)