diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-24 22:37:48 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-24 22:37:48 +0000 |
commit | d7db38fff9c251c36d0796309b43678bdf9e5bd8 (patch) | |
tree | 83b422d45c28e3ae9a2eac550ce8a6048bf5fd71 /crates/hir_def/src/db.rs | |
parent | 9d81618f11eb403cc0644a22f30648393ec77cf6 (diff) | |
parent | d1156bb52e900c015afd490f509d744c7a5adf10 (diff) |
Merge #7907
7907: Autoderef with visibility r=cynecx a=cynecx
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7841.
I am not sure about the general approach here. Right now this simply tries to check whether the autoderef candidate is reachable from the current module. ~~However this doesn't exactly work with traits (see the `tests::macros::infer_derive_clone_in_core` test, which fails right now).~~ see comment below
Refs:
- `rustc_typeck` checking fields: https://github.com/rust-lang/rust/blob/66ec64ccf31883cd2c28d045912a76179c0c6ed2/compiler/rustc_typeck/src/check/expr.rs#L1610
r? @flodiebold
Co-authored-by: cynecx <[email protected]>
Diffstat (limited to 'crates/hir_def/src/db.rs')
-rw-r--r-- | crates/hir_def/src/db.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/hir_def/src/db.rs b/crates/hir_def/src/db.rs index 53df85089..068b2ee38 100644 --- a/crates/hir_def/src/db.rs +++ b/crates/hir_def/src/db.rs | |||
@@ -16,6 +16,7 @@ use crate::{ | |||
16 | item_tree::ItemTree, | 16 | item_tree::ItemTree, |
17 | lang_item::{LangItemTarget, LangItems}, | 17 | lang_item::{LangItemTarget, LangItems}, |
18 | nameres::DefMap, | 18 | nameres::DefMap, |
19 | visibility::{self, Visibility}, | ||
19 | AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, | 20 | AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, |
20 | FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalEnumVariantId, LocalFieldId, StaticId, | 21 | FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalEnumVariantId, LocalFieldId, StaticId, |
21 | StaticLoc, StructId, StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, | 22 | StaticLoc, StructId, StructLoc, TraitId, TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, |
@@ -131,6 +132,12 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
131 | 132 | ||
132 | #[salsa::invoke(ImportMap::import_map_query)] | 133 | #[salsa::invoke(ImportMap::import_map_query)] |
133 | fn import_map(&self, krate: CrateId) -> Arc<ImportMap>; | 134 | fn import_map(&self, krate: CrateId) -> Arc<ImportMap>; |
135 | |||
136 | #[salsa::invoke(visibility::field_visibilities_query)] | ||
137 | fn field_visibilities(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Visibility>>; | ||
138 | |||
139 | #[salsa::invoke(visibility::function_visibility_query)] | ||
140 | fn function_visibility(&self, def: FunctionId) -> Visibility; | ||
134 | } | 141 | } |
135 | 142 | ||
136 | fn crate_def_map_wait(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> { | 143 | fn crate_def_map_wait(db: &dyn DefDatabase, krate: CrateId) -> Arc<DefMap> { |