-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
ICE when attempting to split error message that contains " found" before "expected" into lines #31173
Comments
Kind of unfortunate that the formatting is done by splitting on substrings. It seems like it would be better to either include the line breaks in the error message from the start, or to do the substring search before substituting in user input. |
I ran into this using a closure that captured a local called fn main() {
let found = false;
(0..10).filter(|i| found)
} If I change that to
|
It's hard to tell from out-of-date PR diffs, but I found #19870 (comment) -- it sounds like it started out printing newlines at the error source, then @nrc thought this was fragile and asked for expected/found substring matching. I don't understand why that was preferred though, as this issue reveals how fraught substring-matching can be. Even if we resolve the ICE of slicing backwards, I fear it may still be imprecise about finding the right "expected" and "found" pieces. |
For example, this isn't an ICE, but it's still wrapped incorrectly: fn main() {
let expected = false;
(0..10).filter(|i| expected)
}
|
I don't recall what the earlier approach was and why I thought it was fragile. Probably to avoid mixing error formatting with error production. I agree substring matching is a bit gross. I think the proper fix here is for the error producing code to provide a struct with the expected/found values and then the error handler should format these (i.e., stick in the newlines, etc.). This should be easier now that errors are more structured. |
With #32756 this is what I see for @cuviper 's examples:
|
For the |
Unfortunately, projection errors do not come with a nice set of mismatched types. This is because the type equality check occurs within a higher-ranked context. Therefore, only the type error is reported. This is ugly but was always the situation. I will introduce better errors for the lower-ranked case in another commit. Fixes the last known occurence of rust-lang#31173
Unfortunately, projection errors do not come with a nice set of mismatched types. This is because the type equality check occurs within a higher-ranked context. Therefore, only the type error is reported. This is ugly but was always the situation. I will introduce better errors for the lower-ranked case in another commit. Fixes the last known occurence of rust-lang#31173
Centralize and clean type error reporting Refactors the code that handles type errors to be cleaner and fixes various edge cases. This made the already-bad "type mismatch resolving" error message somewhat uglier. I want to fix that in another commit before this PR is merged. Fixes #31173 r? @jonathandturner, cc @nikomatsakis
Centralize and clean type error reporting Refactors the code that handles type errors to be cleaner and fixes various edge cases. This made the already-bad "type mismatch resolving" error message somewhat uglier. I want to fix that in another commit before this PR is merged. Fixes #31173 r? @jonathandturner, cc @nikomatsakis
In librustc::session::split_msg_into_multiline().
With the error "type mismatch resolving
for<'r> <F2 as core::ops::FnOnce<(&'r mut core::option::Option<T>, found_opts::FoundOpt)>>::Output == core::result::Result<(), collections::string::String>
: expected type parameter, found ()",it finds the " found" in " found_opts::" before " found ()".
Then pos1 becomes (182, 191) and pos2= (91, 97), which makes
&msg[pos1.1..pos2.0]
at line 360 fail.The text was updated successfully, but these errors were encountered: