rust/crates
bors[bot] 6fcb5d772f
Merge #8048
8048: Fix missing unresolved macro diagnostic in function body r=edwin0cheng a=brandondong

This was an issue I found while working on https://github.com/rust-analyzer/rust-analyzer/pull/7970.

**Reproduction:**
1. Call a non-existent macro in a function body.
```
fn main() {
  foo!();
}
```
2. No diagnostics are raised. An unresolved-macro-call diagnostic is expected.
3. If the macro call is instead outside of the function body, this works as expected.

I believe this worked previously and regressed in https://github.com/rust-analyzer/rust-analyzer/pull/7805.

**Behavior prior to https://github.com/rust-analyzer/rust-analyzer/pull/7805:**
- The unresolved-macro-call diagnostic did not exist. Instead, a macro-error diagnostic would be raised with the text "could not resolve macro [path]".
- This was implemented by adding an error to the error sink (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8L657).
- The error was propagated through 1a82af3527/crates/hir_def/src/body.rs (L123) eventually reaching 1a82af3527/crates/hir_def/src/body/lower.rs (L569).

**Behavior after:**
- Instead of writing to the error sink, an UnresolvedMacro error is now returned (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R631).
- The parent caller throws away the error as its function signature is `Option<MacroCallId>` (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R604).
- We instead now reach the warn condition (1a82af3527/crates/hir_def/src/body.rs (L124)) and no diagnostics are created in 1a82af3527/crates/hir_def/src/body/lower.rs (L575).

**Fix:**
- Make sure to propagate the UnresolvedMacro error. Report the error using the new unresolved-macro-call diagnostic.


Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-03-17 07:20:28 +00:00
..
base_db Don't repeat work in transitive_reverse_dependencies 2021-03-16 15:53:34 +01:00
cfg Add runnables::related_tests 2021-02-27 18:00:17 +03:00
flycheck Bump cargo_metadata 2021-03-02 14:27:29 +02:00
hir Rename Substs -> Substitution 2021-03-16 17:58:17 +01:00
hir_def Merge #8048 2021-03-17 07:20:28 +00:00
hir_expand Merge #8048 2021-03-17 07:20:28 +00:00
hir_ty Rename Substs -> Substitution 2021-03-16 17:58:17 +01:00
ide Merge #8055 2021-03-16 15:48:35 +00:00
ide_assists Move more bounds 2021-03-16 22:28:04 +03:00
ide_completion Merge #8052 2021-03-16 13:56:53 +00:00
ide_db Merge #8034 2021-03-16 14:54:12 +00:00
ide_ssr Upgrade rowan 2021-03-16 16:10:49 +03:00
mbe Fix macro expansion for statements w/o semicolon 2021-03-16 13:44:50 +08:00
parser Fix macro expansion for statements w/o semicolon 2021-03-16 13:44:50 +08:00
paths
proc_macro_api Add test for proc-macro meta info retrieval 2021-03-15 23:38:22 +08:00
proc_macro_srv Add test for proc-macro meta info retrieval 2021-03-15 23:38:22 +08:00
proc_macro_test
profile
project_model some clippy::performance fixes 2021-03-15 10:19:59 +01:00
rust-analyzer Enable proc-macros by default 2021-03-15 18:19:08 +03:00
stdx
syntax pit-of-successify tree editor 2021-03-16 22:59:57 +03:00
test_utils Add new_source_root meta to test fixtures 2021-03-16 15:28:02 +01:00
text_edit
toolchain
tt add expand log 2021-03-13 20:14:21 +08:00
vfs
vfs-notify