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 #107821

Closed

Conversation

compiler-errors
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

compiler-errors and others added 18 commits January 22, 2023 04:47
…ize the tracing loggers at their own discretion
[svgo]: https://github.com/svg/svgo

    $ du -bs src/librustdoc/html/static/images/wheel.svg wheel-old.svg
    2972    src/librustdoc/html/static/images/wheel.svg
    3764    wheel-old.svg

100*((2972-3764)/3764) = -21.04%
…ll, r=lcnr

Suggest function call on pattern type mismatch

Fixes rust-lang#101208

This could definitely be generalized to support more suggestions in pattern matches. We can't use all of [`FnCtxt::emit_type_mismatch_suggestions`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/fn_ctxt/struct.FnCtxt.html#method.emit_type_mismatch_suggestions), but it's on my to-do list to play around with more suggestions that would be productive in this position.
Implement `AsFd` and `AsRawFd` for `Rc`

Fixes rust-lang#105931.
…bilization, r=dtolnay

Stabilize feature `cstr_from_bytes_until_nul`

This PR seeks to stabilize `cstr_from_bytes_until_nul`.

Partially addresses rust-lang#95027

This function has only been on nightly for about 10 months, but I think it is simple enough that there isn't harm discussing stabilization. It has also had at least a handful of mentions on both the user forum and the discord, so it seems like it's already in use or at least known.

This needs FCP still.

Comment on potential discussion points:
- eventual conversion of `CStr` to be a single thin pointer: this function will still be useful to provide a safe way to create a `CStr` after this change.
- should this return a length too, to address concerns about the `CStr` change? I don't see it as being particularly useful, and it seems less ergonomic (i.e. returning `Result<(&CStr, usize), FromBytesUntilNulError>`). I think users that also need this length without the additional `strlen` call are likely better off using a combination of other methods, but this is up for discussion
- `CString::from_vec_until_nul`: this is also useful, but it doesn't even have a nightly implementation merged yet. I propose feature gating that separately, as opposed to blocking this `CStr` implementation on that

Possible alternatives:

A user can use `from_bytes_with_nul` on a slice up to `my_slice[..my_slice.iter().find(|c| c == 0).unwrap()]`. However; that is significantly less ergonomic, and is a bit more work for the compiler to optimize compared the direct `memchr` call that this wraps.

## New stable API

```rs
// both in core::ffi

pub struct FromBytesUntilNulError(());

impl CStr {
    pub const fn from_bytes_until_nul(
        bytes: &[u8]
    ) -> Result<&CStr, FromBytesUntilNulError>
}
```

cc `@ericseppanen` original author, `@Mark-Simulacrum` original reviewer, `@m-ou-se` brought up some issues on the thin pointer CStr

`@rustbot` modify labels: +T-libs-api +needs-fcp
…efix, r=petrochenkov

Specify dlltool prefix when generating import libs

Ref: rust-lang#106610 (comment)

tl;dr: This PR adds an explicit dlltool temporary filename prefix. The prefix resolves a race condition by ensuring dlltool temporary files are siloed in an appropriate/unique Rust temporary directory.

---

GNU dlltool, as part of its import library generation logic, uses a bunch of temporary files on disk. In the interest of deterministic build runs, dlltool supports deterministic temporary filenames. The temporary filename prefix is automatically generated internally or can be explicitly specified via a `--temp-prefix` argument.

GNU dlltool **2.38** (that ships with `x86_64-12.2.0-release-posix-seh-rt_v10-rev0` [installed during CI](https://github.com/rust-lang/rust/blob/master/src/ci/scripts/install-mingw.sh)) generates a prefix based on the target library name ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=d95bf3f5470b999fa3b30bc887791859f48d81d1;hb=20756b0fbe065a84710aa38f2457563b57546440#l3992)). The tool writes to files such as `target_dll_h.s` and `target_dll_s00203.o` in the current working directory.

This presents a problem when multiple instances of rustc_codegen_llvm are running to generate an import library (as part of the raw_dylib feature) for the same target library (e.g. kernel32) ([source](https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/back/archive.rs#L185-L196)). That is, dlltool instances race and may overwrite or delete files belonging to each other.

GNU dlltool **2.39**+ (not used in Rust CI) generates a prefix based on the output library path ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=e2af20847009945b4c61a6fef08268fbb4429715;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l3992)). The tool, when invoked as part of rustc_codegen_llvm, writes to files at paths such as `C_Users_Foo_AppData_Local_Temp_rustcOFqhXZ_target_lib_h.s`. (The output library path is normalized and non-alphanumeric characters are replaced with underscores.)
Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion

fixes rust-lang/miri#2778

this was introduced in rust-lang#104645, so this PR reverts the flag-part and uses an env var instead.
…oli-obk

correctly update goals in the cache

we may want to actually write the response for our goal into the provisional or global cache instead of simply using the result from the last iteration '^^

r? `@rust-lang/initiative-trait-system-refactor`
…macro-is-ok, r=estebank

Do not eagerly recover for bad `impl Trait` types in macros

Fixes rust-lang#107796

cc rust-lang#106712, `@estebank` and `@Ezrashaw` please make sure to use [`Parser::may_recover`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.may_recover) for all eager-token-consuming parser recoveries.

This also fixes a separate regression from rust-lang#99915, that was introduced before we added `may_recover` though.
…uillaumeGomez

rustdoc: use svgo to shrink `wheel.svg`

use [svgo] to shrink `wheel.svg`

[svgo]: https://github.com/svg/svgo

    $ du -bs src/librustdoc/html/static/images/wheel.svg wheel-old.svg
    2972    src/librustdoc/html/static/images/wheel.svg
    3764    wheel-old.svg

100*((2972-3764)/3764) = -21.04%
@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Feb 9, 2023
@compiler-errors
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Contributor

bors commented Feb 9, 2023

📌 Commit d9dd22a has been approved by compiler-errors

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

bors commented Feb 9, 2023

⌛ Testing commit d9dd22a with merge e981dec8c8e0fe8da49354869444d4c8722f33ad...

@bors
Copy link
Contributor

bors commented Feb 9, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 9, 2023
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:ca7cab66e2f838703fe12775fbabb05754421ad8)
Complete job name: PR (x86_64-gnu-llvm-13, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-llvm-13
---

---- [ui] tests/ui/suggestions/suggest-call-on-pat-mismatch.rs stdout ----
diff of stderr:

4 LL |     if let E::One(var1, var2) = var {
5    |            ^^^^^^^^^^^^^^^^^^   --- this expression has type `fn(i32, i32) -> E {E::One}`
-    |            expected enum constructor, found enum `E`
+    |            expected enum constructor, found `E`
8    |
8    |
9    = note: expected enum constructor `fn(i32, i32) -> E {E::One}`
10                           found enum `E`

19 LL |     let Some(x) = Some;
20    |         ^^^^^^^   ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}`
-    |         expected enum constructor, found enum `Option`
+    |         expected enum constructor, found `Option<_>`
23    |
23    |
24    = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}`


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/suggest-call-on-pat-mismatch.stderr
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/suggest-call-on-pat-mismatch.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args suggestions/suggest-call-on-pat-mismatch.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/suggestions/suggest-call-on-pat-mismatch.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/auxiliary"
stdout: none
--- stderr -------------------------------
  --> fake-test-src-base/suggestions/suggest-call-on-pat-mismatch.rs:7:12
   |
   |
LL |     if let E::One(var1, var2) = var {
   |            ^^^^^^^^^^^^^^^^^^   --- this expression has type `fn(i32, i32) -> E {E::One}`
   |            expected enum constructor, found `E`
   |
   |
   = note: expected enum constructor `fn(i32, i32) -> E {E::One}`
                          found enum `E`
help: use parentheses to construct this tuple variant
   |
LL |     if let E::One(var1, var2) = var(/* i32 */, /* i32 */) {

error[E0308]: mismatched types
  --> fake-test-src-base/suggestions/suggest-call-on-pat-mismatch.rs:13:9
   |
   |
LL |     let Some(x) = Some;
   |         ^^^^^^^   ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}`
   |         expected enum constructor, found `Option<_>`
   |
   |
   = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}`
help: use parentheses to construct this tuple variant
   |
   |
LL |     let Some(x) = Some(/* value */);

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13-stage1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/parser/bad-let-as-field.rs ... ok
test [ui] tests/ui/parser/bad-pointer-type.rs ... ok
test [ui] tests/ui/parser/bad-recover-ty-after-impl.rs ... ok
test [ui] tests/ui/parser/bad-lit-suffixes.rs ... ok
test [ui] tests/ui/parser/bad-recover-kw-after-impl.rs ... ok
test [ui] tests/ui/parser/bad-fn-ptr-qualifier.rs ... ok
test [ui] tests/ui/parser/bad-value-ident-false.rs ... ok
test [ui] tests/ui/parser/bad-value-ident-true.rs ... ok
test [ui] tests/ui/parser/better-expected.rs ... ok
---

---- [ui] tests/ui/suggestions/suggest-call-on-pat-mismatch.rs stdout ----
diff of stderr:

4 LL |     if let E::One(var1, var2) = var {
5    |            ^^^^^^^^^^^^^^^^^^   --- this expression has type `fn(i32, i32) -> E {E::One}`
-    |            expected enum constructor, found enum `E`
+    |            expected enum constructor, found `E`
8    |
8    |
9    = note: expected enum constructor `fn(i32, i32) -> E {E::One}`
10                           found enum `E`

19 LL |     let Some(x) = Some;
20    |         ^^^^^^^   ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}`
-    |         expected enum constructor, found enum `Option`
+    |         expected enum constructor, found `Option<_>`
23    |
23    |
24    = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}`


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/suggest-call-on-pat-mismatch.stderr
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/suggest-call-on-pat-mismatch.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args suggestions/suggest-call-on-pat-mismatch.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/checkout/tests/ui/suggestions/suggest-call-on-pat-mismatch.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-call-on-pat-mismatch/auxiliary"
stdout: none
--- stderr -------------------------------
  --> fake-test-src-base/suggestions/suggest-call-on-pat-mismatch.rs:7:12
   |
   |
LL |     if let E::One(var1, var2) = var {
   |            ^^^^^^^^^^^^^^^^^^   --- this expression has type `fn(i32, i32) -> E {E::One}`
   |            expected enum constructor, found `E`
   |
   |
   = note: expected enum constructor `fn(i32, i32) -> E {E::One}`
                          found enum `E`
help: use parentheses to construct this tuple variant
   |
LL |     if let E::One(var1, var2) = var(/* i32 */, /* i32 */) {

error[E0308]: mismatched types
  --> fake-test-src-base/suggestions/suggest-call-on-pat-mismatch.rs:13:9
   |
   |
LL |     let Some(x) = Some;
   |         ^^^^^^^   ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}`
   |         expected enum constructor, found `Option<_>`
   |
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
   = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}`
help: use parentheses to construct this tuple variant
   |
   |
LL |     let Some(x) = Some(/* value */);

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.

@compiler-errors compiler-errors deleted the rollup-feopnii branch August 11, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants