Skip to content

Add duration_subsec lint #2839

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

Merged
merged 4 commits into from Jun 12, 2018
Merged

Add duration_subsec lint #2839

merged 4 commits into from Jun 12, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jun 9, 2018

Closes #2543

@ghost ghost mentioned this pull request Jun 9, 2018
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
then {
let suggested_fn = match divisor {
1_000 => "subsec_micros",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could also complain about subsec_micros() / 1000 and similar other usages that have a dedicated method. You should be able to do this nicely by matching on (method_path.name.as_str(), divisor) to check all combinations that we want to lint

@ghost
Copy link
Author

ghost commented Jun 12, 2018

I made the changes suggested by @oli-obk .

@oli-obk
Copy link
Contributor

oli-obk commented Jun 12, 2018

Sweet! Thanks

@oli-obk oli-obk merged commit 26bc88d into rust-lang:master Jun 12, 2018
@ghost ghost deleted the duration_subsec_pr_2 branch June 16, 2018 14:19
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

Successfully merging this pull request may close these issues.

1 participant