Skip to content

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented Aug 19, 2021

Basically this just shows the type of the inner expression of the ? expression as well as the type of the expression that the ? returns from:
Code_wIrCxMqLH9

Unless both of these types are core::result::Result in which case we show the error types only.
Code_Xruw5FCBNI

If both types are core::option::Option with different type params we do not show this special hover either as it would be pointless(instead fallback to default type hover)

Very much open to changes to the hover text here(I suppose we also want to show the actual type of the ? expression, that is its output type?).

Fixes #9931

@Veykril Veykril marked this pull request as draft August 19, 2021 17:05
@Veykril Veykril marked this pull request as ready for review August 19, 2021 17:13
@Veykril
Copy link
Member Author

Veykril commented Aug 19, 2021

r? @matklad

Copy link
Contributor

@matklad matklad left a comment

Choose a reason for hiding this comment

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

Looks plausible to me!

One potentail issue here is that hover is the largest (in terms of binary size) function in the ide crate. We might want to try to add mode software engineering here, and split this up in modules.

It does seem that hover works roughly by "let's compute this n bits of info, and then combine then into one string". It would be cool if each of n bit was serpatate module, and if they returned some rust Structs with hir types, with the top-level doing actual rendering.

r=me

infer::{Adjust, Adjustment, AutoBorrow},
infer::{
Adjust, Adjustment, AutoBorrow, BindingMode, Expectation, InferenceContext, TypeMismatch,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 drive by changes are ok if they make code consistent with the style guide!

@matklad
Copy link
Contributor

matklad commented Aug 30, 2021

While we are at it...

image

This should mention deref somehow. BTW, do we have an official name for winking pretzel &* ?

@Veykril
Copy link
Member Author

Veykril commented Aug 30, 2021

Ye adding some deref thingy there sounds reasonable. Another thing, we should also probably mention iterator item types for iterator types as well.

BTW, do we have an official name for winking pretzel &*?

I only know it as a reborrow, haven't heard a specific name like that for it yet 😄

@Veykril
Copy link
Member Author

Veykril commented Sep 1, 2021

bors r=matklad

@bors
Copy link
Contributor

bors bot commented Sep 1, 2021

@bors bors bot merged commit 25368d2 into rust-lang:master Sep 1, 2021
@Veykril Veykril deleted the hov branch September 1, 2021 09:34
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.

Hover over ? should show the type conversion

2 participants