Stream: t-compiler/rust-analyzer

Topic: Unsafe packed repr ref

Paul Faria (Jun 27 2020 at 18:49, on Zulip):

@matklad so I've wrapped up all of the comments on the unsafe packed repr ref pr (, but I have one item I haven't done yet. In rustc, when it encounters these lines:

let h = HasAligned{ a: NeedsAlign { a: 1 } };

It highlights h.a and points out that this method call causes an autoref which is an unsafe ref to a packed repr. Should I handle that in the current PR or as a follow-up? If we do tackle it, how would I even highlight it? Would it make sense to highlight the dot between the field expr and the method to call to signify that it's the call that's causing the issue, or do what rustc does and highlight h.a? But in the latter case, then should I create a new HighlightTag::Expr tag just for this case, or use Operator?

matklad (Jun 27 2020 at 18:54, on Zulip):

I think we should higlightn cals_autoref as if it were an unsafe function?

Paul Faria (Jun 27 2020 at 19:06, on Zulip):

That makes sense, though I wonder if that would be really confusing since the method itself wouldn't be marked unsafe.

Paul Faria (Jun 27 2020 at 19:10, on Zulip):

I'm also realizing I need to account for ref and & in bind patterns. Is it possible to determine the struct a field comes from when you're looking at a bind pattern? Or do I need to match on all patterns?

Paul Faria (Jun 27 2020 at 21:38, on Zulip):

@matklad accounting for ref and the auto ref method call nearly doubled the PR. I think it should be reviewed again, at least the additions

Paul Faria (Jun 30 2020 at 12:11, on Zulip):

@matklad just wanted to double check before merging, did you want to review the ref additions on @Florian Diebold already reviewed.

Last update: Jul 29 2021 at 08:45UTC