From 96113b7b8e3239b14768f009728f1dc094a4612f Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Wed, 10 May 2023 18:27:28 +0900 Subject: [PATCH] Remove prelude fallback path for Rust <1.52.0 We've already removed non-sysroot proc macro server, which effectively removed support for Rust <1.64.0, so this removal of fallback path shouldn't be problem at this point. --- crates/hir-def/src/nameres/collector.rs | 38 +++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs index 2c8205d14b..2d8870af9f 100644 --- a/crates/hir-def/src/nameres/collector.rs +++ b/crates/hir-def/src/nameres/collector.rs @@ -547,33 +547,21 @@ impl DefCollector<'_> { Edition::Edition2015 => PathKind::Plain, _ => PathKind::Abs, }; - let path = - ModPath::from_segments(path_kind, [krate.clone(), name![prelude], edition].into_iter()); - // Fall back to the older `std::prelude::v1` for compatibility with Rust <1.52.0 - // FIXME remove this fallback - let fallback_path = - ModPath::from_segments(path_kind, [krate, name![prelude], name![v1]].into_iter()); + let path = ModPath::from_segments(path_kind, [krate, name![prelude], edition]); - for path in &[path, fallback_path] { - let (per_ns, _) = self.def_map.resolve_path( - self.db, - self.def_map.root, - path, - BuiltinShadowMode::Other, - ); + let (per_ns, _) = + self.def_map.resolve_path(self.db, self.def_map.root, &path, BuiltinShadowMode::Other); - match per_ns.types { - Some((ModuleDefId::ModuleId(m), _)) => { - self.def_map.prelude = Some(m); - break; - } - types => { - tracing::debug!( - "could not resolve prelude path `{}` to module (resolved to {:?})", - path, - types - ); - } + match per_ns.types { + Some((ModuleDefId::ModuleId(m), _)) => { + self.def_map.prelude = Some(m); + } + types => { + tracing::debug!( + "could not resolve prelude path `{}` to module (resolved to {:?})", + path, + types + ); } } }