Skip to content

Long line printing doesn't support tabs #78438

Closed
@est31

Description

@est31

The code that truncates long lines doesn't take (hard) tabs into account, so the lines printed are off.

Example code:

								fn main() {
									let money = 42i32;
									match money {
										v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
										v => println!("Enough money {}", v),
									}
								}

Gives the following error:

error[E0408]: variable `v` is not bound in all patterns
 --> src/main.rs:4:19
  |
4 | ...            v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
  |                                     -       ^   ^ pattern doesn't bind `v`
  |                                     |       |
  |                                     |       pattern doesn't bind `v`
  |                                     variable not in all patterns

error: aborting due to previous error

If you use four spaces instead of each tab

                                fn main() {
                                    let money = 42i32;
                                    match money {
                                        v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
                                        v => println!("Enough money {}", v),
                                    }
                                }

it works as expected:

error[E0408]: variable `v` is not bound in all patterns
 --> src/main.rs:4:49
  |
4 | ...   v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
  |       -       ^   ^ pattern doesn't bind `v`
  |       |       |
  |       |       pattern doesn't bind `v`
  |       variable not in all patterns

cc #45953 and #63402

cc @estebank

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions