-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Changes to catch_fatal_errors in rustc driver #4545
Conversation
@bors r+ |
📌 Commit bf4a467 has been approved by |
Changes to catch_fatal_errors in rustc driver A [recent PR](https://github.com/rust-lang/rust/pull/60584/files#diff-707a0eda6b2f1a0537abc3d23133748cL1151) changed the function name from `report_ices_to_stderr_if_any` to `catch_fatal_errors`. This PR changes to using the new function name. changelog: none
💔 Test failed - checks-travis |
It looks like this or some other change causes an ICE in chalk, hyper and serde:
|
Do we maybe need to call |
@phansch it's surely different Rust PR, I guess it's failing this line in Clippy: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/types.rs#L243
If you look at the ICE, it's missing this part: Click me
This is what |
I wasn't able to reproduce this locally 🤔 Let's just retry, since the queue is empty anyway @bors try |
Changes to catch_fatal_errors in rustc driver A [recent PR](https://github.com/rust-lang/rust/pull/60584/files#diff-707a0eda6b2f1a0537abc3d23133748cL1151) changed the function name from `report_ices_to_stderr_if_any` to `catch_fatal_errors`. This PR changes to using the new function name. changelog: none
💔 Test failed - checks-travis |
This is why Clippy ICEs: rust-lang/rust@b456c82 |
Did you figure out a way to repro locally @flip1995? As I'm new to Clippy and Rust internals, any ideas on what change needs to happen to fix this? I'm more than willing to continue to shepherd this PR forward, just may need some tips as I'm still learning about MIR and late passes. Is it as simple as adding |
A [recent PR](https://github.com/rust-lang/rust/pull/60584/files#diff-707a0eda6b2f1a0537abc3d23133748cL1151) changed the function name from `report_ices_to_stderr_if_any` to `catch_fatal_errors`. This PR changes to using the new function name.
I've added |
I currently only have a few minutes a day for Clippy, due to my master thesis, so not yet. I will try to find a reproducer today. See this comment, for my findings: rust-lang/rust#64250 (comment). Like @mati865 pointed out, the line at fault is this one: rust-clippy/clippy_lints/src/types.rs Line 243 in 535bc1d
Yes, can you do this? |
The problem seems to be associated types. |
ping @Xanewok. Is this a rustc bug, related to rust-lang/rust#64250 or are we doing something wrong on the Clippy side? Error message
|
The OP fix is unrelated to the ICE (afaict) and corresponds to rust-lang/rls@39d617b on the RLS side. Having said that, the ICE mentioned by @flip1995 is caused by rust-lang/rust#64250, which promoted a debug assertion to a regular one, probably uncovering some bugs. To give a quick background information (to the best of my knowledge), the definitions are identified by a def path, where each segment and the definition itself are identifiable by a def ID. The HIR ID contains an owner (corresponds to a def id) and a local id. Since we use local ids to as the key to the typeck tables (owned by a def), this assertion fires whenever we try to access typeck tables with a HIR ID that don't share the same owner (since it can lead to subtle bugs). In this specific case it means that the
To fix the issue, technically you need to first query the |
Thanks for the insights! We should be able to fix this, with this information. |
So if we're using let (body_id, body_ty, fn_header, fn_decl) = primary_body_of(tcx, id)
.unwrap_or_else(|| {
span_bug!(span, "can't type-check body of {:?}", def_id);
}); This can be prevented by first checking with |
Yup, I'll get a new issue opened today. |
Okay, I'm most definitely out of my depth here. I don't want to end up blocking other merges since this seems to be a blocker all-up for Clippy unless I'm mistaken. I'm reading up and learning about Hir and all these stuff now, but not sure how to result (or test whether the changes fix the issue). I'm willing to continue to give it a go with some more guidance, I just don't want to become a blocker if it needs to get fixed quickly :P. |
I guess part of the issue needs to be fixed on the rustc side. |
@jolson88 Don't worry, you're not a blocker, maintainers can push to this PR.
Yes, I also think this is the case here. I think this is the same issue as rust-lang/rust#64250 (comment), just with fields of inner structs, instead of return types. Another ping @Xanewok (sorry for bothering you with this, but you fixed the typeck tables nesting for return types), what's your take on this? Minimal reproducer: trait Trait {
type Assoc;
}
fn func() {
struct A<T: Trait> {
field: T::Assoc,
}
} I think that this function also needs a fix: fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) {
let field_data = self.save_ctxt.get_field_data(field, parent_id);
if let Some(field_data) = field_data {
let hir_id = self.tcx.hir().node_to_hir_id(field.id);
self.dumper.dump_def(&access_from!(self.save_ctxt, field, hir_id), field_data);
}
} (It was untouched by your PR) |
@flip1995 woops, thanks for catching that! Need to nest the table when processing the struct, will work on the patch now. However, that bit of code is only executed in -Zsave-analysis and I don't think you run it together with Clippy? |
Thanks! No we don't run it in Clippy. That means we probably need to find another solution for the |
@flip1995 can you push your current state so we can get CI working again, even with false negatives? |
Is this a build bot error? The build is fail but it merged the PR. |
Oops, thanks. I should have paid more attention to it. |
Prevents LateContext::maybe_typeck_results() from returning data in a nested item without a body. Consequently, LateContext::qpath_res is less likely to ICE when called in a nested item. Would have prevented rust-lang/rust-clippy#4545, presumably.
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC ````@eddyb```` since you've done related work CC ````@flip1995```` FYI
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC `````@eddyb````` since you've done related work CC `````@flip1995````` FYI
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC ``````@eddyb`````` since you've done related work CC ``````@flip1995`````` FYI
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC ```````````@eddyb``````````` since you've done related work CC ```````````@flip1995``````````` FYI
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC ````````````@eddyb```````````` since you've done related work CC ````````````@flip1995```````````` FYI
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang#4545 CC ````````````@eddyb```````````` since you've done related work CC ````````````@flip1995```````````` FYI
A recent PR changed the function name from
report_ices_to_stderr_if_any
tocatch_fatal_errors
. This PR changes to using the new function name.changelog: none