aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/nameres/collector.rs41
1 files changed, 27 insertions, 14 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 598424305..6b41921ae 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -486,22 +486,35 @@ impl DefCollector<'_> {
486 } else { 486 } else {
487 PathKind::Abs 487 PathKind::Abs
488 }; 488 };
489 let path = 489 let path = ModPath::from_segments(
490 ModPath::from_segments(path_kind, [krate, name![prelude], edition].iter().cloned()); 490 path_kind.clone(),
491 [krate.clone(), name![prelude], edition].iter().cloned(),
492 );
493 // Fall back to the older `std::prelude::v1` for compatibility with Rust <1.52.0
494 // FIXME remove this fallback
495 let fallback_path =
496 ModPath::from_segments(path_kind, [krate, name![prelude], name![v1]].iter().cloned());
491 497
492 let (per_ns, _) = 498 for path in &[path, fallback_path] {
493 self.def_map.resolve_path(self.db, self.def_map.root, &path, BuiltinShadowMode::Other); 499 let (per_ns, _) = self.def_map.resolve_path(
500 self.db,
501 self.def_map.root,
502 &path,
503 BuiltinShadowMode::Other,
504 );
494 505
495 match &per_ns.types { 506 match &per_ns.types {
496 Some((ModuleDefId::ModuleId(m), _)) => { 507 Some((ModuleDefId::ModuleId(m), _)) => {
497 self.def_map.prelude = Some(*m); 508 self.def_map.prelude = Some(*m);
498 } 509 return;
499 _ => { 510 }
500 log::error!( 511 _ => {
501 "could not resolve prelude path `{}` to module (resolved to {:?})", 512 log::debug!(
502 path, 513 "could not resolve prelude path `{}` to module (resolved to {:?})",
503 per_ns.types 514 path,
504 ); 515 per_ns.types
516 );
517 }
505 } 518 }
506 } 519 }
507 } 520 }