This website requires JavaScript.
Explore
Help
Register
Sign In
mikros
/
rust
Watch
1
Star
0
Fork
0
You've already forked rust
Code
Issues
Pull Requests
Packages
Projects
Releases
Wiki
Activity
a733082be9
rust
/
tests
/
ui
/
codemap_tests
/
tab_2.rs
6 lines
79 B
Rust
Raw
Normal View
History
Unescape
Escape
Fix mispositioned error indicators Fixes #38384 Most of the Rust community uses 4 spaces for indentation, but there are also tab users of Rust (including myself!). This patch fixes a bug in error printing which mispositions error indicators when near code with tabs. The code attempted to fix the issue by replacing spaces with tabs, but it sadly wasn't enough, as sometimes you may not print spaces but _ or ^ instead. This patch employs the reverse strategy: it replaces each tab with a space, so that the number of _ and ^ and spaces in error indicators below the code snippet line up perfectly. In a study [1] preceeding this patch, we could see that this strategy is also chosen by gcc version 6.3.0. Its not perfect, as the output is not beautiful, but its the easiest to implement. If anyone wants to improve on this, be my guest! This patch is meant as improvement of the status quo, not as perfect end status. It fixes the actual issue of mispositioning error indicators. [1]: https://github.com/rust-lang/rust/issues/38384#issuecomment-326813710
2017-09-07 01:47:13 -05:00
// ignore-tidy-tab
fn
main
(
)
{
Merge cfail and ui tests into ui tests
2017-11-20 06:13:27 -06:00
"
"
"
; //~ ERROR unterminated double quote
Fix mispositioned error indicators Fixes #38384 Most of the Rust community uses 4 spaces for indentation, but there are also tab users of Rust (including myself!). This patch fixes a bug in error printing which mispositions error indicators when near code with tabs. The code attempted to fix the issue by replacing spaces with tabs, but it sadly wasn't enough, as sometimes you may not print spaces but _ or ^ instead. This patch employs the reverse strategy: it replaces each tab with a space, so that the number of _ and ^ and spaces in error indicators below the code snippet line up perfectly. In a study [1] preceeding this patch, we could see that this strategy is also chosen by gcc version 6.3.0. Its not perfect, as the output is not beautiful, but its the easiest to implement. If anyone wants to improve on this, be my guest! This patch is meant as improvement of the status quo, not as perfect end status. It fixes the actual issue of mispositioning error indicators. [1]: https://github.com/rust-lang/rust/issues/38384#issuecomment-326813710
2017-09-07 01:47:13 -05:00
}
Reference in New Issue
Copy Permalink