Skip to content

Unused braces lint triggers on partial move into ref pattern. #70717

Description

@rodrimati1992

I tried this code:

fn main(){
    let a = (String::new(),0);
    let ref _b = {a.0};
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4b8d234e04e2d77ab45ecf3c41d59d58

I expected the code to compile without warnings.

Instead, the unused_braces lint was triggered:

warning: unnecessary braces around assigned value
 --> src/main.rs:4:18
  |
4 |     let ref _b = {a.0};
  |                  ^^^^^ help: remove these braces
  |
  = note: `#[warn(unused_braces)]` on by default

Meta

This bug happens in 1.44.0-nightly (2020-04-01 76b1198),not in Rust beta nor stable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions