]> git.lizzy.rs Git - rust.git/commit
in which unused-parens suggestions heed what the user actually wrote
authorZack M. Davis <code@zackmdavis.net>
Wed, 17 Oct 2018 04:36:02 +0000 (21:36 -0700)
committerZack M. Davis <code@zackmdavis.net>
Wed, 17 Oct 2018 04:36:02 +0000 (21:36 -0700)
commit475be10dbd5bef7c37d58f2d5f1905123cb6e19e
tree0dde10a02c8711ab79fa8436cf7b87a3fdb16a79
parent01ca85becd45a4115bd5a1b367a1667c06f0906b
in which unused-parens suggestions heed what the user actually wrote

Aaron Hill pointed out that unnecessary parens around a macro call
(paradigmatically, `format!`) yielded a suggestion of hideous
macro-expanded code. (The slightly unusual choice of using the
pretty-printer to compose suggestions was quite recently commented on
in the commit message for 1081bbbfc ("abolish ICE when pretty-printing
async block"), but without any grounds to condemn it as a 𝘣𝘢𝘥
choice. Hill's report provides the grounds.) `span_to_snippet` is
fallable as far as the type system is concerned (because, who knows,
macros or something), so the pretty-printing can live on in the
oft-neglected `else` branch.

Resolves #55109.
src/librustc_lint/unused.rs
src/test/ui/lint/suggestions.rs
src/test/ui/lint/suggestions.stderr