Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jonas-schievink opened this issue Sep 16, 2022 · 0 comments · Fixed by #101990
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@jonas-schievink
Copy link
Contributor

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();
}
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. labels Sep 16, 2022
@TaKO8Ki TaKO8Ki self-assigned this Sep 17, 2022
@TaKO8Ki TaKO8Ki removed their assignment Sep 20, 2022
@bors bors closed this as completed in 5eef9b2 Nov 10, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…lder-method, r=compiler-errors

Fix auto-application of associated generic functions with placeholders

Fixes rust-lang#101920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants