Skip to content
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

suggested changes should not expand format! to $crate::fmt::format($crate::__export::format_args! #6838

Closed
tdyas opened this issue Mar 4, 2021 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@tdyas
Copy link

tdyas commented Mar 4, 2021

Code in question:

error: manual implementation of `Option::map`
    --> rule_graph/src/builder.rs:1166:9
     |
1166 | /         if let Some(errors) = errored.get(&node_id) {
1167 | |           Some(format!("{}:\n{}", node, errors.join("\n")))
1168 | |         } else {
1169 | |           None
1170 | |         }
     | |_________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
help: try this
     |
1166 |         errored.get(&node_id).map(|errors| {
1167 |         let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
1168 |         res
1169 |     })
     |

I expected the suggested change to keep format! the same and to not expand it to $crate::fmt::format($crate::__export::format_args!.

Meta

cargo 1.52.0-nightly (bf5a5d5e5 2021-02-18)
release: 1.52.0
commit-hash: bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070
commit-date: 2021-02-18

This happens with rustc as of 6f7673d077add6b9a066e988b1b8b132a8193d6c. (Dumping the version would not be helpful since the copy of rustc in question contains a local reversion from tracking down an unrelated ICE that I had encountered, just documenting this issue as I saw it).

@tdyas tdyas added the C-bug Category: Clippy is not doing the correct thing label Mar 4, 2021
@matthiaskrgr
Copy link
Member

Thanks, this is a duplicate of #6811 which has already been fixed in #6801 but the change has not landed in rustc tarballs yet.
Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants