rust/crates/hir_def/src
bors[bot] 0fb5d9d87a
Merge #6033
6033: Make name resolution resolve proc macros instead of relying purely on the build system r=matklad a=jonas-schievink

This makes name resolution look at proc-macro declaration attributes like `#[proc_macro_derive]` and defines the right proc macro in the macro namespace, fixing unresolved custom derives like `thiserror::Error` (which can cause false positives, now that we emit diagnostics for unresolved imports).

This works even when proc-macro support is turned off, in which case we fall back to a dummy expander that always returns an error. IMO this is the right way to handle at least the name resolution part of proc. macros, while the *expansion* itself should rely on the build system to build and provide the macro DLL. It does mean that they may go out of sync, but we can provide diagnostics if that happens (something like "could not find macro X in crate Y – ensure that all files of crate Y are saved").

I think it is valuable to be able to reason about proc macros even when we can't expand them, since proc macro expansion can break between Rust releases or users might not want to turn it on for performance reasons. It allows us to provide better diagnostics on any proc macro invocation we're not expanding (like a weak warning that informs the user that proc macro support is turned off, or that it has been disabled because the server crashed).

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5763

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-09-28 11:03:47 +00:00
..
body Merge #5971 2020-09-13 17:28:22 +00:00
item_tree Give ExternCrate a Name, not a ModPath 2020-09-17 15:28:23 +02:00
nameres Add more comments about proc macro resolution 2020-09-28 13:02:28 +02:00
path Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
adt.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
attr.rs Remove incorrect docs 2020-09-18 18:09:47 +02:00
body.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
builtin_type.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
child_by_source.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
data.rs Lower extern type alias as foreign opaque type. 2020-09-16 20:57:14 +08:00
db.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
diagnostics.rs Mark unresolved imports diagnostic as experimental 2020-09-28 12:45:20 +02:00
docs.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
dyn_map.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
expr.rs Merge #5971 2020-09-13 17:28:22 +00:00
find_path.rs Don't unnecessarily unnest imports for import insertion 2020-09-25 15:19:22 +02:00
generics.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
import_map.rs Switch to expect_test from crates.io 2020-08-21 13:19:31 +02:00
item_scope.rs Simplify iterator chain 2020-09-28 12:51:40 +02:00
item_tree.rs Give ExternCrate a Name, not a ModPath 2020-09-17 15:28:23 +02:00
keys.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
lang_item.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
lib.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
nameres.rs Add diagnostic types for unresolved crates/imports 2020-09-16 17:26:51 +02:00
path.rs Give ExternCrate a Name, not a ModPath 2020-09-17 15:28:23 +02:00
per_ns.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
resolver.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
src.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
test_db.rs Add annotation-based nameres diagnostic tests 2020-09-16 17:26:51 +02:00
trace.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
type_ref.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00
visibility.rs Rename ra_hir_def -> hir_def 2020-08-13 16:29:33 +02:00