Skip to content

Conversation

@flip1995
Copy link
Member

Resolves #2930

The applicability levels added to the span_lint_and_sugg and multispan_sugg (do we need this on multispan_sugg?) functions are how I felt would be the best fitting ones.

I haven't tested this yet, because I wanted to wait for the new nightly instead of doing this manual. 😄

cc @Manishearth

snippet(cx, haystack.span, ".."),
snippet(cx, needle.span, "..")));
snippet(cx, needle.span, "..")),
Applicability::HasPlaceholders);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only "maybe" has placeholders. We should make the snippet function return a tuple of Applicability and snippet-String

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best thing to do here would be to have it accept &mut Applicability IMO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

let mut applicability = span.into(); // if macro-ish, makes it MaybeIncorrect
let foo = span_to_snippet(...., &mut applicability) // if Applicable, makes it HasPlaceholders in the macro case

@Manishearth
Copy link
Member

FWIW http://github.com/kennytm/rustup-toolchain-install-master lets you locally build clippy on trunk

@flip1995
Copy link
Member Author

FWIW http://github.com/kennytm/rustup-toolchain-install-master lets you locally build clippy on trunk

Nice to know! Thanks!

@killercup
Copy link
Contributor

Thanks so much for doing this!

@oli-obk oli-obk closed this Jul 22, 2018
@oli-obk oli-obk reopened this Jul 22, 2018
@oli-obk oli-obk closed this Jul 24, 2018
@oli-obk oli-obk reopened this Jul 24, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jul 24, 2018

needs a rebase

@flip1995
Copy link
Member Author

Should I add the Applicability argument to the snippet function in this PR or in a separate one?

@phansch phansch added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 29, 2018
@flip1995 flip1995 added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Sep 23, 2018
"this `.fold` can be written more succinctly using another method",
"try",
sugg,
Applicability::HasPlaceholders,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to change this to Applicability::MaybeIncorrect. See #3069 and #3303.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is a stale PR to remind me (and others) that this should be done sometimes. When I'm (or someone else) continues working on this, I would start from scratch and go over these Applicability levels again (Also taking #3191 into consideration).

But yeah Applicability::MaybeIncorrect would probably be better here.

@flip1995
Copy link
Member Author

Closing in favor of #3459

@flip1995 flip1995 deleted the applicability branch November 27, 2018 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants