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

Use span snippet in all suggestions where possible #3023

Closed
estebank opened this issue Aug 9, 2018 · 2 comments
Closed

Use span snippet in all suggestions where possible #3023

estebank opened this issue Aug 9, 2018 · 2 comments

Comments

@estebank
Copy link
Contributor

estebank commented Aug 9, 2018

Suggestions should first attempt to use a span snippet instead of generated code (presumably a Ty) to avoid suggesting incorrect code:

warning: use of `unwrap_or` followed by a function call
   --> policy.rs:481:46
    |
481 |         .iter().map(|a| a.into()).collect()).unwrap_or(vec![]),
    |                                              ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))`
    |
    = note: #[warn(or_fun_call)] on by default
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#or_fun_call
@oli-obk
Copy link
Contributor

oli-obk commented Aug 10, 2018

Uh... that's what we're doing. But the span points to the expanded tokens. We need to figure out the unexpanded span for most of these things

@estebank
Copy link
Contributor Author

This could be sidestepped by pointing the span only to unwrap_or and suggest unwrap_or_else, instead of the entire call. To do so might require doing some span wrangling though :-/

bors bot added a commit that referenced this issue Oct 27, 2018
3366: Don't expand macros in some suggestions r=oli-obk a=phansch

Fixes #1148 
Fixes #1628
Fixes #2455
Fixes #3023
Fixes #3333
Fixes #3360

Co-authored-by: Philipp Hansch <dev@phansch.net>
bors bot added a commit that referenced this issue Oct 28, 2018
3217: Fix string_lit_as_bytes lint for macros r=phansch a=yaahallo

Prior to this change, string_lit_as_bytes would trigger for constructs
like `include_str!("filename").as_bytes()` and would recommend fixing it
by rewriting as `binclude_str!("filename")`.

This change updates the lint to act as an EarlyLintPass lint. It then
differentiates between string literals and macros that have bytes
yielding alternatives.

Closes #3205

3366: Don't expand macros in some suggestions r=oli-obk a=phansch

Fixes #1148 
Fixes #1628
Fixes #2455
Fixes #3023
Fixes #3333
Fixes #3360

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: Philipp Hansch <dev@phansch.net>
@bors bors bot closed this as completed in #3366 Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants