Skip to content

Tuple error message unhelpful when more than 12 elements #15032

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

Closed
mdinger opened this issue Jun 19, 2014 · 2 comments
Closed

Tuple error message unhelpful when more than 12 elements #15032

mdinger opened this issue Jun 19, 2014 · 2 comments

Comments

@mdinger
Copy link
Contributor

mdinger commented Jun 19, 2014

12 element tuple works:

fn main() {
    let tup = (1,2,3,4,5,6,7,8,9,10,11,12);
    println!("{}", tup.val0());
}

13 element tuple doesn't:

fn main() {
    let tup = (1,2,3,4,5,6,7,8,9,10,11,12,13);
    println!("{}", tup.val0());
}

The error message is not helpful. It should state that tuples don't support more than 12 elements:

<anon>:3:24: 3:30 error: type `(<generic integer #0>,<generic integer #1>,<generic integer #2>,<generic integer #3>,<generic integer #4>,<generic integer #5>,<generic integer #6>,<generic integer #7>,<generic integer #8>,<generic integer #9>,<generic integer #10>,<generic integer #11>,<generic integer #12>)` does not implement any method in scope named `val0`
<anon>:3     println!("{}", tup.val0());
                                ^~~~~~
<anon>:3:20: 3:30 error: cannot determine a type for this bounded type parameter: unconstrained type
<anon>:3     println!("{}", tup.val0());
                            ^~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
<anon>:3:5: 3:32 note: expansion site
playpen: application terminated with error code 101
@huonw
Copy link
Member

huonw commented Jun 19, 2014

Tuples do support more than 12 elements, it's just the traits providing methods like val0 in the standard library are only (manually) implemented for tuples upto 12 elements.

E.g. this works fine

fn main() {
    let t = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
    let (x, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)  = t;
    println!("{}", x);
}

(That said those traits are a hack.)

@mdinger
Copy link
Contributor Author

mdinger commented Jun 19, 2014

Thanks for your clarifying. I'll close because the premise was wrong.

@mdinger mdinger closed this as completed Jun 19, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 19, 2023
…nicola

fix: exclude Markdown injection grammar from .vscodeignore.

Enables Markdown injection introduced in rust-lang#14866 but wasn't included in release due to the grammar file being ignored by `.vscodeignore`. I verified the fix by doing `vsce package` and installing it manually:

<img width="779" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/bb3da211-a017-45bf-ba7b-4122335aa6e8">

<img width="780" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/1593486/aa0c4025-e72c-4b0c-9d40-44c33e7d45e6">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants