(path: &str, target: &Symbol)
| 333 | } |
| 334 | |
| 335 | fn candidate_path(path: &str, target: &Symbol) -> bool { |
| 336 | if path == target.location.path || target.public { |
| 337 | return true; |
| 338 | } |
| 339 | if Language::detect(&target.location.path) != Some(Language::Rust) { |
| 340 | return false; |
| 341 | } |
| 342 | let file = std::path::Path::new(&target.location.path); |
| 343 | let mut region = file |
| 344 | .parent() |
| 345 | .unwrap_or_else(|| std::path::Path::new("")) |
| 346 | .to_path_buf(); |
| 347 | if !matches!( |
| 348 | file.file_name().and_then(|name| name.to_str()), |
| 349 | Some("lib.rs" | "main.rs" | "mod.rs") |
| 350 | ) { |
| 351 | region.push(file.file_stem().unwrap_or_default()); |
| 352 | } |
| 353 | for module in &target.module_scope { |
| 354 | region.push(module); |
| 355 | } |
| 356 | if target.parent_visible { |
| 357 | region.pop(); |
| 358 | } |
| 359 | std::path::Path::new(path).starts_with(region) |
| 360 | } |
no test coverage detected