mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 09:36:06 +00:00
Merge #9102
9102: minor: Fall back to legacy prelude r=jonas-schievink a=jonas-schievink should fix https://github.com/rust-analyzer/rust-analyzer/issues/9101 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
dbdfeeeff9
@ -486,22 +486,35 @@ impl DefCollector<'_> {
|
||||
} else {
|
||||
PathKind::Abs
|
||||
};
|
||||
let path =
|
||||
ModPath::from_segments(path_kind, [krate, name![prelude], edition].iter().cloned());
|
||||
let path = ModPath::from_segments(
|
||||
path_kind.clone(),
|
||||
[krate.clone(), name![prelude], edition].iter().cloned(),
|
||||
);
|
||||
// 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]].iter().cloned());
|
||||
|
||||
let (per_ns, _) =
|
||||
self.def_map.resolve_path(self.db, self.def_map.root, &path, BuiltinShadowMode::Other);
|
||||
for path in &[path, fallback_path] {
|
||||
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);
|
||||
}
|
||||
_ => {
|
||||
log::error!(
|
||||
"could not resolve prelude path `{}` to module (resolved to {:?})",
|
||||
path,
|
||||
per_ns.types
|
||||
);
|
||||
match &per_ns.types {
|
||||
Some((ModuleDefId::ModuleId(m), _)) => {
|
||||
self.def_map.prelude = Some(*m);
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
log::debug!(
|
||||
"could not resolve prelude path `{}` to module (resolved to {:?})",
|
||||
path,
|
||||
per_ns.types
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ pub mod known {
|
||||
rust_2015,
|
||||
rust_2018,
|
||||
rust_2021,
|
||||
v1,
|
||||
// Components of known path (type name)
|
||||
Iterator,
|
||||
IntoIterator,
|
||||
|
Loading…
Reference in New Issue
Block a user