-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Highlight parts of fn in type errors #66682
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Nice! |
When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each.
b48ec30
to
d92355c
Compare
values.0.push_normal(", ".to_string()); | ||
} | ||
values.0.push("...".to_string(), !sig2.c_variadic); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a lot of things are repeated twice in this method; could we try to rewrite things so that it isn't repeated by computing the diffs first and then doing all the logic for a single case?
values | ||
} | ||
|
||
(ty::FnPtr(sig1), ty::FnDef(did2, substs2)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, this method is some 325+ LOC... would be good to split it up
c2b1ed3
to
9d7774c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this is a really great improvement! Like @Centril has mentioned, cmp_fn_sig
feels quite repetitive, but I can't think of a nice way to improve it. Feel free to r=me if you're happy with this.
@bors r=davidtwco @davidtwco @Centril, I will make a follow up PR to split out |
📌 Commit 9d7774c has been approved by |
Highlight parts of fn in type errors When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each. Examples: <img width="699" alt="" src="https://user-images.githubusercontent.com/1606434/69487597-ab561600-0e11-11ea-9b4e-d4fd9e91d5dc.png"> <img width="528" alt="" src="https://user-images.githubusercontent.com/1606434/69487207-9033d800-0e0a-11ea-93e3-8c4d002411a5.png"> <img width="468" alt="" src="https://user-images.githubusercontent.com/1606434/69487208-9033d800-0e0a-11ea-92e3-2b2cee120335.png"> <img width="775" alt="" src="https://user-images.githubusercontent.com/1606434/69487209-9033d800-0e0a-11ea-9e68-7f6ed5c8cb08.png">
☀️ Test successful - checks-azure |
When a type error arises between two fn items, fn pointers or tuples,
highlight only the differing parts of each.
Examples: