Skip to content

Commit 9189988

Browse files
alanzfacebook-github-bot
authored andcommitted
filter common_test::exportable_test_ranges by file_id
Summary: We are seeing panics from ranges beyond the end of a file from the `exportable_test_ranges`. This can only be if the definition in question does not originate in the current file. So filter out ones not in the current file. This allows us to remove `clamp_range` introduced in D69457800 Reviewed By: robertoaloi Differential Revision: D69467231 fbshipit-source-id: 31f6f4eff15e2bb25f7bf6c8d793598c0ecf3e9c
1 parent ba4a99f commit 9189988

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

crates/ide/src/common_test.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ use hir::FunctionDef;
4343
use hir::Name;
4444
use hir::NameArity;
4545
use hir::Semantic;
46-
use itertools::Itertools;
4746
use lazy_static::lazy_static;
4847

4948
use crate::diagnostics::Diagnostic;
@@ -77,10 +76,6 @@ pub fn unreachable_test(
7776
testcases: &Option<FxHashSet<NameArity>>,
7877
) {
7978
let exported_test_ranges = exported_test_ranges(sema, file_id);
80-
let exported_test_ranges = exported_test_ranges
81-
.iter()
82-
.map(|(n, r)| (n, sema.db.clamp_range(file_id, *r)))
83-
.collect_vec();
8479
if let Some(runnable_names) = testcases {
8580
for (name, range) in exported_test_ranges {
8681
if !runnable_names.contains(&name) {
@@ -143,7 +138,7 @@ pub fn runnable_names(
143138

144139
fn exported_test_ranges(sema: &Semantic, file_id: FileId) -> FxHashMap<NameArity, TextRange> {
145140
let mut res = FxHashMap::default();
146-
let def_map = sema.db.def_map(file_id);
141+
let def_map = sema.db.def_map_local(file_id);
147142
let functions = def_map.get_functions();
148143
let excludes = sema.resolve_implemented_callbacks(file_id);
149144
for (name_arity, def) in functions {

0 commit comments

Comments
 (0)