Commit Graph

249522 Commits

Author SHA1 Message Date
Guillaume Gomez
4002638a44
Rollup merge of #122512 - baitcode:2024-03-14-buffer-documentation-fix, r=Nilstrieb
Cursor.rs documentation fix

Reason:

I've been learning Rust std library and got confused. Seek trait documentation clearly states that negative indexes will cause an error. And the code in the Cursor example uses negative index. I found myself trying to understand what am I missing until I've actually executed the code and got error. I decided to submit small fix to the documentation.
2024-03-15 17:24:08 +01:00
Guillaume Gomez
5325c2bdd1
Rollup merge of #122496 - GuillaumeGomez:reduce-gcc-build-logs, r=Mark-Simulacrum
Greatly reduce GCC build logs

Fixes https://github.com/rust-lang/rust-log-analyzer/issues/80.

Based on [makefile documentation](https://www.gnu.org/software/make/manual/html_node/Options-Summary.html#index-_002d_002dquiet-1) and [configure documentation](https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/configure-Invocation.html).

cc `@RalfJung` `@antoyo`
2024-03-15 17:24:08 +01:00
Guillaume Gomez
5c0012b953
Rollup merge of #122468 - beepster4096:borrowck_prefixes_cleanup, r=Nadrieril
Cleanup `MirBorrowckCtxt::prefixes`

Some of the uses of this method aren't necessary anymore and `PrefixSet::Supporting` is not used anywhere.

With `PrefixSet::Supporting` removed, this could technically be moved to an extension trait on `PlaceRef`. However, it would have to be moved back to `MirBorrowckCtxt` when the `Derefer` MIR pass is moved before borrowck so I didn't.
2024-03-15 17:24:07 +01:00
Guillaume Gomez
47be8e8b8b
Rollup merge of #114651 - tmfink:rustdoc-rustc-wrapper, r=GuillaumeGomez
rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests

Currently, `rustdoc` builds test crates with `rustc` directly instead of using [`RUSTC_WRAPPER`](https://doc.rust-lang.org/cargo/reference/config.html#buildrustc-wrapper) (if any is set).

This causes build issues in build systems that use `cargo` but tweak linking flags by setting the `RUSTC_WRAPPER` environment variable.

This change is not meant to be final--it's only a minimal proof of concept.
Please advise on the best way to proceed.

Open questions:
- [x] Does supporting the `rustc` wrappers make sense?
    - yes, `cargo-miri` for example needs a "hack" to workaround the issue
- [X] What environment variable(s) should be read for the rustc wrapper? Should `rustdoc` [use the same names as `cargo`](https://doc.rust-lang.org/cargo/reference/config.html#buildrustc-wrapper)?
    - None, since `rustdoc` takes arguments
- [X] What name should be used for a `rustdoc` CLI option?
    - `--test-builder-wrapper`
- [X] Should a separate workspace wrapper (like `RUSTC_WORKSPACE_WRAPPER`) be supported?
    - `--test-builder-wrapper` can be passed multiple times to get multiple wrappers passed
- [X] How/where should this be documented? It's not obvious to all users that `cargo doc` actually causes `rustdoc` to compile tests with rust
    - Added doc to `src/doc/rustdoc/src/command-line-arguments.md` per `@GuillaumeGomez`
2024-03-15 17:24:07 +01:00
Guillaume Gomez
c4ece1f4c8 Build GCC with as many threads as available 2024-03-15 16:16:27 +01:00
Guillaume Gomez
e126ceb46d Greatly reduce GCC build logs 2024-03-15 16:16:27 +01:00
bors
accc516128 Auto merge of #122538 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2024-03-15 12:03:12 +00:00
Travis Finkenauer
d02e66ddf0 doc: add --test-builder/--test-builder-wrapper 2024-03-15 03:19:29 -07:00
bors
d7723b2191 Auto merge of #122534 - matthiaskrgr:rollup-p95i3ph, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #121207 (Add `-Z external-clangrt`)
 - #122174 (diagnostics: suggest `Clone` bounds when noop `clone()`)
 - #122471 (preserve span when evaluating mir::ConstOperand)
 - #122515 (Pass the correct DefId when suggesting writing the aliased Self type out)
 - #122523 (Ensure RPITITs are created before def-id freezing)
 - #122526 (Docs for `thir::ExprKind::Use` and `thir::ExprKind::Let`)
 - #122527 (Clean up AstConv)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-15 10:03:49 +00:00
Matthias Krüger
277df5e176
Rollup merge of #122527 - fmease:clean-up-hir-ty-lowering, r=compiler-errors
Clean up AstConv

Split off from #120926 to make it only contain the renaming & (doc) comment updates.
Any changes other than that which have accumulated over time are now part of this PR.
Let's be disciplined ;) Inspired by https://github.com/rust-lang/rust/pull/120926#issuecomment-1997984483.

---

* Remove `hir_trait_to_predicates`
  * Unused since #113671
* Inline `create_args_for_ast_trait_ref`
  * Only had a single call site
  * Having it as a separate method didn't gain us anything
* Use an if-let guard somewhere to avoid unwrapping
* Avoid explicit trait object lifetimes
  * More legible, stylistic-only (the updated code is 100% semantically identical)
  * Use explicitly elided lifetimes in impl headers, they get elaborated to distinct lifetimes
  * Make use of [object lifetime defaulting](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes) for a trait object type inside of a reference type somewhere
* Use preexisting dedicated method `ItemCtxt::to_ty` over `<dyn AstConv<'_>>::ast_ty_to_ty`
* Use preexisting dedicated method `AstConv::astconv` over explicit coercions
* Simplify the function signature of `create_args_for_ast_path` and of `check_generic_arg_count`
  * In both cases redundant information was passed rendering the call sites verbose and confusing
  * No perf impact (tested in [#120926](https://github.com/rust-lang/rust/pull/120926))
* Move diagnostic method `report_ambiguous_associated_type` from `astconv` to `astconv::errors`
  * The submodule `errors` exists specifically for that purpose
  * Use it to keep the main module clean & short
2024-03-15 10:14:56 +01:00
Matthias Krüger
7a7b65abbe
Rollup merge of #122526 - Zalathar:thir-expr-docs, r=oli-obk
Docs for `thir::ExprKind::Use` and `thir::ExprKind::Let`

These docs are based on my own recent investigations; hopefully they're reasonably accurate.

`Use` was particularly puzzling to me at first, since the name is not very suggestive, and the old docs were quite cryptic.
2024-03-15 10:14:56 +01:00
Matthias Krüger
ee940f87fc
Rollup merge of #122523 - compiler-errors:ensure-associated-types, r=oli-obk
Ensure RPITITs are created before def-id freezing

From the test:

```rust
// `ty::Error` in a trait ref will silence any missing item errors, but will also
// prevent the `associated_items` query from being called before def ids are frozen.
```

Essentially, the code that checks that `impl`s have all their items (`check_impl_items_against_trait`) is also (implicitly) responsible for fetching the `associated_items` query before, but since we early return here:
c2901f5435/compiler/rustc_hir_analysis/src/check/check.rs (L732-L737)
...that means that this never happens for trait refs that reference errors.

Fixes #122518
r? oli-obk
2024-03-15 10:14:55 +01:00
Matthias Krüger
42af99383a
Rollup merge of #122515 - jieyouxu:ice-self-ty-mismatch, r=compiler-errors
Pass the correct DefId when suggesting writing the aliased Self type out

Fixes #122467.
2024-03-15 10:14:55 +01:00
Matthias Krüger
f4afbe1389
Rollup merge of #122471 - RalfJung:const-eval-span, r=oli-obk
preserve span when evaluating mir::ConstOperand

This lets us show to the user where they were using the faulty const (which can be quite relevant when generics are involved).

I wonder if we should change "erroneous constant encountered" to something like "the above error was encountered while evaluating this constant" or so, to make this more similar to what the collector emits when showing a "backtrace" of where things get monomorphized? It seems a bit strange to rely on the order of emitted diagnostics for that but it seems the collector already [does that](da8a8c9223/compiler/rustc_monomorphize/src/collector.rs (L472-L475)).
2024-03-15 10:14:54 +01:00
Matthias Krüger
e66c7e479c
Rollup merge of #122174 - notriddle:master, r=TaKO8Ki
diagnostics: suggest `Clone` bounds when noop `clone()`

Fixes #121524
2024-03-15 10:14:54 +01:00
Matthias Krüger
2b8fc6fd54
Rollup merge of #121207 - chriswailes:z-external-clangrt, r=michaelwoerister
Add `-Z external-clangrt`

This adds the unstable `-Z external-clangrt` flag that will prevent rustc from emitting linker paths for the in-tree LLVM sanitizer runtime library.
2024-03-15 10:14:53 +01:00
Travis Finkenauer
713043ef22 rustdoc: create rustc command with an iterator
This avoids unnecessary allocation with a temporary Vec.
2024-03-15 01:41:37 -07:00
Travis Finkenauer
3d53242e53 rustdoc: fix test's saved stdout
Also reword "test-builder-wrapper" argument help.
2024-03-15 01:41:37 -07:00
Travis Finkenauer
58dee7d781 rustdoc: add --test-builder-wrapper argument
Instead of executing the test builder directly, the test builder wrapper
will be called with test builder as the first argument and subsequent
arguments. This is similar to cargo's RUSTC_WRAPPER argument.

The `--test-builder-wrapper` argument can be passed multiple times to
allow "nesting" of wrappers.
2024-03-15 01:41:37 -07:00
bors
6d9549fbe6 Auto merge of #3383 - RalfJung:rustup, r=RalfJung
Rustup
2024-03-15 07:12:07 +00:00
Ralf Jung
32c734b73c fmt 2024-03-15 08:09:46 +01:00
Ralf Jung
0d811d7f3a Merge from rustc 2024-03-15 08:09:31 +01:00
Ralf Jung
3cc4059a6e Preparing for merge from rustc 2024-03-15 07:55:46 +01:00
León Orell Valerian Liehr
5beda81b71
Clean up AstConv 2024-03-15 05:06:38 +01:00
Zalathar
cac0b121b6 Docs for thir::ExprKind::Use and thir::ExprKind::Let 2024-03-15 13:11:00 +11:00
bors
ee03c286cf Auto merge of #122517 - petrochenkov:bodihash, r=oli-obk
Fill in HIR hash for associated opaque types

Fixes https://github.com/rust-lang/rust/issues/122508
2024-03-15 02:04:04 +00:00
Michael Goulet
571f945713 Ensure RPITITs are created before def-id freezing 2024-03-14 20:30:57 -04:00
bors
c2901f5435 Auto merge of #122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #117118 ([AIX] Remove AixLinker's debuginfo() implementation)
 - #121650 (change std::process to drop supplementary groups based on CAP_SETGID)
 - #121764 (Make incremental sessions identity no longer depend on the crate names provided by source code)
 - #122212 (Copy byval argument to alloca if alignment is insufficient)
 - #122322 (coverage: Initial support for branch coverage instrumentation)
 - #122373 (Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification`  and  `unused_imports`)
 - #122479 (Implement `Duration::as_millis_{f64,f32}`)
 - #122487 (Rename `StmtKind::Local` variant into `StmtKind::Let`)
 - #122498 (Update version of cc crate)
 - #122503 (Make `SubdiagMessageOp` well-formed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-15 00:03:58 +00:00
bors
ed9d70f56c Auto merge of #3382 - saethlin:sysroots-notification, r=saethlin
Fix sysroot notification list of broken targets

We use this same shell quoting trick on the line above to expand shell variables into the job URL. So this should work a line down as well... right?
2024-03-14 22:45:48 +00:00
Ben Kimock
22f6193ac1 Apply the same shell quoting trick we use in the URL to 2024-03-14 18:43:04 -04:00
bors
f4b771bf1f Auto merge of #122514 - workingjubilee:update-backtrace-for-miri, r=workingjubilee
Use rust-lang/backtrace-rs@6fa4b85

r? `@ghost`
2024-03-14 21:35:39 +00:00
Ralf Jung
48f2f0d725 preserve span when evaluating mir::ConstOperand 2024-03-14 21:55:07 +01:00
Vadim Petrochenkov
ef5513f278 Fill in HIR hash for associated opaque types 2024-03-14 23:29:12 +03:00
许杰友 Jieyou Xu (Joe)
87ced1561f
Pass the correct DefId when suggesting writing the aliased Self type out 2024-03-14 19:39:15 +00:00
Jubilee Young
442cc762c0 Use rust-lang/backtrace-rs@6fa4b85 2024-03-14 12:37:43 -07:00
Matthias Krüger
6ce3110ce9
Rollup merge of #122503 - compiler-errors:trait-alias-wf, r=Nilstrieb
Make `SubdiagMessageOp` well-formed

`WF(Diag<'_, G>)` requires `G: EmissionGuarantee`, but we don't currently check this is true due to limitations in the solver. Probably still worth enforcing.

r? `@nnethercote` (or anyone can r+ this, really)
2024-03-14 20:00:22 +01:00
Matthias Krüger
6366c64974
Rollup merge of #122498 - jfgoog:update-cc-crate-version, r=workingjubilee
Update version of cc crate

Reason:

In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: 57853c4bf8

This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix.

We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream.
2024-03-14 20:00:21 +01:00
Matthias Krüger
1f4aff7d2b
Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obk
Rename `StmtKind::Local` variant into `StmtKind::Let`

It comes from this [discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F).

Starting point was:

> I often end up looking at [ExprKind::Let](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Let) instead of Local because of the name. I think renaming it (both the `ExprKind` variant and the Let struct) to `LetPattern` or LetPat could improve the situation as I'm not sure I'm not the only one encountering this issue.

And then it evolved into:

> It's already `Expr::Let` instead of `StmtKind::Local`. Counterproposal: rename `StmtKind::Local` to `StmtKind::Let`.

The goal here is to clear this confusion.

r? `@oli-obk`
2024-03-14 20:00:21 +01:00
Matthias Krüger
5d41186446
Rollup merge of #122479 - GrigorenkoPV:duration_millis_float, r=scottmcm
Implement `Duration::as_millis_{f64,f32}`

Implementation of #122451.

Linked const-unstability to #72440, so the post there should probably be updated to mentions the 2 new methods when/if this PR is merged.
2024-03-14 20:00:20 +01:00
Matthias Krüger
b200108bc5
Rollup merge of #122373 - surechen:fix_121331, r=petrochenkov
Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification`  and  `unused_imports`

fixes #121331

For an `item` that triggers lint unnecessary_qualification, if the `use item` which imports this item is also trigger unused import, fixing the two lints at the same time may lead to the problem that the `item` cannot be found.
This PR will avoid reporting lint unnecessary_qualification when conflict occurs.

r? ``@petrochenkov``
2024-03-14 20:00:20 +01:00
Matthias Krüger
54a5a49af0
Rollup merge of #122322 - Zalathar:branch, r=oli-obk
coverage: Initial support for branch coverage instrumentation

(This is a review-ready version of the changes that were drafted in #118305.)

This PR adds support for branch coverage instrumentation, gated behind the unstable flag value `-Zcoverage-options=branch`. (Coverage instrumentation must also be enabled with `-Cinstrument-coverage`.)

During THIR-to-MIR lowering (MIR building), if branch coverage is enabled, we collect additional information about branch conditions and their corresponding then/else blocks. We inject special marker statements into those blocks, so that the `InstrumentCoverage` MIR pass can reliably identify them even after the initially-built MIR has been simplified and renumbered.

The rest of the changes are mostly just plumbing needed to gather up the information that was collected during MIR building, and include it in the coverage metadata that we embed in the final binary.

Note that `llvm-cov show` doesn't print branch coverage information in its source views by default; that needs to be explicitly enabled with `--show-branches=count` or similar.

---

The current implementation doesn't have any support for instrumenting `if let` or let-chains. I think it's still useful without that, and adding it would be non-trivial, so I'm happy to leave that for future work.
2024-03-14 20:00:19 +01:00
Matthias Krüger
722514f466
Rollup merge of #122212 - erikdesjardins:byval-align2, r=wesleywiser
Copy byval argument to alloca if alignment is insufficient

Fixes #122211

"Ignore whitespace" recommended.
2024-03-14 20:00:18 +01:00
Matthias Krüger
4dff106433
Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk
Make incremental sessions identity no longer depend on the crate names provided by source code

This makes incremental sessions identity no longer depend on the crate names provided by source code, implementing
https://github.com/rust-lang/compiler-team/issues/726.

r? ````@oli-obk````
2024-03-14 20:00:18 +01:00
Matthias Krüger
eaa8dafe1a
Rollup merge of #121650 - GrigorenkoPV:cap_setgid, r=Amanieu
change std::process to drop supplementary groups based on CAP_SETGID

A trivial rebase of #95982

Should fix #39186 (from what I can tell)

Original description:

> Fixes #88716
>
> * Before this change, when a process was given a uid via `std::os::unix::process::CommandExt.uid`, there would be a `setgroups` call (when the process runs) to clear supplementary groups for the child **if the parent was root** (to remove potentially unwanted permissions).
> * After this change, supplementary groups are cleared if we have permission to do so, that is, if we have the CAP_SETGID capability.
>
> This new behavior was agreed upon in #88716 but there was a bit of uncertainty from `@Amanieu` here: [#88716 (comment)](https://github.com/rust-lang/rust/issues/88716#issuecomment-973366600)
>
> > I agree with this change, but is it really necessary to ignore an EPERM from setgroups? If you have permissions to change UID then you should also have permissions to change groups. I would feel more comfortable if we documented set_uid as requiring both UID and GID changing permissions.
>
> The way I've currently written it, we ignore an EPERM as that's what #88716 originally suggested. I'm not at all an expert in any of this so I'd appreciate feedback on whether that was the right way to go.
2024-03-14 20:00:17 +01:00
Matthias Krüger
68ca795286
Rollup merge of #117118 - bzEq:aix-linker, r=wesleywiser
[AIX] Remove AixLinker's debuginfo() implementation

AIX ld's `-s` option doesn't perfectly fit` debuginfo()`'s semantics and may unexpectedly remove metadata in shared libraries. Remove the implementation of `AixLinker` and suggest user to use `strip` utility instead.
2024-03-14 20:00:17 +01:00
bors
fd27e8745f Auto merge of #119849 - lcnr:eagerly-instantiate-binders, r=compiler-errors
more eagerly instantiate binders

The old solver sometimes incorrectly used `sub`, change it to explicitly instantiate binders and use `eq` instead. While doing so I also moved the instantiation before the normalize calls. This caused some observable changes, will explain these inline. This PR therefore requires a crater run and an FCP.

r? types
2024-03-14 18:58:53 +00:00
baitcode
07e0182fd3 Fix minor documentation issue. Code outside the test would fail. Seek documentation clearly states that negative indexes will cause error.
Just making the code in the example to return Result::Ok, instead of Result::Error.
2024-03-14 18:58:23 +00:00
Chris Wailes
f46aceaaf7 Restore correct version of comment and fix logic bug 2024-03-14 11:06:39 -07:00
Michael Goulet
6e4cd8b7cc Make SubdiagMessageOp well-formed 2024-03-14 13:13:08 -04:00
lcnr
c8f0f17ed2 add tests 2024-03-14 17:45:13 +01:00