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

Rollup of 6 pull requests #113188

Merged
merged 13 commits into from
Jun 30, 2023
Merged

Rollup of 6 pull requests #113188

merged 13 commits into from
Jun 30, 2023

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

tgross35 and others added 13 commits June 1, 2023 17:39
```
error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> $DIR/E0637.rs:13:13
   |
LL |     T: Into<&u32>,
   |             ^ explicit lifetime name needed here
   |
help: consider introducing a higher-ranked lifetime here
   |
LL |     T: for<'a> Into<&'a u32>,
   |        +++++++       ++
```
…lnay

Stabilize `const_cstr_methods`

This PR seeks to stabilize `const_cstr_methods`. Fixes most of rust-lang#101719

## New const stable API

```rust
impl CStr {
    // depends: memchr
    pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {...}
    // depends: const_slice_index
    pub const fn to_bytes(&self) -> &[u8] {}
    // depends: pointer casts
    pub const fn to_bytes_with_nul(&self) -> &[u8] {}
    // depends: str::from_utf8
    pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {}
}
```

I don't think any of these methods will have any issue when `CStr` becomes a thin pointer as long as `memchr` is const  (which also allows for const `strlen`) .

## Notes

- `from_bytes_until_nul` relies on `const_slice_index`, which relies on `const_trait_impls`, and generally this should be avoided. After talking with Oli, it should be OK in this case because we could replace the ranges with pointer tricks if needed (worst case being those feature gates disappear). rust-lang#107624 (comment)
- Making `from_ptr` const is deferred because it depends on `const_eval_select`. I have moved this under the new flag `const_cstr_from_ptr` rust-lang#107624 (comment)

cc ``@oli-obk`` I think you're the const expert

``@rustbot`` modify labels: +T-libs-api +needs-fcp
…-errors

suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error

Recently saw someone ask why this code (example slightly modified):
```rs
fn main() {
  let mut foo = [1, 2];
  std::mem::swap(&mut foo[0], &mut foo[1]);
}
```
triggers this error and how to fix it:
```
error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time
 --> src/main.rs:4:33
  |
4 |     std::mem::swap(&mut foo[0], &mut foo[1]);
  |     -------------- -----------  ^^^^^^^^^^^ second mutable borrow occurs here
  |     |              |
  |     |              first mutable borrow occurs here
  |     first borrow later used by call
  |
  = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
```
The current help message is nice and goes in the right direction, but I think we can do better for this specific instance and suggest `slice::swap`, which makes this compile
…time-args-in-apit, r=eholk

Account for late-bound vars from parent arg-position impl trait

We should be reporting an error like we do for late-bound args coming from a parent APIT.

Fixes rust-lang#113016
…unds, r=spastorino

Encode item bounds for `DefKind::ImplTraitPlaceholder`

This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃

Fixes rust-lang#113155

r? ``@cjgillot``
…er-errors

Properly implement variances_of for RPITIT GAT

This fixes some of the issues found by crater run in rust-lang#112988 (comment)

r? ``@compiler-errors``
Use structured suggestion when telling user about `for<'a>`

```
error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> $DIR/E0637.rs:13:13
   |
LL |     T: Into<&u32>,
   |             ^ explicit lifetime name needed here
   |
help: consider introducing a higher-ranked lifetime here
   |
LL |     T: for<'a> Into<&'a u32>,
   |        +++++++       ++
```
@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Jun 30, 2023
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=6

@bors
Copy link
Contributor

bors commented Jun 30, 2023

📌 Commit 207b244 has been approved by matthiaskrgr

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 30, 2023
@bors
Copy link
Contributor

bors commented Jun 30, 2023

⌛ Testing commit 207b244 with merge b4591cb...

@bors
Copy link
Contributor

bors commented Jun 30, 2023

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing b4591cb to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 30, 2023
@bors bors merged commit b4591cb into rust-lang:master Jun 30, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 30, 2023
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#107624 Stabilize const_cstr_methods e2889cfc2fff2d14844e8e3b01877bd7710da640 (link)
#111403 suggest slice::swap for mem::swap(&mut x[0], &mut x[1]) d3818e8293c3b0133cdc9d595f441016dc019fb6 (link)
#113071 Account for late-bound vars from parent arg-position impl t… 8d3f3c396e1dbef74c91933d8833b706d16524cb (link)
#113165 Encode item bounds for DefKind::ImplTraitPlaceholder 8cf5677c5372e6694ddae3c5def268d1bbe77630 (link)
#113171 Properly implement variances_of for RPITIT GAT a97f7b6da89d735717a8c9b572562d017f52baa1 (link)
#113177 Use structured suggestion when telling user about for<'a> ebb6d0de08c5925a7d000b0176d3368c36b58719 (link)

previous master: 97279e91d8

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b4591cb): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.1%, -0.4%] 6
Improvements ✅
(secondary)
-1.7% [-2.0%, -1.4%] 3
All ❌✅ (primary) -0.5% [-1.1%, 1.0%] 7

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 1

Bootstrap: 659.661s -> 660.129s (0.07%)

@matthiaskrgr matthiaskrgr deleted the rollup-j3abaks branch March 16, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants