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

fix(ptr_as_ptr): handle std::ptr::null{_mut} #11913

Merged
merged 1 commit into from Dec 6, 2023

Conversation

KisaragiEffective
Copy link
Contributor

close #11066
close #11665
close #11911

Please write a short comment explaining your change (or "none" for internal only changes)

changelog: [ptr_as_ptr]: handle std::ptr::null and std::ptr::null_mut

@rustbot
Copy link
Collaborator

rustbot commented Dec 3, 2023

r? @llogiq

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 3, 2023
@KisaragiEffective KisaragiEffective changed the title fix: handle std::ptr::null{_mut} fix(ptr_as_ptr): handle std::ptr::null{_mut} Dec 3, 2023
@KisaragiEffective
Copy link
Contributor Author

I've rebased onto latest master.

enum OmitFollowedCastReason<'a> {
None,
Null(&'a QPath<'a>),
NullMut(&'a QPath<'a>),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for future improvement:
This should be replaced with check of:

  1. if calling function is <T>(...args) -> *{const,mut} T
  2. one of:
    • args does not contain or refer T -> we can give arbitrary T
    • check if it still pass type-checking if we change T=Src to T=Dst

@y21
Copy link
Member

y21 commented Dec 3, 2023

Does this also work for stuff like let p = ptr::null(); p as *const u8;? I imagine that runs into the same kinds of inference issues? Though not sure if it's possible to make it more "general" (avoiding FPs through other kinds of expressions) since we'd need to know if the source pointer type had inference variables before they were unified with the cast target, or something like that (or maybe it's stored somewhere?) 🤔

@llogiq
Copy link
Contributor

llogiq commented Dec 3, 2023

This looks like a solid improvement to me. Any further work can be done in a follow-up PR.

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 3, 2023

📌 Commit 8eea8b1 has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Dec 3, 2023

⌛ Testing commit 8eea8b1 with merge 018cf8b...

bors added a commit that referenced this pull request Dec 3, 2023
…llogiq

fix(ptr_as_ptr): handle `std::ptr::null{_mut}`

close #11066
close #11665
close #11911

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`ptr_as_ptr`]: handle `std::ptr::null` and `std::ptr::null_mut`
@bors
Copy link
Collaborator

bors commented Dec 3, 2023

💔 Test failed - checks-action_test

@llogiq
Copy link
Contributor

llogiq commented Dec 3, 2023

That's a weird one; doesn't seem like it has to do with this PR. Let's see if other PRs also fail.

@llogiq
Copy link
Contributor

llogiq commented Dec 6, 2023

@bors retry

@bors
Copy link
Collaborator

bors commented Dec 6, 2023

⌛ Testing commit 8eea8b1 with merge 2793e8d...

@bors
Copy link
Collaborator

bors commented Dec 6, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 2793e8d to master...

@bors bors merged commit 2793e8d into rust-lang:master Dec 6, 2023
5 checks passed
@KisaragiEffective KisaragiEffective deleted the fix/ptr-as-ptr-with-null branch December 6, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
5 participants