Skip to content
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

Error E0107 - False positive while using tauri #9128

Closed
RobDeFlop opened this issue Jul 28, 2022 · 3 comments · Fixed by #10607
Closed

Error E0107 - False positive while using tauri #9128

RobDeFlop opened this issue Jul 28, 2022 · 3 comments · Fixed by #10607
Labels
bug subsystem::highlighting Issues related to code highlighting subsystem::proc-macros Issues related to procedural macros

Comments

@RobDeFlop
Copy link

Environment

  • IntelliJ Rust plugin version: 0.4.175.4772-222
  • Rust toolchain version: 1.62.1 (e092d0b6b 2022-07-16) x86_64-pc-windows-msvc
  • IDE name and version: CLion 2022.2 (CL-222.3345.126)
  • Operating system: Windows 11 10.0
  • Macro expansion engine: new
  • Name resolution engine: new

Problem description

When you use Tauri and create a command to receive an event from the "frontend" and want to access the window as a param, it throws an E0107 Error for the Window data type that is a false positive. Reference is the official Tauri documentation

grafik

Steps to reproduce

Set up a tauri app and add an event to receive the invoked event from the "frontend".

#[tauri::command(async)]
async fn app_ready(window: Window) {
    println!("Received Event");
}
@RobDeFlop RobDeFlop changed the title E0107 false positive while using tauri Error E0107 - False positive while using tauri Jul 28, 2022
@sekwah41
Copy link

sekwah41 commented Dec 31, 2022

Just found this too now. Glad its reported.

Though looking at the source I can see why its flagged

pub struct Window<R: Runtime> {

@sekwah41
Copy link

sekwah41 commented Dec 31, 2022

I think technically the right way to state it is

#[tauri::command]
fn set_ui_theme<R: Runtime>(is_dark_mode: bool, window: tauri::Window<R>) {
    println!("set_ui_theme! {}", is_dark_mode);
}

So this plugin actually is probably correct to warn about it, but its doing red warnings against legit rust code.

@Undin Undin added subsystem::proc-macros Issues related to procedural macros subsystem::highlighting Issues related to code highlighting bug labels Dec 31, 2022
@Undin
Copy link
Member

Undin commented Dec 31, 2022

The plugin shows error annotation in this case because it doesn't expand attribute procedural macros by default for now.
As a result, it shows false positive error here.
But you can enable expansion of attributes macros with org.rust.macros.proc.attr experimental feature and it should solve your issue.
Don't forget to reload the project model via Refresh Cargo Projects action in Cargo tool window after it.
See #6908 for more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug subsystem::highlighting Issues related to code highlighting subsystem::proc-macros Issues related to procedural macros
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants