Update on Procedural Macros Support

We finally enabled function-like and derive procedural macro expansion by default 🎉

Now the plugin provides them with syntax highlighting, completion, the Show Macro Expansion popup, and other features already available for declarative macros. Generated items are now suggested in code completion and considered in other code insight features:

Note that attribute procedural macro expansion is still disabled by default. If you want to try out, enable org.rust.macros.proc.attr experimental feature.

Read more about macros and how they are supported in Rust plugin in the corresponding blog post

New Features

  • #4768 Show coerced types via View | Type Info action (Ctrl+Shift+P)

  • #9686 Support short intra-doc links (in the [link] format)

  • #9808 Parse half-open range patterns

  • #9760 Notify users about changes in the crate roots of procedural macro libraries to reload the project model. Otherwise, the plugin won’t be able to expand procedural macro calls properly

  • #9711 Experimentally set RUST_IDE_PROC_MACRO_COMPLETION and RUST_IDE_PROC_MACRO_COMPLETION_DUMMY_IDENTIFIER environment variables for procedural macro when invoking them during completion. The idea is that authors of procedural macros could use these variables and based on them change the behavior of the macro to provide a better (possibly custom) completion for IDE users. See usage example in yew::html! macro

Fixes

  • #9756 Suggest Reload project instead of Attach file to a module quick-fix for the crate root files after their creation

  • #9761 Fix type inference in closures on nightly Rust

  • #9779 Fix false-positive errors like Use of moved values after invalidating caches without clearing file caches

  • #9800 Fix impl search when there are multiple type aliases with the same names

  • #9783 Fix move statement up/down editor action being incorrectly disabled with some IDE configurations (by @afetisov)

  • #9823 Fix completion inside local macro calls in 2022.3 IDE builds

  • #9767 Fix navigation, highlighting, completion and other code insight features with function-like macros invoked in the pattern context

  • #9762 Fix Find usages for variables defined by macros

  • #9764 Fix handling of nested blocks expanded from local macros

  • #9741 Don’t offer Un-elide lifetimes intention when there are no input lifetimes

  • #9788 Don’t show File does not belong to any known Cargo project warning for scratch files

  • #9345 Fix nesting of renamed imports (by @afetisov)

  • #9745 Restore Import | Fix all 'Unresolved reference' problems in file quick-fix option, which adds all missing unambiguous imports. Note, if you prefer missing imports to be fixed on the fly, you can enable Add unambiguous imports on the fly option in Settings | Editor | General | Auto Import settings

  • #9737 Don’t create separate Undo entries when adding unambiguous import on the fly

Internal Improvements

  • #9758 Make 2022.3 platform default for development

Full set of changes can be found here