Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Incorrect diagnostic when the feature isn't enabled #39

Closed
rust-lang/rust
#84358
@ChrisPardy

Description

@ChrisPardy

Compiling tte following code using the old capture logic

#![feature(rustc_attrs)]

struct S(i32);

fn foo() {
    let b = Box::new(S(10));
    
    let c = #[rustc_capture_analysis] || {
        let _b = b.0;
    };
    
    c();
}

prints the following diagnostic when compiled(view on playground):

note: Min Capture b[] -> ImmBorrow
  --> src/lib.rs:9:39
   |
9  |       let c = #[rustc_capture_analysis] || {
   |  _______________________________________^
10 | |         let _b = b.0;
   | |                  ^^^ b[] captured as ImmBorrow here
11 | |     };
   | |_____^ b[] used here

It should instead look something like:

note: Min Capture b[] -> ImmBorrow
  --> /users/cpardy/example2.rs:10:18
   |
10 |         let _b = b.0;
   |                  ^^^

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions