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

ANN: show type errors for references containing unknown types if mutability differs #5548

Merged
merged 1 commit into from Jun 16, 2020

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Jun 11, 2020

This PR changes error annotation to show a type error if you give an immutable reference where a mutable reference is expected, even if the type behind the reference is not fully resolved. I think that this is useful, because even if the types are unresolved, passing & where &mut is expected will be an error in any case and if we show the annotation (and solve it with a quick fix, that I'll send a separate PR for), it can help with actually resolving the type (this happens in the linked issue).

Fixes: #4705

@Kobzol Kobzol added this to In Progress in To test via automation Jun 12, 2020
Copy link
Member

@mchernyavsky mchernyavsky left a comment

Choose a reason for hiding this comment

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

Thanks!
bors r+

@mchernyavsky mchernyavsky added this to the v126 milestone Jun 16, 2020
@mchernyavsky mchernyavsky self-assigned this Jun 16, 2020
@mchernyavsky mchernyavsky modified the milestones: v126, v125 Jun 16, 2020
@bors
Copy link
Contributor

bors bot commented Jun 16, 2020

Build succeeded:

@bors bors bot merged commit 64644fc into intellij-rust:master Jun 16, 2020
To test automation moved this from In Progress to Test Jun 16, 2020
@Kobzol Kobzol deleted the type-check-ref-mut branch June 16, 2020 18:43
bors bot added a commit that referenced this pull request Jun 17, 2020
5550: INSP: add quick fix to convert immutable reference to mutable reference r=mchernyavsky a=Kobzol

This PR adds a quick fix to convert an immutable reference to a mutable one:
![refmut](https://user-images.githubusercontent.com/4539057/84370594-c125ff80-abd8-11ea-96ff-dbd407d3455c.gif)

The last test should be enabled if/after #5548 gets merged.

Umbrella issue: #1730
Fixes: #2472

Co-authored-by: Jakub Beránek <berykubik@gmail.com>
@lancelote lancelote moved this from Test to Done in To test Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
To test
  
Done
Development

Successfully merging this pull request may close these issues.

Highlight "types differ in mutability" errors if a variable type is not manually declared
2 participants