rust-analyzer: No such field Error Code E0560 for Tauri in build(tauri::generate_context!())

rust-analyzer version: 0.3.2264-standalone (8364ef2997 2025-01-12)

rustc version: 1.83.0

editor or extension: VSCode, extension version 0.3.2264

relevant settings: Nothing special

code snippet to reproduce:


async fn start() {
    info!(
        "{}: Main.rs: Starting the application...",
        Utc::now().format("%a,%b,%e,%T,%Y")
    );

    tauri::Builder
        ::default()
        .plugin(tauri_plugin_store::Builder::new().build())
        .plugin(tauri_plugin_process::init())
        .plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
            info!(
                "Another instance attempted to launch with arguments: {:?}, cwd: {:?}",
                args, cwd
            );

            // Bring the main window to focus if it exists
            if let Some(main_window) = app.get_webview_window("main") {
                if main_window.is_visible().unwrap() {
                    info!("Window is already visible")
                } else {
                    match main_window.show() {
                        Ok(_) => {
                            info!("opened main windows")
                        },
                        Err(e) => error!("Error showing main window: {}", e)
                    };
                };
                main_window.set_focus().unwrap_or_else(|e| {
                    error!("Failed to focus on main window: {}", e);
                });
            };

            if let Some(splashscreen_window) = app.get_webview_window("splashscreen") {
                if splashscreen_window.is_visible().unwrap() {
                    info!("Window is already visible")
                } else {
                    match splashscreen_window.show() {
                        Ok(_) => {
                            info!("opened main windows")
                        },
                        Err(e) => error!("Error showing main window: {}", e)
                    };
                };
                splashscreen_window.set_focus().unwrap_or_else(|e| {
                    error!("Failed to focus on splashscreen window: {}", e);
                });
            }
        }))
        .setup(|app| {
           // Not really important as the issues lies within tauri::generate_context!()
            Ok(())
        })
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_shell::init())
        .plugin(tauri_plugin_updater::Builder::new().build())
        .invoke_handler(tauri::generate_handler![
            close_splashscreen,
        ])
        .build(tauri::generate_context!()) // no such field Error Code E0560
        .expect("error while building tauri application")
        .run();
}

Error is : no such field Error Code E0560 It also show 175 errors with the exact same code.

This only started happening since the new update of rust-analyzer and I am not the only one having it. Going back to an older version fix this bug. Thank you !

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 22 (8 by maintainers)

Most upvoted comments

No, the fix will be included in the release on Monday.

For now setting the config key rust-analyzer.cargo.cfgs to ["debug_assertions"], will solve your problem. We are going to figure out a way to not burden the end user with this in a few days.

Looks like it is working good in Version 0.4.2268

A fix for this should be available in the latest nightly (from a couple of minutes ago).

@programmingdumpster F1, then “Preferences: Open User Settings” or “Preferences: Open User Settings (JSON)”.

@CarrotRub that’s a pre-existing error that goes away if you disable experimental diagnostics.

What does tauri::generate_context!() expand to? There’s a command to expand a macro.

Had to upload (too long) as .txt (.rs not allowed)

expanded generate_context.rs.txt