Skip to content

incorrect "missing structure fields" on-the-fly diagnostic #19780

Open
@elenakrittik

Description

@elenakrittik

in the code snippet provided below, rust-analyzer incorrectly emits an on-the-fly diagnostic telling that field a is missing from the struct expression, even though it has a default value through the use of the default_field_values feature

rust-analyzer version: rust-analyzer version: 0.3.2362-standalone (fb133c8 2025-03-29)

rustc version: rustc 1.87.0-nightly (b48576b4d 2025-03-22)

editor or extension: VSCode 1.98.2, extension version same as RA version

relevant settings: none

repository link (if public, optional): https://github.com/elenakrittik/msf-bug

code snippet to reproduce:

#![feature(default_field_values)]
#![allow(clippy::no_effect)]
#![allow(dead_code)]

struct Struct {
    a: usize = 0,
    b: usize,
}

fn main() {
    Struct { b: 1, .. }; // <-- here
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableunstable featureC-featureCategory: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions