KEMBAR78
Remove `IUnknownImpl::from_inner_ref` as no longer needed by sivadeilra · Pull Request #3513 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@sivadeilra
Copy link
Collaborator

This PR cleans up part of #3055, which improved COM object support.

The IUnknownImpl::from_inner_ref method predates the new ComObject API. It allows unsafe code to cast from &T to &T_Impl. This is a very dangerous operation because it "widens" the pointer; it requires that &T point to a T that is embedded within a T_Impl.

This was necessary for some situations before the new ComObject API, but is is completely unnecessary now. The new ComObject API provides safe ways to do the same thing. Also, this cast is unnecessary because all COM interface trait implementations are done on T_Impl types, not on T, so this method is unnecessary.

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

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

Excellent thanks!

@kennykerr kennykerr changed the title Remove IUnknownImpl::from_inner_ref Remove IUnknownImpl::from_inner_ref as it is no longer needed Feb 24, 2025
@kennykerr kennykerr changed the title Remove IUnknownImpl::from_inner_ref as it is no longer needed Remove IUnknownImpl::from_inner_ref as no longer needed Feb 24, 2025
@kennykerr kennykerr merged commit c1f45a4 into microsoft:master Feb 24, 2025
34 checks passed
@sivadeilra sivadeilra deleted the user/ardavis/remove-from-inner-ref branch February 24, 2025 22:04
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.

3 participants