Skip to content

Commit

Permalink
Auto merge of #16347 - Veykril:find-path, r=Veykril
Browse files Browse the repository at this point in the history
internal: Consider all kinds of explicit private imports in find_path

Builds on top of #16265 to make things a bit more general, now we consider all explicit private imports.
  • Loading branch information
bors committed Jan 11, 2024
2 parents d5366b5 + b6e6d5d commit 3e1ae6b
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 224 deletions.
10 changes: 5 additions & 5 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod change;

use std::panic;

use rustc_hash::FxHashSet;
use syntax::{ast, Parse, SourceFile};
use triomphe::Arc;

Expand Down Expand Up @@ -90,15 +89,16 @@ pub trait SourceDatabaseExt: SourceDatabase {

fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[CrateId]> {
let graph = db.crate_graph();
graph
let mut crates = graph
.iter()
.filter(|&krate| {
let root_file = graph[krate].root_file_id;
db.file_source_root(root_file) == id
})
.collect::<FxHashSet<_>>()
.into_iter()
.collect()
.collect::<Vec<_>>();
crates.sort();
crates.dedup();
crates.into_iter().collect()
}

/// Silly workaround for cyclic deps between the traits
Expand Down
5 changes: 2 additions & 3 deletions crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,10 @@ impl ExprCollector<'_> {

let res = match self.def_map.modules[module]
.scope
.macro_invocations
.get(&InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
.macro_invoc(InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
{
// fast path, macro call is in a block module
Some(&call) => Ok(self.expander.enter_expand_id(self.db, call)),
Some(call) => Ok(self.expander.enter_expand_id(self.db, call)),
None => self.expander.enter_expand(self.db, mcall, |path| {
self.def_map
.resolve_path(
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/child_by_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl ChildBySource for ItemScope {
self.impls().for_each(|imp| add_impl(db, res, file_id, imp));
self.extern_crate_decls().for_each(|ext| add_extern_crate(db, res, file_id, ext));
self.use_decls().for_each(|ext| add_use(db, res, file_id, ext));
self.unnamed_consts().for_each(|konst| {
self.unnamed_consts(db).for_each(|konst| {
let loc = konst.lookup(db);
if loc.id.file_id() == file_id {
res[keys::CONST].insert(loc.source(db).value, konst);
Expand Down
Loading

0 comments on commit 3e1ae6b

Please sign in to comment.