Commit Graph

250003 Commits

Author SHA1 Message Date
Jacob Pratt
f25397adc0
Rollup merge of #122786 - Enselic:remove_and_create_dir_all, r=onur-ozkan
compiletest: Introduce `remove_and_create_dir_all()` helper

The code

    let _ = fs::remove_dir_all(&dir);
    create_dir_all(&dir).unwrap();

is duplicated in 7 places. Let's introduce a helper.
2024-03-20 20:29:47 -04:00
Jacob Pratt
afdbad80b1
Rollup merge of #122776 - GuillaumeGomez:rename-hir-let, r=oli-obk
Rename `hir::Let` into `hir::LetExpr`

As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F).

r? `````@Zalathar`````
2024-03-20 20:29:47 -04:00
Jacob Pratt
7a5ffccded
Rollup merge of #122765 - workingjubilee:test-for-vec-handling-usize-max, r=Nilstrieb
Add `usize::MAX` arg tests for Vec

Tests to prevent recurrence of the UB from the rust-lang/rust#122760 issue.

I skipped the `with_capacity`, `drain`, `reserve`, etc. APIs because they actually had a good assortment of tests earlier in the same file.

r? Nilstrieb
2024-03-20 20:29:46 -04:00
Jacob Pratt
c6a49220d6
Rollup merge of #122764 - Zalathar:loopy, r=oli-obk
coverage: Remove incorrect assertions from counter allocation

These assertions detect situations where a BCB node (in the coverage graph) would have both a physical counter and one or more in-edge counters/expressions.

For most BCBs that situation would indicate an implementation bug. However, it's perfectly fine in the case of a BCB having an edge that loops back to itself.

Given the complexity and risk involved in fixing the assertions, and the fact that nothing relies on them actually being true, this patch just removes them instead.

Fixes #122738.

`````@rustbot````` label +A-code-coverage
2024-03-20 20:29:46 -04:00
Jacob Pratt
4e792df4ed
Rollup merge of #122749 - aliemjay:region-err, r=compiler-errors
make `type_flags(ReError) & HAS_ERROR`

Self-explanatory. `TypeVisitableExt::references_error(ReError)` incorrectly returned `false`.
2024-03-20 20:29:45 -04:00
Jacob Pratt
d53df5a51e
Rollup merge of #122740 - tshepang:patch-1, r=clubby789
use more accurate terminology

rustc is just one tool/executable, even if at the center of the toolchain
2024-03-20 20:29:45 -04:00
Jacob Pratt
43ad753adb
Rollup merge of #122729 - m-ou-se:relax, r=Amanieu
Relax SeqCst ordering in standard library.

Every single SeqCst in the standard library is unnecessary. In all cases, Relaxed or Release+Acquire was sufficient.

