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 8 pull requests #91019

Merged
merged 20 commits into from
Nov 18, 2021
Merged

Rollup of 8 pull requests #91019

merged 20 commits into from
Nov 18, 2021

Conversation

JohnTitor
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

wooster0 and others added 20 commits November 1, 2021 18:52
This was the only Clean impl I found with `where` bounds.

This impl was doubly-confusing: it was implemented on a tuple and it
was polymorphic. Combined, this caused a "spooky action at a distance"
effect to make the code very confusing.
Basically, this entails moving the arguments cleaning to the call site.

I extracted several local variables because:

1. It makes the code easier to read and understand.

2. If I hadn't, the extra `clean()` calls would have caused complicated
   tuples to be split across several lines.

3. I couldn't just extract local variables for `args` because then the
   arguments would be cleaned *before* the generics, while rustdoc expects
   them to be cleaned *after*. Only extracting `args` caused panics like
   this:

       thread 'rustc' panicked at 'assertion failed: cx.impl_trait_bounds.is_empty()',
       src/librustdoc/clean/utils.rs:462:5

   Extracting variables makes the control flow -- and the required
   order of cleaning -- more explicit.
Otherwise, rustdoc panics with messages like this:

   thread 'rustc' panicked at 'assertion failed: cx.impl_trait_bounds.is_empty()',
   src/librustdoc/clean/utils.rs:462:5

This ordering requirement is unrelated to the `clean_fn_decl_with_args`
refactoring, but the requirement was uncovered as part of that change.

I'm not sure if *all* of these places have the requirement, but I added
comments to them just in case.
This commit makes the following functions from `core::str` `const fn`:
- `from_utf8[_mut]` (`feature(const_str_from_utf8)`)
- `from_utf8_unchecked_mut` (`feature(const_str_from_utf8_unchecked_mut)`)
- `Utf8Error::{valid_up_to,error_len}` (`feature(const_str_from_utf8)`)
This function parameter attribute was introduced in rust-lang#44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
…=Aaron1011

Add `-Zassert-incr-state` to assert state of incremental cache

Closes rust-lang#85864.
…=camelid

Clean up mess for --show-coverage documentation

It was somewhat duplicated for some reasons... Anyway, this remove this duplication and clean up a bit.

r? ```@camelid```
Mention `Vec::remove` in `Vec::swap_remove`'s docs

Thought this was a nice addition.
…=oli-obk

Make slice->str conversion and related functions `const`

This PR marks the following APIs as `const`:
```rust
// core::str
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error>;
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;

impl Utf8Error {
    pub const fn valid_up_to(&self) -> usize;
    pub const fn error_len(&self) -> Option<usize>;
}
```

Everything but `from_utf8_unchecked_mut` uses `const_str_from_utf8` feature gate, `from_utf8_unchecked_mut` uses `const_str_from_utf8_unchecked_mut` feature gate.

---

I'm not sure why `from_utf8_unchecked_mut` was left out being  non-`const`, considering that `from_utf8_unchecked` is not only `const`, but **`const` stable**.

---

r? ```@oli-obk``` (performance-only `const_eval_select` use)
rustdoc: Replace where-bounded Clean impl with simple function

This is the first step in removing the Clean impls for tuples. Either way, this
significantly simplifies the code since it reduces the amount of "trait magic".

(To clarify, I'm referring to impls like `impl Clean for (A, B)`, not Clean impls
that work on tuples in the user's program.)

cc ``@jyn514``
…=oli-obk

require full validity when determining the discriminant of a value

This resolves (for now) the semantic question that came up in rust-lang#89764: arguably, reading the discriminant of a value is 'using' that value, so we are in our right to demand full validity. Reading a discriminant is somewhat special in that it works for values of *arbitrary* type; all the other primitive MIR operations work on specific types (e.g. `bool` or an integer) and basically implicitly require validity as part of just "doing their job".

The alternative would be to just require that the discriminant itself is valid, if any -- but then what do we do for types that do not have a discriminant, which kind of validity do we check? [This code](https://github.com/rust-lang/rust/blob/81117ff930fbf3792b4f9504e3c6bccc87b10823/compiler/rustc_codegen_ssa/src/mir/place.rs#L206-L215) means we have to at least reject uninhabited types, but I would rather not special case that.

I don't think this can be tested in CTFE (since validity is not enforced there), I will add a compile-fail test to Miri:
```rust
#[allow(enum_intrinsics_non_enums)]
fn main() {
    let i = 2u8;
    std::mem::discriminant(unsafe { &*(&i as *const _ as *const bool) }); // UB
}
```

(I tried running the check even on the CTFE machines, but then it runs during ConstProp and that causes all sorts of problems. We could run it for ConstEval but not ConstProp, but that simply does not seem worth the effort currently.)

r? ``@oli-obk``
…loat-ending-in-dot, r=sanxiyn

Avoid suggesting literal formatting that turns into member access

Fixes rust-lang#90974
rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in rust-lang#44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

Noticed while reviewing rust-lang#90947.
@rustbot rustbot added the rollup A PR which is a rollup label Nov 18, 2021
@JohnTitor
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Nov 18, 2021

📌 Commit 08c1639 has been approved by JohnTitor

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 18, 2021
@bors
Copy link
Contributor

bors commented Nov 18, 2021

⌛ Testing commit 08c1639 with merge cc946fc...

@bors
Copy link
Contributor

bors commented Nov 18, 2021

☀️ Test successful - checks-actions
Approved by: JohnTitor
Pushing cc946fc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 18, 2021
@bors bors merged commit cc946fc into rust-lang:master Nov 18, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 18, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #91019!

Tested on commit cc946fc.
Direct link to PR: #91019

💔 miri on windows: test-pass → test-fail (cc @RalfJung @eddyb @oli-obk).
💔 miri on linux: test-pass → test-fail (cc @RalfJung @eddyb @oli-obk).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Nov 18, 2021
Tested on commit rust-lang/rust@cc946fc.
Direct link to PR: <rust-lang/rust#91019>

💔 miri on windows: test-pass → test-fail (cc @RalfJung @eddyb @oli-obk).
💔 miri on linux: test-pass → test-fail (cc @RalfJung @eddyb @oli-obk).
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cc946fc): comparison url.

Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.

  • Moderate improvement in instruction counts (up to -0.6% on incr-unchanged builds of style-servo)
  • Moderate regression in instruction counts (up to 0.8% on full builds of await-call-tree)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@rustbot rustbot added the perf-regression Performance regression. label Nov 19, 2021
@JohnTitor JohnTitor deleted the rollup-q95ra7r branch November 19, 2021 01:19
@JohnTitor
Copy link
Member Author

The regressions happened in the doc benchmarks so #90750 should be the culprit.

@pnkfelix
Copy link
Member

Moving perf-regression label to PR #90750

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 23, 2021
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.