Skip to content

Restrict TUPLE_INDEX to only allow decimal digits - #2349

Open
matthewhughes934 wants to merge 1 commit into
rust-lang:masterfrom
matthewhughes934:tuple-index-must-be-decimal
Open

Restrict TUPLE_INDEX to only allow decimal digits#2349
matthewhughes934 wants to merge 1 commit into
rust-lang:masterfrom
matthewhughes934:tuple-index-must-be-decimal

Conversation

@matthewhughes934

Copy link
Copy Markdown

I was rather confused after reading the current definition and trying out some code:

struct Foo(u32);

fn main() {
    let f = Foo(1);
    let _ = f.0;    // ok
    let _ = f.0_0   // DEC_LTIERAL: error[E0609]: no field `0_0` on type `Foo`
    let _ = f.0b0;  // BIN_LITERAL: error[E0609]: no field `0b0` on type `Foo`
    let _ = f.0o0;  // OCT_LTERAL:  error[E0609]: no field `0o0` on type `Foo`
    let _ = f.0x0;  // HEX_LITERAL: error[E0609]: no field `0x0` on type `Foo`
}

I was rather confused after reading the current definition and trying
out some code:

    struct Foo(u32);

    fn main() {
        let f = Foo(1);
        let _ = f.0;    // ok
        let _ = f.0_0   // DEC_LTIERAL: error[E0609]: no field `0_0` on type `Foo`
        let _ = f.0b0;  // BIN_LITERAL: error[E0609]: no field `0b0` on type `Foo`
        let _ = f.0o0;  // OCT_LTERAL:  error[E0609]: no field `0o0` on type `Foo`
        let _ = f.0x0;  // HEX_LITERAL: error[E0609]: no field `0x0` on type `Foo`
    }
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Sep 2, 2026
@matthewhughes934

Copy link
Copy Markdown
Author

I thought it was about as much effort to raise a PR with this change as to raise an issue explaining the problem. Though I'm aware the contributing guide asks for opening issues in these cases, so sorry if I've jumped the gun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants