Skip to content

Commit 6039c49

Browse files
committed
imperitivize
1 parent e2aaf38 commit 6039c49

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::ops::Not;
2-
31
use rustc_ast::expand::StrippedCfgItem;
42
use rustc_ast::ptr::P;
53
use rustc_ast::visit::{self, Visitor};
@@ -2472,30 +2470,29 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24722470
// FIXME: add case where non parent using undeclared module (hard?)
24732471
let dir = src.parent()?;
24742472
let src = src.file_stem()?.to_str()?;
2475-
[
2473+
for file in [
24762474
// …/x.rs
24772475
dir.join(i).with_extension("rs"),
24782476
// …/x/mod.rs
24792477
dir.join(i).join("mod.rs"),
2480-
]
2481-
.iter()
2482-
.chain(
2483-
// in …/x.rs
2484-
matches!(src, "main" | "lib" | "mod")
2485-
.not()
2486-
.then(|| {
2487-
[
2488-
// …/x/y.rs
2489-
dir.join(src).join(i).with_extension("rs"),
2490-
// …/x/y/mod.rs
2491-
dir.join(src).join(i).join("mod.rs"),
2492-
]
2493-
})
2494-
.iter()
2495-
.flatten(),
2496-
)
2497-
.find(|x| x.exists())
2498-
.cloned()
2478+
] {
2479+
if file.exists() {
2480+
return Some(file);
2481+
}
2482+
}
2483+
if !matches!(src, "main" | "lib" | "mod") {
2484+
for file in [
2485+
// …/x/y.rs
2486+
dir.join(src).join(i).with_extension("rs"),
2487+
// …/x/y/mod.rs
2488+
dir.join(src).join(i).join("mod.rs"),
2489+
] {
2490+
if file.exists() {
2491+
return Some(file);
2492+
}
2493+
}
2494+
}
2495+
None
24992496
}
25002497

25012498
/// Adds suggestions for a path that cannot be resolved.

0 commit comments

Comments
 (0)