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.
This commit is contained in:
Ryo Yoshida 2023-05-10 18:27:28 +09:00
parent 34a9129333
commit 96113b7b8e
No known key found for this signature in database
GPG key ID: E25698A930586171

View file

@ -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
);
}
}
}