Skip to content

[bug] rust-analyzer throws errors about missing field referenced_by when tauri-utils is built without debug_assertions #13865

Closed

Description

@stewartadam

Describe the bug

Disabling debug_assertions when building tauri-utils causes IDE errors from rust-analyzer when calling tauri::generate_context!() claiming that 'referenced_by' field is missing several times:

Image

I discovered this because I with the following in my Cargo.toml for improved performance of dev builds:

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev]
incremental = true            # Improve consecutive recompile performance
opt-level = 1                 # Enable a small amount of optimization in debug mode

[profile.dev.package."*"]
incremental = true
debug = false
opt-level = 3
codegen-units = 16
overflow-checks = false
debug-assertions = false

Using cargo-expand before and after enabling debug_assertions I can see that the ResolvedCommand struct is generated in both cases, but referenced_by field is omitted when it is disabled:

cargo-expand output

debug_assertions = false:

                                    map.insert(
                                        "plugin:app|identifier".into(),
                                        <[_]>::into_vec(
                                            ::alloc::boxed::box_new([
                                                ::tauri::utils::acl::resolved::ResolvedCommand {
                                                    context: ::tauri::utils::acl::ExecutionContext::Local,
                                                    windows: <[_]>::into_vec(
                                                        ::alloc::boxed::box_new(["main".parse().unwrap()]),
                                                    ),
                                                    webviews: ::alloc::vec::Vec::new(),
                                                    scope_id: ::core::option::Option::None,
                                                },
                                            ]),
                                        ),
                                    );

debug_assertions = true:

                                    map.insert(
                                        "plugin:app|identifier".into(),
                                        <[_]>::into_vec(
                                            ::alloc::boxed::box_new([
                                                ::tauri::utils::acl::resolved::ResolvedCommand {
                                                    context: ::tauri::utils::acl::ExecutionContext::Local,
                                                    referenced_by: ::tauri::utils::acl::resolved::ResolvedCommandReference {
                                                        capability: "default".into(),
                                                        permission: "allow-identifier".into(),
                                                    },
                                                    windows: <[_]>::into_vec(
                                                        ::alloc::boxed::box_new(["main".parse().unwrap()]),
                                                    ),
                                                    webviews: ::alloc::vec::Vec::new(),
                                                    scope_id: ::core::option::Option::None,
                                                },
                                            ]),
                                        ),
                                    );

Since the app actually launches fine without referenced_by, my guess is the parameter should be made optional to avoid IDE errors.

Reproduction

  1. cargo tauri init
  2. Edit cargo.toml and set debug_assertions = false
  3. Open lib.rs in IDE

Expected behavior

No errors

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.5.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.90.0-nightly (e43d139a8 2025-07-09)
    ✔ cargo: 1.90.0-nightly (930b4f62c 2025-06-28)
    ✔ rustup: 1.28.2 (2025-04-28)
    ✔ Rust toolchain: nightly-aarch64-apple-darwin (overridden by environment variable RUSTUP_TOOLCHAIN)
    - node: 24.2.0
    - npm: 11.3.0

[-] Packages
    - tauri 🦀: 2.6.2
    - tauri-build 🦀: 2.3.0
    - wry 🦀: 0.52.1
    - tao 🦀: 0.34.0
    - tauri-cli 🦀: 2.5.0 (outdated, latest: 2.6.2)

[-] Plugins

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: webui
    - devUrl: localhost:5174

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions