Skip to content

loan paths leaking into borrowck errors #41962

Closed
@Manishearth

Description

@Manishearth
pub fn main(){
    let maybe = Some(vec![true, true]);

    loop {
        if let Some(thing) = maybe {
        }
    }
}

(playpen)

gives the error

error[E0382]: use of partially moved value: `maybe`
 --> test.rs:7:30
  |
7 |         if let Some(thing) = maybe {
  |                     -----    ^^^^^ value used here after move
  |                     |
  |                     value moved here
  |
  = note: move occurs because `(maybe:std::prelude::v1::Some).0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `(maybe:std::prelude::v1::Some).0`
 --> test.rs:7:21
  |
7 |         if let Some(thing) = maybe {
  |                     ^^^^^ value moved here in previous iteration of loop
  |
  = note: move occurs because `(maybe:std::prelude::v1::Some).0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error: aborting due to 2 previous errors

(maybe:std::prelude::v1::Some).0 seems to be MIR leaking into the UI

cc @jonathandturner @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions