Skip to content

Failed Type Annotations in For Loops #13395

@RylanYancey

Description

@RylanYancey

** Rust-Analyzer Version:** 0.3.1238-standalone

** Rustc Version:** rustc 1.64.1 (a55dd71d5 2022-09-19)

Rust-Analyzer fails to provide type annotations for variables in loops, giving them the {unknown} type.

Example 1:

    pub fn configure (&mut self, modules: &[Mod]) {

        let mut prev_size = self.input;

        for m in modules.iter() { // problem occurs here; 'm' is of type {unknown}
            self.modules.push((m.init(prev_size, self.batch_size), self.optim.init()));

            prev_size = m.output_size(prev_size);
        }
    }

Example 2:

    pub fn train (&mut self) {
        for data in self.dataset.iter() { // problem occurs here; 'data' is of type {unknown}
            
        }
    }

Issue persists after reinstalling rust-analyzer, restarting VSCode, and restarting my computer. RA successfully identifies the types of other variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions