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

Tracking Issue: Bugs introduced by Rustup #3905 #3913

Closed
3 tasks done
flip1995 opened this issue Apr 1, 2019 · 7 comments
Closed
3 tasks done

Tracking Issue: Bugs introduced by Rustup #3905 #3913

flip1995 opened this issue Apr 1, 2019 · 7 comments
Labels
C-bug Category: Clippy is not doing the correct thing C-tracking-issue Category: Tracking Issue E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call for participation: writing tests L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@flip1995
Copy link
Member

flip1995 commented Apr 1, 2019

This is a tracking issue for the bugs introduced by #3905. This is only a summary, more debugging attempts can be found in the PR:

Summary: This FP happens, because the code is expanded to HIR code, which includes a line containing From::from(err). This gets linted, but shouldn't. Previously it got expanded to the same HIR code, but didn't get linted.

Minimal example:

use std::path::Path;
use std::fs;

fn main() {
    let path = Path::new(".");
    for _ in fs::read_dir(path)? {}
}
  • Missing suggestion on explicit_iter_loop

Summary: Even though span_lint_and_sugg is used, no suggestion is displayed, but also no error or ICE. This problem came up once before on something completely unrelated: #3582 (comment). (This could be a problem in rustc, in the suggestion emitting code.)

Minimal example:

#[warn(clippy::explicit_iter_loop)]
fn main() {
    let v = vec![1];
    for _ in v.iter() { }
}
  • FN into_iter_on_array when into_iter() is called in the for-loop head

Summary: The problem is, that the into_iter MethodCall in the expanded HIR code is seen as macro expanded code, so that is_macro returns true for the span of the MethodCall expression. The HIR expanded code didn't change recently, so something must have changed in rustc, determining if an expression comes from a macro expansion.

Minimal example:

fn main() {
    for _ in [1, 2, 3].into_iter() {}
}
@flip1995 flip1995 added C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions E-needs-test Call for participation: writing tests E-help-wanted Call for participation: Help is requested to fix this issue. C-tracking-issue Category: Tracking Issue labels Apr 1, 2019
@phansch
Copy link
Member

phansch commented Apr 10, 2019

This is not an issue anymore, since the changes have been rolled back, or?

@Manishearth
Copy link
Member

Only the libtest changes were rolled back

@flip1995
Copy link
Member Author

flip1995 commented Apr 10, 2019

Regression tests are in #3936

@flip1995
Copy link
Member Author

Citing @estebank from #3944 (comment): (identity_conversion bug)

@flip1995 I believe we can get around that by touching https://github.com/rust-lang/rust/blob/9217fe0e2f04d61dd29c9aaebee2c993705e1d26/src/librustc/hir/lowering.rs#L4667-L4774

We can mark any of the mentioned spans with CompilerDesugaringKind::QuestionMark as a reason, we just need to identify which span it should be (or mark all of them, which should be fine, depending on how that mark is used elsewhere).

@ReinierMaas
Copy link

I would have found this problem quicker if it was mentioned in the Lints: Known problems

@flip1995
Copy link
Member Author

identity_conversion is fixed in the latest version. a5bcaf5

@flip1995
Copy link
Member Author

Everything listed here got fixed. Verified in #3936

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 C-tracking-issue Category: Tracking Issue E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call for participation: writing tests L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

4 participants