Skip to content

Suggestion for using function call instead of method call syntax incorrectly marked machine applicable #101920

Closed
@jonas-schievink

Description

@jonas-schievink
fn main() {
    let b = Box::new(0);
    let ptr = b.into_raw();
}

Current output:

error[E0599]: no method named `into_raw` found for struct `Box<{integer}>` in the current scope
 --> src/main.rs:3:17
  |
3 |     let ptr = b.into_raw();
  |               --^^^^^^^^
  |               | |
  |               | this is an associated function, not a method
  |               help: use associated function syntax instead: `Box::<{integer}>::into_raw`
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
  = note: the candidate is defined in an impl for the type `Box<T, A>`

However, the "help: use associated function syntax instead: Box::<{integer}>::into_raw" suggestion is internally marked as "machine applicable", even though it contains the {integer} placeholder. Running cargo fix --broken-code on this code, or using rust-analyzer's check-on-save feature and applying the quickfix thus results in invalid code:

fn main() {
    let b = Box::new(0);
    let ptr = Box::<{integer}>::into_raw();
}

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