-
Notifications
You must be signed in to change notification settings - Fork 380
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
Tracking issue for procedural macro support #6908
Comments
6992: MACRO: expand custom derive, resolve impls from custom derive r=vlad20012 a=vlad20012 Issue #6908 At this point, we can expand custom derive proc macros (except `serde`) and take into account `impl`s generated by them. Other items except impls are ignored. Works only when using the new name resolution engine (#6217). `serde::Serialize` and `serde::Deserialize` are ignored for now because we have fine-working hardcoded impls for them and turning it into honest macro expansion can impact performance (because of LOTS of serde macros everywhere). changelog: Provide initial support for [custom derive](https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros) procedural macros. Now the plugin can expand such procedural macro calls and take into account expanded `impl` items in type inference and name resolution (other types of items are ignored). Note, it’s only an initial implementation, so it may work in an unexpected way in some cases. The feature is disabled by default for now. To turn it on, you should enable `Use experimental name resolution engine` option in `Preferences | Languages & Frameworks | Rust` settings and enable `org.rust.cargo.evaluate.build.scripts` and `org.rust.macros.proc` experimental features. Don’t forget to reload a project structure after enabling the corresponding features via `Refresh Cargo Projects` action on Cargo tool window. See [tracking issue](#6908) for more details and the current status of procedural macros support Co-authored-by: vlad20012 <beskvlad@gmail.com>
6992: MACRO: expand custom derive, resolve impls from custom derive r=undin a=vlad20012 Issue #6908 At this point, we can expand custom derive proc macros (except `serde`) and take into account `impl`s generated by them. Other items except impls are ignored. Works only when using the new name resolution engine (#6217). `serde::Serialize` and `serde::Deserialize` are ignored for now because we have fine-working hardcoded impls for them and turning it into honest macro expansion can impact performance (because of LOTS of serde macros everywhere). changelog: Provide initial support for [custom derive](https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros) procedural macros. Now the plugin can expand such procedural macro calls and take into account expanded `impl` items in type inference and name resolution (other types of items are ignored). Note, it’s only an initial implementation, so it may work in an unexpected way in some cases. The feature is disabled by default for now. To turn it on, you should enable `Use experimental name resolution engine` option in `Preferences | Languages & Frameworks | Rust` settings and enable `org.rust.cargo.evaluate.build.scripts` and `org.rust.macros.proc` experimental features. Don’t forget to reload a project structure after enabling the corresponding features via `Refresh Cargo Projects` action on Cargo tool window. See [tracking issue](#6908) for more details and the current status of procedural macros support Co-authored-by: vlad20012 <beskvlad@gmail.com>
6992: MACRO: expand custom derive, resolve impls from custom derive r=undin a=vlad20012 Issue #6908 At this point, we can expand custom derive proc macros (except `serde`) and take into account `impl`s generated by them. Other items except impls are ignored. Works only when using the new name resolution engine (#6217). `serde::Serialize` and `serde::Deserialize` are ignored for now because we have fine-working hardcoded impls for them and turning it into honest macro expansion can impact performance (because of LOTS of serde macros everywhere). changelog: Provide initial support for [custom derive](https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros) procedural macros. Now the plugin can expand such procedural macro calls and take into account expanded `impl` items in type inference and name resolution (other types of items are ignored). Note, it’s only an initial implementation, so it may work in an unexpected way in some cases. The feature is disabled by default for now. To turn it on, you should enable `Use experimental name resolution engine` option in `Preferences | Languages & Frameworks | Rust` settings and enable `org.rust.cargo.evaluate.build.scripts` and `org.rust.macros.proc` experimental features. Don’t forget to reload a project structure after enabling the corresponding features via `Refresh Cargo Projects` action on Cargo tool window. See [tracking issue](#6908) for more details and the current status of procedural macros support Co-authored-by: vlad20012 <beskvlad@gmail.com>
Does this mean that a subset of derive macro code is currently considered (e.g. for code completion and missing-symbol highlighting?
For example, the Snafu derive macro produces structs which intellij-rust seems to be unaware of. Would a minimal use case example of this and tracking issue be of any benefit? |
Yep. Currently, the plugin takes into account only impl blocks generated by derive proc macro
I don't think that we need additional tracking issue only for that case because the current issue already contains a similar item: "take into account all items generated by custom derive macros". But an additional use-case can be useful indeed to check it during the corresponding implementation |
Here is the use-case: Cargo.toml: [package]
name = "snafu-jetbrains"
version = "0.1.0"
edition = "2018"
[dependencies]
snafu = "0.6" main.rs use snafu::Snafu;
/// The error type for this library.
#[derive(Debug, Snafu)]
enum Error {
#[snafu(display("This is always an error:: {}", message))]
AlwaysError { message: String },
}
fn hello_world() -> Result<(), Error> {
AlwaysError {
message: "this is a struct created by snafu",
}
.fail()
}
fn main() {
hello_world().unwrap()
} Problem: Desired behavior: code completion should be available for the struct Desired behavior: context actions should provide the ability to fill in missing struct fields for the Thank you! 🚀 |
7307: CI&MACRO: expand proc macros on Apple Silicon machines r=Undin a=Undin Part of #6908 changelog: Support [procedural macro](https://doc.rust-lang.org/reference/procedural-macros.html) expansion on Apple Silicon machines. Note: - you should use `aarch64-apple-darwin` toolchain to make procedural macro expansion work - the proc macro expansion is still disabled by default. To turn it on, enable `org.rust.cargo.evaluate.build.scripts` and `org.rust.macros.proc` [experimental features](https://plugins.jetbrains.com/plugin/8182-rust/docs/rust-faq.html#experimental-features) Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
How are we coming along on Right now I have to open Sublime Text using Rust Analyzer to discover generated structs and functions! Help, I'm lost without my IDE! |
What's blocking #6732? I don't see that issue mentioned here. I'm experiencing the same problem and would love if that is fixed. |
@hamza1311, I suppose it's #7725, but you can use the latest |
@vlad20012, I see. It seems that specific case is fixed but there are other cases where the bug still exists. For example, the following code still gives the same message: use yew::prelude::*;
fn _test() -> Html {
use_effect(|| {
|| {}
});
html! {
}
}
[package]
name = "yew-html-macro-bug-repro"
version = "0.1.0"
edition = "2018"
[dependencies]
yew = { git = "https://github.com/yewstack/yew/" } It is also worth mentioning that the warning disappears if I do this: |
I tried enabling this, refreshed a cargo project and it just worked. My code compiles fine even though IntelliJ now shows it as "red". Before I open a new ticket I thought I'd ask if I am maybe missing something: Do I need to do anything to manually update proc macro details and/or can I delete a cache somewhere? A |
Had a issue with Sycamore (originally reported it for Yew) but these experimental features solved it for me. Also added screenshots and a repo to reproduce it: #6732 (comment) |
Hi I wanted to activate org.rust.macros.proc as an experimental feature, but I do not see it in there, what can I do to make it available? Thanks |
@CristianKerr follow this instruction |
|
@CristianKerr I suppose you use too old plugin version |
You are right, I have 0.3.140.3644-202, but I do not know why it doesn't show latest version for me (it looks like its up to date). Thanks! |
Probably, you use old IDE version as well |
@Undin you are right, got stuck on older version, thanks for the help! |
Span::call_site.source_file.path has empty path |
10607: Enable attribute procedural macro expansion by default r=vlad20012 a=vlad20012 It looks like most of the issues with attribute macros are fixed now, so we can enable their expansion by default. Part of #6908 Fixes #5104 Fixes #5239 Fixes #5748 Fixes #5896 Fixes #6006 Fixes #6091 Fixes #6093 Fixes #6482 Fixes #6938 Fixes #7610 Fixes #7863 Fixes #8350 Fixes #8407 Fixes #8640 Fixes #9128 Fixes #9384 Fixes #9534 Fixes #9918 Fixes #9973 changelog: Enable [attribute](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros) procedural macro expansion by default. Co-authored-by: vlad20012 <beskvlad@gmail.com>
Procedural macro support feature depends on the following (experimental) features:
org.rust.cargo.evaluate.build.scripts
- enables building and collecting build artifacts including proc-macro libraries during importing of project structure. Enabled by defaultorg.rust.macros.proc.function-like
- enables expansion of function-like procedural macros. Enabled by defaultorg.rust.macros.proc.derive
- enables expansion of derive procedural macros. Enabled by defaultorg.rust.macros.proc.attr
- enables expansion of attribute procedural macrosTo enable an experimental feature, type
Experimental feature
in the dialog ofHelp | Find Action
action, enable the corresponding items and reload the project model viaRefresh Cargo Projects
action in Cargo tool windoworg.rust.cargo.evaluate.build.scripts
experimental feature is enabled Compile only buildscripts and proc macros when fetching build scripts #6735aarch64-apple-darwin
target) CI&MACRO: expand proc macros on Apple Silicon machines #7307Fixes Support
paste::item!
macro. #4707Fixes Macros using
paste!
don't get expanded successfully #6983Fixes Unresolved reference / trait bound not satisfied error #7090
Fixes Syntax highlighting and autocompletion don't work inside macro (like async_stream, lazy_static and etc) #7242
Fixes Incorrect inference for
futures::try_join!()
#7608Fixes Tuples do not show the correct type #7699
Fixes Types aren't recognized when using Bevy queries #8049
Fixes mod created in the autocxx's macro is not recognized #8785
Fixes Macro expansion is producing false positive E0308 #9266
Fixes derive_more::Add and another Add trait impl: spurious error #4629
Fixes Plugin doesn't see generated functions #5468
Fixes Plugin doesn't recognize Display derive #5478
Fixes False positives for
Request<HelloRequest>
doesn't implementDebug
(required by {:?}) #5728Fixes "CustomError doesn't Display" false positive error using "failure" create #5954
Fixes Problem with #[derive] macro? #6036
Fixes False positive "Use of moved value" when Copy is derived by enumset #6489
Fixes Mismatched types [E0308] reported in Clion, but not with cargo check #6880
Fixes Missing methods introspection for fltk-rs #7158 (requires RES: resolve proc macros through
#[macro_use]
#7184)Fixes The trait method implemented through a derived macro cannot be prompted #7848
Fixes Regression in new engine for Rust macro expansion? #8193
Fixes False error when determining type of
decode
function ofBorshSerialize
trait #8415Fixes False positive error on the bevy Asset trait #8581
Fixes sea-orm ActiveModelBehavior #8610
Fixes False Error with strum #[derive(Display)]: enum doesn't implement Display #8847
Fixes False positive with auto-dereferencing #8856
Fixes intellij-rust parse thiserror::Error has problem #9133
Fixes false positive of lacking impl, if given from
derive_more
crate #9216Fixes Trait defined by custom derive macro can't be traced properly #9226
Fixes Support items generated by proc macros #1786
Fixes Support items generated by snafu derive macro #7365
Fixes SeaQL(sea-orm) derive macros not detected #7901
Fixes False positive 'unresolved reference' #7997
Fixes Code completion regression in web-sys? #5104
Fixes [Request] versuch::try_fn attribute macro support #5239
Fixes Bug: Macro Declared Deref not identified correctly #5748
Fixes Wrong inference for amethyst
Option<Handle<SpriteSheet>>::as_ref().unwrap().clone()
#5896Fixes False positive "main function not found" with rocket #5975 (the corresponding changes in the inspection made in INSP: properly process items by
Main function not found
#9914)Fixes Can't find async function #6006
Fixes False E0050, E0185 #6091
Fixes Unresolved reference while rustc is ok #6093
Fixes Inspector incorrectly points out that #[derive] can only be used on structs, enums and unions #6162 (requires changes in the annotator)
Fixes Unrecognised fields and no autocomplete [generated by macros] #6482
Fixes pin project struct doesn't have code completion #6938
Fixes Proc macro on struct which are generating new struct in crates failing #7610
Fixes #[async_trait] with 'async_trait lifetime is incorrectly flagged as being an experimental in-band lifetime #7863
Fixes Wrong error highlight with
#[inherent]
proc-macro #8350Fixes False positives with cxx #8369 (requires changes in
org.rust.ide.annotator.RsSyntaxErrorsAnnotator
)Fixes Ability to supress errors in Rust #8407
FIxes Analyzer doesn't consider macro expansion before flagging errors. #8640
Fixes Error E0107 - False positive while using tauri #9128
Fixes Function modification is not captured #9384
Fixes broken code navigation (minimal example included) IDEA Ultimate #9534
Fixes Take into account
allow
attributes generated by macro #9918Fixes #[proc_macro_attribute] field injection is not supported by syntax highlighter #9973
org.rust.cargo.evaluate.build.scripts
experimental feature by default Stabilise org.rust.cargo.evaluate.build.scripts #9402 Enable build script evaluation by default #9532org.rust.macros.proc.function-like
experimental feature by default Enablefunction-like
andderive
proc macro expansion by default #9729org.rust.macros.proc.derive
experimental feature by default Enablefunction-like
andderive
proc macro expansion by default #9729org.rust.macros.proc.attr
experimental feature by defaultAdding support for custom syntax introduced by proc macros #6367
Cannot find declaration to go to - mod link macro param #7170
The text was updated successfully, but these errors were encountered: