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

Unsupported default function parameters should have an explicit diagnostic #137310

Open
cyrgani opened this issue Feb 20, 2025 · 0 comments · May be fixed by #137396
Open

Unsupported default function parameters should have an explicit diagnostic #137310

cyrgani opened this issue Feb 20, 2025 · 0 comments · May be fixed by #137396
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cyrgani
Copy link
Contributor

cyrgani commented Feb 20, 2025

Code

fn f(x: u8 = 0) {}

Current output

error: expected parameter name, found `=`
 --> src/lib.rs:1:12
  |
1 | fn f(x: u8 = 0) {
  |            ^ expected parameter name

error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `=`
 --> src/lib.rs:1:12
  |
1 | fn f(x: u8 = 0) {
  |           -^ expected one of 7 possible tokens
  |           |
  |           help: missing `,`

Desired output

error: default function parameters are not supported

Rationale and extra context

especially since #![feature(default_field_values)] uses the same syntax, this seems plausible to try

Other cases

Rust Version

1.87.0-nightly

(2025-02-19 f280acf4c743806abbbb)

Anything else?

No response

@cyrgani cyrgani added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 20, 2025
@cyrgani cyrgani changed the title Unsupported default dunction parameters should have an explicit diagnostic Unsupported default function parameters should have an explicit diagnostic Feb 20, 2025
@fmease fmease added the A-parser Area: The parsing of Rust source code to an AST label Feb 20, 2025
@compiler-errors compiler-errors linked a pull request Feb 21, 2025 that will close this issue
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 A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants