{"action":"created","issue":{"url":"https://api.github.com/repos/nrc/rustfmt/issues/290","labels_url":"https://api.github.com/repos/nrc/rustfmt/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/nrc/rustfmt/issues/290/comments","events_url":"https://api.github.com/repos/nrc/rustfmt/issues/290/events","html_url":"https://github.com/nrc/rustfmt/pull/290","id":105144932,"number":290,"title":"Initial implementation of hard tab indentation.","user":{"login":"SiegeLord","id":480550,"avatar_url":"https://avatars.githubusercontent.com/u/480550?v=3","gravatar_id":"","url":"https://api.github.com/users/SiegeLord","html_url":"https://github.com/SiegeLord","followers_url":"https://api.github.com/users/SiegeLord/followers","following_url":"https://api.github.com/users/SiegeLord/following{/other_user}","gists_url":"https://api.github.com/users/SiegeLord/gists{/gist_id}","starred_url":"https://api.github.com/users/SiegeLord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiegeLord/subscriptions","organizations_url":"https://api.github.com/users/SiegeLord/orgs","repos_url":"https://api.github.com/users/SiegeLord/repos","events_url":"https://api.github.com/users/SiegeLord/events{/privacy}","received_events_url":"https://api.github.com/users/SiegeLord/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-09-07T04:40:53Z","updated_at":"2015-09-19T22:55:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nrc/rustfmt/pulls/290","html_url":"https://github.com/nrc/rustfmt/pull/290","diff_url":"https://github.com/nrc/rustfmt/pull/290.diff","patch_url":"https://github.com/nrc/rustfmt/pull/290.patch"},"body":"This is a draft, as perhaps not all implementation choices I made are ideal. I also wasn't sure what to do with tests.\r\n\r\nThe general idea of this change is to switch from using a plain `usize` to track indentation to a special `Indent` type which tracks block indentation and alignment (for visual alignment) separately. Adding the hard tab mode on top of that is then trivial. This increased type safety should prevent bugs where width is passed instead of offset and vice versa (e.g. see a possible bug in `src/items.rs:61-62`).\r\n\r\nI've tested the patch and it seems to work fine in most cases. It doesn't interact well with visual indentation for function arguments + closures, but I don't think there's expectation that every possible indentation configuration option should result in a sensible style."},"comment":{"url":"https://api.github.com/repos/nrc/rustfmt/issues/comments/141712584","html_url":"https://github.com/nrc/rustfmt/pull/290#issuecomment-141712584","issue_url":"https://api.github.com/repos/nrc/rustfmt/issues/290","id":141712584,"user":{"login":"SiegeLord","id":480550,"avatar_url":"https://avatars.githubusercontent.com/u/480550?v=3","gravatar_id":"","url":"https://api.github.com/users/SiegeLord","html_url":"https://github.com/SiegeLord","followers_url":"https://api.github.com/users/SiegeLord/followers","following_url":"https://api.github.com/users/SiegeLord/following{/other_user}","gists_url":"https://api.github.com/users/SiegeLord/gists{/gist_id}","starred_url":"https://api.github.com/users/SiegeLord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiegeLord/subscriptions","organizations_url":"https://api.github.com/users/SiegeLord/orgs","repos_url":"https://api.github.com/users/SiegeLord/repos","events_url":"https://api.github.com/users/SiegeLord/events{/privacy}","received_events_url":"https://api.github.com/users/SiegeLord/received_events","type":"User","site_admin":false},"created_at":"2015-09-19T22:55:55Z","updated_at":"2015-09-19T22:55:55Z","body":"So I looked into this, and it turned out to be a bit more complicated than I initially thought it might be. While it's easy to make something compile, there are many spots in the code where the context's `block_indent` goes out of sync from the `offset` parameter. E.g. consider formatting this:\r\n\r\n```rust\r\nmatch x {\r\n    Some(x) if x > 0 ||\r\n            x < 0 || { // offset contains one block indent and some alignment spaces, block_indent is just the block indent\r\n        x; // only block_indent has the information to align this\r\n    }\r\n}\r\n```\r\n\r\nSure, you can drop the alignment when you indent the contents of that block, but then that breaks some other pieces of code:\r\n\r\n```rust\r\naaaaaaaaaaaaaaaa.map(|x| {\r\n                        x; // now x needs to be aligned with both tabs and spaces\r\n                    })\r\n```\r\n\r\nI'm sure it can all be fixed, but I think it'd take the greater part of the day, I think."}}