Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ rust-analyzer #115048

Merged
merged 118 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
595d9e6
fix: don't use control flow when extracted fn contains tail expr of o…
lowr Jul 10, 2023
008b639
handle `#[cfg]`s on generic parameters
max-heller Jul 28, 2023
37a8493
tests
max-heller Jul 28, 2023
784379e
wip
max-heller Jul 29, 2023
c4cff80
use nodes from actual file
max-heller Jul 30, 2023
b9ee4a5
working for path segments
max-heller Jul 30, 2023
3205ed7
simplify storing generic parameter attributes in item tree
max-heller Aug 2, 2023
f4038a6
support AssocTypeArg and MethodCalls
max-heller Aug 1, 2023
1b3e20f
handle more cases
max-heller Aug 2, 2023
50db877
optimization and #[cfg] filtering for function generic params
max-heller Aug 5, 2023
ee39905
update tests
max-heller Aug 5, 2023
5e6d646
remove unnecessary branch
max-heller Aug 5, 2023
d48606f
unroll test loop
max-heller Aug 5, 2023
bed1114
handle omitted lifetime params
max-heller Aug 5, 2023
9b636e2
Support `libc::getenv` in mir interpreter
HKalbasi Aug 5, 2023
0c433c2
Support doc links that resolve to fields
lowr Aug 6, 2023
bb9d822
cleanup
max-heller Aug 6, 2023
0c21d85
FIXME
max-heller Aug 6, 2023
b96e4f2
Add mir lower support for tuple destructing assignment
HKalbasi Aug 6, 2023
aa55ce9
Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-fro…
lnicola Aug 7, 2023
0c00198
Merge branch 'master' into sync-from-rust
lnicola Aug 7, 2023
d9e9ca2
Auto merge of #15409 - lnicola:sync-from-rust, r=lnicola
bors Aug 7, 2023
31c3093
Support closure in clone shim
HKalbasi Aug 7, 2023
9cb1f45
add check.ignore to list cargo check diagnostics to ignore (dead_code…
adamse May 13, 2023
cba39f8
fix: Fix float parser hack creating empty NameRef tokens
Veykril Aug 8, 2023
44eeaea
Auto merge of #15415 - Veykril:eager-parser-input, r=Veykril
bors Aug 8, 2023
02d5c0a
chore: convert unwrap to except and add a debug log
Sarrus1 Aug 8, 2023
f98d654
Auto merge of #15350 - max-heller:issue-11756, r=Veykril
bors Aug 8, 2023
ed4e28b
Auto merge of #15217 - Sarrus1:fix/unsafe-unwrap, r=Veykril
bors Aug 8, 2023
783130b
Auto merge of #15250 - lowr:fix/extract-fn-no-control-flow-with-tail-…
bors Aug 8, 2023
ef5c6da
Rewrite DeMorgan without str manipulation.
alibektas Jul 24, 2023
17f3055
Rewrite DeMorgan v2
alibektas Aug 8, 2023
af4ba46
Auto merge of #15405 - lowr:patch/doc-links-to-fields, r=Veykril
bors Aug 8, 2023
6aa03c5
Use `Cast::cast()` instead of interning `GenericArgData`
lowr Aug 8, 2023
3bfe1d5
Display fully qualified associated types correctly
oxalica Aug 8, 2023
6918eb6
Auto merge of #15416 - oxalica:fix/hover-assoc-type, r=lowr
bors Aug 8, 2023
52b4392
the "add missing members" assists: implemented substitution of defaul…
ponyii Jun 30, 2023
4ebdc6f
syntax update: the default value of `ConstParam` turned from `Expr` i…
ponyii Jul 10, 2023
4e2be8e
the "add missing members" assists: implemented the transformation of …
ponyii Jul 11, 2023
61cabe0
the "add missing members" assists: supported bracketed default const …
ponyii Jul 12, 2023
e4c4542
refactoring
ponyii Aug 8, 2023
68e8379
fixed a merge-caused error
ponyii Aug 8, 2023
6a2f83a
Impl `HirDisplay` for `SelfParam`
oxalica Aug 8, 2023
de86444
Prefer `hir::SelfParam` and fix signature help of methods from macros
oxalica Aug 8, 2023
e13fac3
Auto merge of #15262 - adamse:master, r=HKalbasi
bors Aug 8, 2023
ddbbd6a
Auto merge of #15417 - lowr:patch/purge-generic-arg-data-in-expr, r=H…
bors Aug 8, 2023
021802c
Support enum in memory map patch address
HKalbasi Aug 8, 2023
fc2f90e
Auto merge of #15419 - HKalbasi:mir, r=HKalbasi
bors Aug 8, 2023
a1d9e45
Apply suggestions from code review
max-heller Aug 8, 2023
0b57fa3
test
max-heller Aug 9, 2023
400f618
convert TypeLocation::GenericArg to struct variant
max-heller Aug 9, 2023
fb98f52
fixme
max-heller Aug 9, 2023
18b24f6
More error context when failing to invoke the rust toolchain
Veykril Aug 9, 2023
4bed01c
Auto merge of #15421 - Veykril:workspace-loading, r=Veykril
bors Aug 9, 2023
992b928
Record import source IDs
Veykril Aug 9, 2023
c516dd5
Simplify
Veykril Aug 9, 2023
4e4dda5
Deunwrap convert_named_struct_to_tuple_struct
alibektas Aug 9, 2023
b6ee96c
Auto merge of #15423 - alibektas:deunwrap/convert_named_struct_to_tup…
bors Aug 9, 2023
b658f9a
Remove unwrap from Remove dbg
lnicola Aug 9, 2023
63aba76
Remove unnecessary ItemTreeId field in ImportSource
Veykril Aug 9, 2023
b78d69c
Auto merge of #15422 - Veykril:import-sources, r=Veykril
bors Aug 9, 2023
ebf2705
minor : Deunwrap convert_to_guarded_return
alibektas Aug 9, 2023
7e04142
Fix pinned version of lsp-types
Veykril Aug 9, 2023
05b0612
Auto merge of #15428 - Veykril:lsp-types-pin, r=Veykril
bors Aug 9, 2023
c81a068
Deunwrap generate_delegate_methods
alibektas Aug 9, 2023
423b00a
Deunwrap remove_unused_imports
alibektas Aug 9, 2023
94b3481
Deunwrap generate_derive
alibektas Aug 9, 2023
e5b23e3
Derive block attributes from block item tree
Veykril Aug 10, 2023
fde2d9b
Deduplicate FileId field in ModuleOrigin
Veykril Aug 10, 2023
bfad781
Memoize block_item_tree_query
Veykril Aug 10, 2023
9adff00
Simplify
Veykril Aug 10, 2023
1b67823
Auto merge of #15435 - Veykril:block-src, r=Veykril
bors Aug 10, 2023
0ef541e
Increase the buffer size for discover project command
Wilfred Aug 8, 2023
de28baf
Auto merge of #15424 - lnicola:remove-remove-dbg-unwrap, r=lnicola
bors Aug 11, 2023
1fde334
Auto merge of #15433 - alibektas:deunwrap/remove_unused_imports, r=ln…
bors Aug 11, 2023
c1c8e78
Preserve `resolve_obligations_as_possible` temporary allocation acros…
Veykril Aug 10, 2023
39ebc37
Auto merge of #15436 - Veykril:temp-alloc, r=Veykril
bors Aug 12, 2023
d6d188f
fix: Fix `only_types` config filtering out traits from world symbols
Veykril Aug 12, 2023
6cf06c1
Auto merge of #15445 - Veykril:worl-symbols-traits, r=Veykril
bors Aug 12, 2023
33f9250
Pass server extraEnv to isValidExecutable
Veykril Aug 12, 2023
9ac88d8
Fix parser being stuck in eager macro inputs
Veykril Aug 11, 2023
2fbe69d
Auto merge of #15438 - Veykril:eager-parser-stuck, r=Veykril
bors Aug 12, 2023
0fa822d
Auto merge of #15418 - oxalica:fix/sig-from-macro, r=Veykril
bors Aug 15, 2023
f73cd39
Auto merge of #15383 - max-heller:issue-12568, r=Veykril
bors Aug 15, 2023
0b2a241
Auto merge of #15426 - alibektas:deunwrap/convert_to_guarded_return, …
bors Aug 15, 2023
c18ce9a
Auto merge of #15429 - alibektas:deunwrap/generate_delegate_methods, …
bors Aug 15, 2023
7ca45dc
Auto merge of #15410 - alibektas:15240/invalid-demorgan, r=Veykril
bors Aug 15, 2023
e76d20e
Add status bar button to toggle check on save state
Veykril Aug 12, 2023
b771de3
Auto merge of #15179 - ponyii:fix/default-values-of-const-params-are-…
bors Aug 15, 2023
ef2ee59
Auto merge of #15446 - Veykril:checkOnSaveToggle, r=Veykril
bors Aug 15, 2023
d548146
Auto merge of #15420 - Wilfred:discover_command_max_buffer, r=Veykril
bors Aug 15, 2023
4c67bec
Always collect memory usage info in analysis-stats
lnicola Aug 15, 2023
54c4125
Auto merge of #15461 - lnicola:analysis-stats-memory, r=Veykril
bors Aug 15, 2023
fec5ff9
start hovering default values of generic constants
ponyii Aug 15, 2023
b147709
Auto merge of #15463 - ponyii:fix/start-hovering-default-values-of-ge…
bors Aug 15, 2023
2a78173
v2
alibektas Aug 15, 2023
53b2924
internal: Add offset param to token descending API
Veykril Aug 16, 2023
e69b96b
Auto merge of #15466 - Veykril:prep-inline-fmt-args, r=Veykril
bors Aug 16, 2023
af80482
Prepare ItemScope for IDE import resolution
Veykril Aug 16, 2023
c4e9b5a
Add import info to item scope dumps
Veykril Aug 17, 2023
a17d73a
Thread imports through the resolver
Veykril Aug 17, 2023
49716e6
Auto merge of #15472 - Veykril:import-ide-support, r=Veykril
bors Aug 17, 2023
637f496
fix: Fix auto-import (and completions) importing `#[doc(hidden)]` items
Veykril Aug 17, 2023
44cf174
Auto merge of #15473 - Veykril:doc-hidden-imports, r=Veykril
bors Aug 17, 2023
eb6244c
Record import aliases in symbol index
Veykril Aug 18, 2023
d895e9e
Auto merge of #15477 - Veykril:import-alias-symbols, r=Veykril
bors Aug 18, 2023
c0f6ece
Auto merge of #15434 - alibektas:deunwrap/generate_derive, r=lnicola
bors Aug 18, 2023
dadbfe7
upgrade lsp server
matklad Aug 19, 2023
721e0e3
Auto merge of #15480 - matklad:lsp-server-up, r=Veykril
bors Aug 19, 2023
6c46b98
fix: avoid problematic serde release
matklad Aug 19, 2023
904b326
Auto merge of #15482 - matklad:🪄deblobify, r=Veykril
bors Aug 19, 2023
1cebc0c
internal: post-bump lsp-server version
matklad Aug 19, 2023
83b3ba1
Auto merge of #15483 - matklad:up-me-baby-one-more-time, r=Veykril
bors Aug 19, 2023
37e0e8a
Implement extern crate completion
jmintb Mar 30, 2023
a3892f0
Auto merge of #15374 - jmintb:extern_crate, r=Veykril
bors Aug 21, 2023
887cc48
fix help text for rust-analyzer.check.invocation{Strategy,Location}
RalfJung Aug 21, 2023
9b3d034
Auto merge of #15490 - RalfJung:check-invocation-help, r=Veykril
bors Aug 21, 2023
e7ef5d8
Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-fro…
lnicola Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -999,23 +999,23 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"

[[package]]
name = "lsp-server"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3711e4d6f491dc9edc0f1df80e204f38206775ac92c1241e89b79229a850bc00"
version = "0.7.3"
dependencies = [
"crossbeam-channel",
"log",
"lsp-types",
"serde",
"serde_json",
]

[[package]]
name = "lsp-server"
version = "0.7.2"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72417faa455bfb4e5bf14b157d8e2ca2ed74b4e89b8cf42ea2d864825ae5c8a2"
dependencies = [
"crossbeam-channel",
"log",
"lsp-types",
"serde",
"serde_json",
]
Expand Down Expand Up @@ -1555,7 +1555,7 @@ dependencies = [
"ide-ssr",
"itertools",
"load-cargo",
"lsp-server 0.7.1",
"lsp-server 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lsp-types",
"mbe",
"mimalloc",
Expand Down
5 changes: 3 additions & 2 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ proc-macro-test = { path = "./crates/proc-macro-test" }
# In-tree crates that are published separately and follow semver. See lib/README.md
line-index = { version = "0.1.0-pre.1" }
la-arena = { version = "0.3.1" }
lsp-server = { version = "0.7.1" }
lsp-server = { version = "0.7.3" }

# non-local crates
smallvec = { version = "1.10.0", features = [
Expand All @@ -97,7 +97,8 @@ smallvec = { version = "1.10.0", features = [
smol_str = "0.2.0"
nohash-hasher = "0.2.0"
text-size = "1.1.0"
serde = { version = "1.0.156", features = ["derive"] }
# See https://github.com/serde-rs/serde/issues/2538#issuecomment-1684517372 for why we pin serde
serde = { version = "1.0.156, < 1.0.172", features = ["derive"] }
serde_json = "1.0.96"
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
# can't upgrade due to dashmap depending on 0.12.3 currently
Expand Down
4 changes: 3 additions & 1 deletion src/tools/rust-analyzer/crates/base-db/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl ChangeFixture {
let mut default_crate_root: Option<FileId> = None;
let mut default_target_data_layout: Option<String> = None;
let mut default_cfg = CfgOptions::default();
let mut default_env = Env::new_for_test_fixture();

let mut file_set = FileSet::default();
let mut current_source_root_kind = SourceRootKind::Local;
Expand Down Expand Up @@ -200,6 +201,7 @@ impl ChangeFixture {
assert!(default_crate_root.is_none());
default_crate_root = Some(file_id);
default_cfg = meta.cfg;
default_env.extend(meta.env.iter().map(|(x, y)| (x.to_owned(), y.to_owned())));
default_target_data_layout = meta.target_data_layout;
}

Expand All @@ -220,7 +222,7 @@ impl ChangeFixture {
None,
default_cfg,
Default::default(),
Env::new_for_test_fixture(),
default_env,
false,
CrateOrigin::Local { repo: None, name: None },
default_target_data_layout
Expand Down
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,12 @@ impl fmt::Display for Edition {
}
}

impl Extend<(String, String)> for Env {
fn extend<T: IntoIterator<Item = (String, String)>>(&mut self, iter: T) {
self.entries.extend(iter);
}
}

impl FromIterator<(String, String)> for Env {
fn from_iter<T: IntoIterator<Item = (String, String)>>(iter: T) -> Self {
Env { entries: FromIterator::from_iter(iter) }
Expand Down
10 changes: 4 additions & 6 deletions src/tools/rust-analyzer/crates/hir-def/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,10 @@ impl AttrsWithOwner {
.item_tree(db)
.raw_attrs(AttrOwner::ModItem(definition_tree_id.value.into()))
.clone(),
ModuleOrigin::BlockExpr { block } => RawAttrs::from_attrs_owner(
db.upcast(),
InFile::new(block.file_id, block.to_node(db.upcast()))
.as_ref()
.map(|it| it as &dyn ast::HasAttrs),
),
ModuleOrigin::BlockExpr { id, .. } => {
let tree = db.block_item_tree_query(id);
tree.raw_attrs(AttrOwner::TopLevel).clone()
}
}
}
AttrDefId::FieldId(it) => {
Expand Down
7 changes: 6 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ impl ExprCollector<'_> {
let mut args = Vec::new();
let mut arg_types = Vec::new();
if let Some(pl) = e.param_list() {
let num_params = pl.params().count();
args.reserve_exact(num_params);
arg_types.reserve_exact(num_params);
for param in pl.params() {
let pat = this.collect_pat_top(param.pat());
let type_ref =
Expand Down Expand Up @@ -1100,7 +1103,9 @@ impl ExprCollector<'_> {
ast::Stmt::ExprStmt(es) => matches!(es.expr(), Some(ast::Expr::MacroExpr(_))),
_ => false,
});
statement_has_item || matches!(block.tail_expr(), Some(ast::Expr::MacroExpr(_)))
statement_has_item
|| matches!(block.tail_expr(), Some(ast::Expr::MacroExpr(_)))
|| (block.may_carry_attributes() && block.attrs().next().is_some())
};

let block_id = if block_has_items {
Expand Down
20 changes: 10 additions & 10 deletions src/tools/rust-analyzer/crates/hir-def/src/body/tests/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ fn outer() {
"#,
expect![[r#"
block scope
CrateStruct: t
PlainStruct: t v
SelfStruct: t
CrateStruct: ti
PlainStruct: ti vi
SelfStruct: ti
Struct: v
SuperStruct: _

Expand All @@ -66,7 +66,7 @@ fn outer() {
"#,
expect![[r#"
block scope
imported: t v
imported: ti vi
name: v

crate
Expand All @@ -92,9 +92,9 @@ fn outer() {
"#,
expect![[r#"
block scope
inner1: t
inner1: ti
inner2: v
outer: v
outer: vi

block scope
inner: v
Expand All @@ -121,7 +121,7 @@ struct Struct {}
"#,
expect![[r#"
block scope
Struct: t
Struct: ti

crate
Struct: t
Expand Down Expand Up @@ -153,7 +153,7 @@ fn outer() {
"#,
expect![[r#"
block scope
ResolveMe: t
ResolveMe: ti

block scope
m2: t
Expand Down Expand Up @@ -214,7 +214,7 @@ fn f() {
"#,
expect![[r#"
block scope
ResolveMe: t
ResolveMe: ti

block scope
h: v
Expand Down Expand Up @@ -292,7 +292,7 @@ pub mod cov_mark {
nested: v

crate
cov_mark: t
cov_mark: ti
f: v
"#]],
);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl ExternCrateDeclData {
db.crate_def_map(loc.container.krate())
.extern_prelude()
.find(|&(prelude_name, ..)| *prelude_name == name)
.map(|(_, root)| root.krate())
.map(|(_, (root, _))| root.krate())
};

Arc::new(Self {
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
#[salsa::invoke(ItemTree::file_item_tree_query)]
fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;

#[salsa::invoke(ItemTree::block_item_tree_query)]
fn block_item_tree_query(&self, block_id: BlockId) -> Arc<ItemTree>;

#[salsa::invoke(crate_def_map_wait)]
#[salsa::transparent]
fn crate_def_map(&self, krate: CrateId) -> Arc<DefMap>;
Expand Down
81 changes: 74 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/find_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
nameres::DefMap,
path::{ModPath, PathKind},
visibility::Visibility,
ModuleDefId, ModuleId,
CrateRootModuleId, ModuleDefId, ModuleId,
};

/// Find a path that can be used to refer to a certain item. This can depend on
Expand Down Expand Up @@ -81,7 +81,7 @@ fn find_path_inner(
}

let def_map = from.def_map(db);
let crate_root = def_map.crate_root().into();
let crate_root = def_map.crate_root();
// - if the item is a module, jump straight to module search
if let ItemInNs::Types(ModuleDefId::ModuleId(module_id)) = item {
let mut visited_modules = FxHashSet::default();
Expand Down Expand Up @@ -149,7 +149,7 @@ fn find_path_for_module(
db: &dyn DefDatabase,
def_map: &DefMap,
visited_modules: &mut FxHashSet<ModuleId>,
crate_root: ModuleId,
crate_root: CrateRootModuleId,
from: ModuleId,
module_id: ModuleId,
max_len: usize,
Expand Down Expand Up @@ -183,7 +183,7 @@ fn find_path_for_module(

// - if the item is the crate root of a dependency crate, return the name from the extern prelude
let root_def_map = crate_root.def_map(db);
for (name, def_id) in root_def_map.extern_prelude() {
for (name, (def_id, _extern_crate)) in root_def_map.extern_prelude() {
if module_id == def_id {
let name = scope_name.unwrap_or_else(|| name.clone());

Expand All @@ -192,7 +192,7 @@ fn find_path_for_module(
def_map[local_id]
.scope
.type_(&name)
.filter(|&(id, _)| id != ModuleDefId::ModuleId(def_id))
.filter(|&(id, _)| id != ModuleDefId::ModuleId(def_id.into()))
})
.is_some();
let kind = if name_already_occupied_in_type_ns {
Expand Down Expand Up @@ -224,6 +224,7 @@ fn find_path_for_module(
)
}

// FIXME: Do we still need this now that we record import origins, and hence aliases?
fn find_in_scope(
db: &dyn DefDatabase,
def_map: &DefMap,
Expand All @@ -244,7 +245,7 @@ fn find_in_prelude(
item: ItemInNs,
from: ModuleId,
) -> Option<ModPath> {
let prelude_module = root_def_map.prelude()?;
let (prelude_module, _) = root_def_map.prelude()?;
// Preludes in block DefMaps are ignored, only the crate DefMap is searched
let prelude_def_map = prelude_module.def_map(db);
let prelude_scope = &prelude_def_map[prelude_module.local_id].scope;
Expand Down Expand Up @@ -293,7 +294,7 @@ fn calculate_best_path(
db: &dyn DefDatabase,
def_map: &DefMap,
visited_modules: &mut FxHashSet<ModuleId>,
crate_root: ModuleId,
crate_root: CrateRootModuleId,
max_len: usize,
item: ItemInNs,
from: ModuleId,
Expand Down Expand Up @@ -346,6 +347,11 @@ fn calculate_best_path(
let extern_paths = crate_graph[from.krate].dependencies.iter().filter_map(|dep| {
let import_map = db.import_map(dep.crate_id);
import_map.import_info_for(item).and_then(|info| {
if info.is_doc_hidden {
// the item or import is `#[doc(hidden)]`, so skip it as it is in an external crate
return None;
}

// Determine best path for containing module and append last segment from `info`.
// FIXME: we should guide this to look up the path locally, or from the same crate again?
let mut path = find_path_for_module(
Expand Down Expand Up @@ -1293,4 +1299,65 @@ pub mod prelude {
"None",
);
}

#[test]
fn different_crate_renamed_through_dep() {
check_found_path(
r#"
//- /main.rs crate:main deps:intermediate
$0
//- /intermediate.rs crate:intermediate deps:std
pub extern crate std as std_renamed;
//- /std.rs crate:std
pub struct S;
"#,
"intermediate::std_renamed::S",
"intermediate::std_renamed::S",
"intermediate::std_renamed::S",
"intermediate::std_renamed::S",
);
}

#[test]
fn different_crate_doc_hidden() {
check_found_path(
r#"
//- /main.rs crate:main deps:intermediate
$0
//- /intermediate.rs crate:intermediate deps:std
#[doc(hidden)]
pub extern crate std;
pub extern crate std as longer;
//- /std.rs crate:std
pub struct S;
"#,
"intermediate::longer::S",
"intermediate::longer::S",
"intermediate::longer::S",
"intermediate::longer::S",
);
}

#[test]
fn respect_doc_hidden() {
check_found_path(
r#"
//- /main.rs crate:main deps:std,lazy_static
$0
//- /lazy_static.rs crate:lazy_static deps:core
#[doc(hidden)]
pub use core::ops::Deref as __Deref;
//- /std.rs crate:std deps:core
pub use core::ops;
//- /core.rs crate:core
pub mod ops {
pub trait Deref {}
}
"#,
"std::ops::Deref",
"std::ops::Deref",
"std::ops::Deref",
"std::ops::Deref",
);
}
}
Loading
Loading