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: prefer (*p).clone to p.clone if the p is a raw pointer #127114

Merged
merged 1 commit into from
Jun 30, 2024

Conversation

linyihai
Copy link
Contributor

Fixes #126863

I wonder if there is a better way to solve the regression problem of this test case:
tests/ui/borrowck/issue-20801.rs.
It's okay to drop the dereference symbol in this scenario.

But it's not correct in #126863

help: consider removing the dereference here
  |
5 -         let inner: String = *p;
5 +         let inner: String = p;

I haven't found out how to tell if clone pointer is allowed, i.e. no type mismatch occurs

@rustbot
Copy link
Collaborator

rustbot commented Jun 29, 2024

r? @Nadrieril

rustbot has assigned @Nadrieril.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2024
Copy link
Member

@Nadrieril Nadrieril left a comment

Choose a reason for hiding this comment

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

Hi! LGTM except two nits

@Nadrieril
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 29, 2024

📌 Commit 8dc36c1 has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 29, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 29, 2024
fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer

Fixes rust-lang#126863

I wonder if there is a better way to solve the regression problem of this test case:
`tests/ui/borrowck/issue-20801.rs`.
It's okay to drop the dereference symbol in this scenario.

But it's not correct in rust-lang#126863

```
help: consider removing the dereference here
  |
5 -         let inner: String = *p;
5 +         let inner: String = p;
```

I haven't found out how to tell if clone pointer is allowed, i.e. no type mismatch occurs
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 29, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#123237 (Various rustc_codegen_ssa cleanups)
 - rust-lang#126960 (Improve error message in tidy)
 - rust-lang#127002 (Implement `x perf` as a separate tool)
 - rust-lang#127050 (Make mtime of reproducible tarballs dependent on git commit)
 - rust-lang#127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel)
 - rust-lang#127106 (Improve unsafe extern blocks diagnostics)
 - rust-lang#127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.)
 - rust-lang#127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer)
 - rust-lang#127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 29, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#123237 (Various rustc_codegen_ssa cleanups)
 - rust-lang#126960 (Improve error message in tidy)
 - rust-lang#127002 (Implement `x perf` as a separate tool)
 - rust-lang#127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel)
 - rust-lang#127106 (Improve unsafe extern blocks diagnostics)
 - rust-lang#127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.)
 - rust-lang#127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer)
 - rust-lang#127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.)
 - rust-lang#127122 (Remove uneccessary condition in `div_ceil`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 30, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#123237 (Various rustc_codegen_ssa cleanups)
 - rust-lang#126960 (Improve error message in tidy)
 - rust-lang#127002 (Implement `x perf` as a separate tool)
 - rust-lang#127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel)
 - rust-lang#127106 (Improve unsafe extern blocks diagnostics)
 - rust-lang#127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.)
 - rust-lang#127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer)
 - rust-lang#127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.)
 - rust-lang#127122 (Remove uneccessary condition in `div_ceil`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9879b46 into rust-lang:master Jun 30, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 30, 2024
Rollup merge of rust-lang#127114 - linyihai:issue-126863, r=Nadrieril

fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer

Fixes rust-lang#126863

I wonder if there is a better way to solve the regression problem of this test case:
`tests/ui/borrowck/issue-20801.rs`.
It's okay to drop the dereference symbol in this scenario.

But it's not correct in rust-lang#126863

```
help: consider removing the dereference here
  |
5 -         let inner: String = *p;
5 +         let inner: String = p;
```

I haven't found out how to tell if clone pointer is allowed, i.e. no type mismatch occurs
@linyihai linyihai deleted the issue-126863 branch July 1, 2024 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhelpful compiler suggestion when trying to dereference a pointer that is not Copy
4 participants