As I [wrote](https://marabos.nl/atomics/memory-ordering.html#common-misconceptions) in my book on atomics:

> [..] when reading code, SeqCst basically tells the reader: "this operation depends on the total order of every single SeqCst operation in the program," which is an incredibly far-reaching claim. The same code would likely be easier to review and verify if it used weaker memory ordering instead, if possible. For example, Release effectively tells the reader: "this relates to an acquire operation on the same variable," which involves far fewer considerations when forming an understanding of the code.
>
> It is advisable to see SeqCst as a warning sign. Seeing it in the wild often means that either something complicated is going on, or simply that the author did not take the time to analyze their memory ordering related assumptions, both of which are reasons for extra scrutiny.

r? ````@Amanieu```` ````@joboet````
2024-03-20 20:29:44 -04:00
Jacob Pratt
31adfd77d2
Rollup merge of #122545 - Alexendoo:unused-qualifications, r=petrochenkov
Ignore paths from expansion in `unused_qualifications`

If any of the path segments are from an expansion the lint is skipped currently, but a path from an expansion where all of the segments are passed in would not be. Doesn't seem that likely to occur but it could happen
2024-03-20 20:29:44 -04:00
bors
1388d7a069 Auto merge of #122761 - jwong101:fix/vec-insert, r=workingjubilee,Nilstrieb
fix OOB pointer formed in Vec::index

Move the length check to before using `index` with `ptr::add` to prevent an out of bounds pointer from being formed.

Fixes #122760
2024-03-20 21:37:30 +00:00
Martin Nordholts
c3cc6c1990 compiletest: Introduce remove_and_create_dir_all() helper
The code

    let _ = fs::remove_dir_all(&dir);
    create_dir_all(&dir).unwrap();

is duplicated in 7 places. Let's introduce a helper.
2024-03-20 20:28:30 +01:00
bors
e3df96cfda Auto merge of #122779 - estebank:test-svg-non-determinism, r=compiler-errors
When comparing SVG tests against their blessed version, ignore the first line

`anstyle_svg` has some weird non-determinism in the width parameter, which makes tests blessed in one environment to fail in another. This is the *only* non-determinism detected so far, so we modify the diff check to ignore the first line of the SVG. In order for a test to fail/be updated by `--bless`, a different part of the file needs to also have changed. If other sources of non-determinism are found, we should back out of the "`--color=always` means `.svg`" change.

r? `@compiler-errors`
2024-03-20 18:47:34 +00:00
Martin Nordholts
352587af44 compiletest: mir_dump_dir.as_path() -> &mir_dump_dir 2024-03-20 19:24:18 +01:00
Ali MJ Al-Nasrawy
0dc006b3a8 register opaques that reference errors 2024-03-20 17:30:19 +00:00
Ali MJ Al-Nasrawy
19e0ea4a6d make type_flags(ReError) & HAS_ERROR 2024-03-20 17:29:58 +00:00
Alex Macleod
a8452461dc Ignore paths from expansion in unused_qualifications 2024-03-20 16:30:26 +00:00
Esteban Küber
bf63f7eefe When comparing SVG tests against their blessed version, ignore the first line
`anstyle_svg` has some weird non-determinism in the width parameter, which makes tests blessed in one environment to fail in another. This is the *only* non-determinism detected so far, so we modify the diff check to ignore the first line of the SVG. In order for a test to fail/be updated by `--bless`, a different part of the file needs to also have changed.
2024-03-20 16:25:29 +00:00
Guillaume Gomez
98e66553a6 Rename hir::Let into hir::LetExpr 2024-03-20 16:47:11 +01:00
bors
94b72d6beb Auto merge of #122359 - Zoxc:missing-static-notes, r=wesleywiser
Print the crates not available as static

This prints out the crates not available to be statically linked when static linking is preferred and we run into an error with duplicated crates.
2024-03-20 15:46:15 +00:00
Mara Bos
34621757ea SeqCst->Relaxed in condvar test.
Relaxed is enough here. Synchronization is done by the mutex.
2024-03-20 15:38:09 +01:00
Mara Bos
acddc55748 SeqCst->Relaxed in thread local test.
Relaxed memory ordering is fine because spawn()/join() already provides
all the synchronization we need.
2024-03-20 15:38:09 +01:00
Mara Bos
b45a725cbc SeqCst->Relaxed in std::net::test.
Relaxed is enough to have fetch_add(1) return each value only once
(until it wraps around).
2024-03-20 15:35:13 +01:00
Mara Bos
8b519f98e2 Use less restricted memory ordering in xous::thread_local_key.
SeqCst isn't necessary in any of these cases.
2024-03-20 15:35:11 +01:00
bors
a128516cf9 Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68
Bump to 1.78 bootstrap compiler

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-03-20 13:43:41 +00:00
Mark Rousskov
9a22a0fdab Fix bootstrap bump fallout 2024-03-20 08:49:13 -04:00
Mark Rousskov
283db5abfc Workaround for rustdoc bug in new beta
Filed #122758 to track a proper fix, but this seems to solve the
problem in the meantime and is probably OK in terms of impact on
(internal) doc quality.
2024-03-20 08:49:13 -04:00
Mark Rousskov
02f1930595 step cfgs 2024-03-20 08:49:13 -04:00
bors
c86f3ac24f Auto merge of #120717 - compiler-errors:cap-closure-kind, r=oli-obk
For async closures, cap closure kind, get rid of `by_mut_body`

Right now we have three `AsyncFn*` traits, and three corresponding futures that are returned by the `call_*` functions for them. This is fine, but it is a bit excessive, since the future returned by `AsyncFn` and `AsyncFnMut` are identical. Really, the only distinction we need to make with these bodies is "by ref" and "by move".

This PR removes `AsyncFn::CallFuture` and renames `AsyncFnMut::CallMutFuture` to `AsyncFnMut::CallRefFuture`. This simplifies MIR building for async closures, since we don't need to build an extra "by mut" body, but just a "by move" body which is materially different.

We need to do a bit of delicate handling of the ClosureKind for async closures, since we need to "cap" it to `AsyncFnMut` in some cases when we only care about what body we're looking for.

This also fixes a bug where `<{async closure} as Fn>::call` was returning a body that takes the async-closure receiver *by move*.

This also helps align the `AsyncFn` traits to the `LendingFn` traits' eventual designs.
2024-03-20 11:40:45 +00:00
bors
0f706af330 Auto merge of #122763 - matthiaskrgr:rollup-o8a2mye, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #121543 (various clippy fixes)
 - #122540 (Do not use `?`-induced skewing of type inference in the compiler)
 - #122730 (Expose `ucred::peer_cred` on QNX targets to enable dist builds)
 - #122732 (Remove redundant coroutine captures note)
 - #122739 (Add "put" as a confusable for insert on hash map/set)
 - #122748 (Reduce `pub` usage in `rustc_session`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-20 09:37:39 +00:00
Jubilee Young
92f668c20b Add usize::MAX arg tests for Vec 2024-03-20 01:21:19 -07:00
Zalathar
2f21e4f8bb coverage: Tidy imports in rustc_mir_transform::coverage::counters 2024-03-20 18:25:53 +11:00
Zalathar
85bec7a50c coverage: Remove incorrect assertions from counter allocation
These assertions detect situations where a BCB node would have both a physical
counter and one or more in-edge counters/expressions.

For most BCBs that situation would indicate an implementation bug. However,
it's perfectly fine in the case of a BCB having an edge that loops back to
itself.

Given the complexity and risk involved in fixing the assertions, and the fact
that nothing relies on them actually being true, this patch just removes them
instead.
2024-03-20 18:22:15 +11:00
Zalathar
70206f06ca coverage: Regression test for ICE triggered by self-loops 2024-03-20 18:14:35 +11:00
Matthias Krüger
53a753e31f
Rollup merge of #122748 - nnethercote:rustc_session-pub, r=jackh726
Reduce `pub` usage in `rustc_session`.

In particular, almost none of the errors in `errors.rs` are used outside the crate.

r? `@jackh726`
2024-03-20 05:51:24 +01:00
Matthias Krüger
d7209bf858
Rollup merge of #122739 - Sky9x:insert-put, r=jhpratt
Add "put" as a confusable for insert on hash map/set

Already a confusable on btree map/set.

Java's `Map` calls the insert method `put`: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html#put(K,V)
2024-03-20 05:51:24 +01:00
Matthias Krüger
ffdb147aa4
Rollup merge of #122732 - compiler-errors:coroutine-captures-note, r=nnethercote
Remove redundant coroutine captures note

This note is redundant, since we'll always be printing this "captures the following types..." between *more* descriptive `BuiltinDerivedObligationCause`s.

Please review with whitespace disabled, since I also removed an unnecessary labeled break.
2024-03-20 05:51:23 +01:00
Matthias Krüger
2cf93ac9c8
Rollup merge of #122730 - ferrocene:hoverbear/qnx-ucred-cfgs, r=Amanieu
Expose `ucred::peer_cred` on QNX targets to enable dist builds

After following https://doc.rust-lang.org/rustc/platform-support/nto-qnx.html I attempted to run the following `x.py` command:

```bash
export build_env='
    CC_aarch64-unknown-nto-qnx710=qcc
    CFLAGS_aarch64-unknown-nto-qnx710=-Vgcc_ntoaarch64le_cxx
    CXX_aarch64-unknown-nto-qnx710=qcc
    AR_aarch64_unknown_nto_qnx710=ntoaarch64-ar
    CC_x86_64-pc-nto-qnx710=qcc
    CFLAGS_x86_64-pc-nto-qnx710=-Vgcc_ntox86_64_cxx
    CXX_x86_64-pc-nto-qnx710=qcc
    AR_x86_64_pc_nto_qnx710=ntox86_64-ar'
env $build_env ./x.py --stage 2 dist rust-std  --target aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710,x86_64-unknown-linux-gnu
```

The result was the following error:

```
   Compiling object v0.32.2
   Compiling std_detect v0.1.5 (/home/ana/git/rust-lang/rust/library/stdarch/crates/std_detect)
   Compiling addr2line v0.21.0
error: function `peer_cred` is never used
  --> library/std/src/os/unix/net/ucred.rs:89:12
   |
89 |     pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
   |            ^^^^^^^^^
   |
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`

error: could not compile `std` (lib) due to 1 previous error
Build completed unsuccessfully in 0:06:25
```

I contacted `@flba-eb` and `@gh-tr` over email and we confirmed that `peer_cred` here should be flagged on `nto` targets. This should enable the clean `x.py --stage 2 dist rust-std` command on these platforms.
2024-03-20 05:51:23 +01:00
Matthias Krüger
9fb40efa6d
Rollup merge of #122540 - WaffleLapkin:ununexpected, r=estebank
Do not use `?`-induced skewing of type inference in the compiler

This prevents breakage from #122412 and is generally a good idea.

r? `@estebank`
2024-03-20 05:51:22 +01:00
Matthias Krüger
4f3050b85a
Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obk
various clippy fixes

We need to keep the order of the given clippy lint rules before passing them.
Since clap doesn't offer any useful interface for this purpose out of the box,
we have to handle it manually.

Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well.

Fixes #121481
cc `@matthiaskrgr`
2024-03-20 05:51:22 +01:00
Joshua Wong
37718f949f fix OOB pointer formed in Vec::index
Move the length check to before using `index` with `ptr::add` to prevent
an out of bounds pointer from being formed.

Fixes #122760
2024-03-19 22:47:35 -05:00
bors
b7dcabe55e Auto merge of #122119 - estebank:issue-117846, r=Nadrieril
Silence unecessary !Sized binding error

When gathering locals, we introduce a `Sized` obligation for each
binding in the pattern. *After* doing so, we typecheck the init
expression. If this has a type failure, we store `{type error}`, for
both the expression and the pattern. But later we store an inference
variable for the pattern.

We now avoid any override of an existing type on a hir node when they've
already been marked as `{type error}`, and on E0277, when it comes from
`VariableType` we silence the error in support of the type error.

Fix https://github.com/rust-lang/rust/issues/117846
2024-03-20 02:36:37 +00:00
bors
a77c20c4b9 Auto merge of #122753 - weihanglo:update-cargo, r=weihanglo
Update cargo

5 commits in 2fe739fcf16c5bf8c2064ab9d357f4a0e6c8539b..d438c80c45c24be676ef5867edc79d0a14910efe
2024-03-15 21:39:18 +0000 to 2024-03-19 16:11:22 +0000
- refactor(toml): Expose surce/spans for VirtualManifests (rust-lang/cargo#13603)
- cargo/init: avoid target.name assignments if possible (rust-lang/cargo#13606)
- chore: Fix minor grammar nit in command-line help (rust-lang/cargo#13602)
- Bump to 0.80.0; update changelog (rust-lang/cargo#13604)
- cargo: prevent dashes in lib.name (rust-lang/cargo#12783)

r? ghost
2024-03-20 00:33:53 +00:00
Mark Rousskov
e4c58eb8da Bump stage0 2024-03-19 19:27:24 -04:00
Mark Rousskov
4fb89c5056 branch 1.78: replace-version-placeholder 2024-03-19 19:27:24 -04:00
Weihang Lo
ae2933656d
Update cargo 2024-03-19 18:31:12 -04:00
bors
bd459c2877 Auto merge of #122029 - estebank:drive-by-ui-test, r=oli-obk
When displaying multispans, ignore empty lines adjacent to `...`

```
error[E0308]: `match` arms have incompatible types
   --> tests/ui/codemap_tests/huge_multispan_highlight.rs:98:18
    |
6   |       let _ = match true {
    |               ---------- `match` arms have incompatible types
7   |           true => (
    |  _________________-
8   | |             // last line shown in multispan header
...   |
96  | |
97  | |         ),
    | |_________- this is found to be of type `()`
98  |           false => "
    |  __________________^
...   |
119 | |
120 | |         ",
    | |_________^ expected `()`, found `&str`

error[E0308]: `match` arms have incompatible types
   --> tests/ui/codemap_tests/huge_multispan_highlight.rs:215:18
    |
122 |       let _ = match true {
    |               ---------- `match` arms have incompatible types
123 |           true => (
    |  _________________-
124 | |
125 | |         1 // last line shown in multispan header
...   |
213 | |
214 | |         ),
    | |_________- this is found to be of type `{integer}`
215 |           false => "
    |  __________________^
216 | |
217 | |
218 | |         1 last line shown in multispan
...   |
237 | |
238 | |         ",
    | |_________^ expected integer, found `&str`
```
2024-03-19 22:11:59 +00:00
Esteban Küber
b1575b71d4 Silence unecessary !Sized binding error
When gathering locals, we introduce a `Sized` obligation for each
binding in the pattern. *After* doing so, we typecheck the init
expression. If this has a type failure, we store `{type error}`, for
both the expression and the pattern. But later we store an inference
variable for the pattern.

We now avoid any override of an existing type on a hir node when they've
already been marked as `{type error}`, and on E0277, when it comes from
`VariableType` we silence the error in support of the type error.

Fix #117846.
2024-03-19 21:26:11 +00:00
onur-ozkan
81d7d7aabd resolve clippy errors
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-20 00:12:00 +03:00
Nicholas Nethercote
de38888256 Reduce pub usage in rustc_session.
In particular, almost none of the errors in `errors.rs` are used outside
the crate.
2024-03-20 08:07:15 +11:00
Michael Goulet
541858ed78 Add a few more comments 2024-03-19 16:59:24 -04:00
Michael Goulet
f1fef64e19 Fix ABI for FnMut/Fn impls for async closures 2024-03-19 16:59:24 -04:00