Commit Graph

251477 Commits

Author SHA1 Message Date
lcnr
4fa5fb684e move leak check out of candidate evaluation
this prevents higher ranked goals from guiding selection
2024-04-03 22:32:46 +01:00
Nadrieril
e2ebaa1a08 Add if let tests 2024-04-03 23:16:27 +02:00
Slanterns
fbc56dfac1
Stabilize Literal::c_string 2024-04-04 05:04:27 +08:00
Slanterns
61ac7812c6
Stabilize Literal::byte_character 2024-04-04 05:00:49 +08:00
bors
4fd4797c26 Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121595 (Better reporting on generic argument mismatchs)
 - #122619 (Fix some unsoundness with PassMode::Cast ABI)
 - #122964 (Rename `expose_addr` to `expose_provenance`)
 - #123291 (Move some tests)
 - #123301 (pattern analysis: fix union handling)
 - #123395 (More postfix match fixes)
 - #123419 (rustc_index: Add a `ZERO` constant to index types)
 - #123421 (Fix target name in NetBSD platform-support doc)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 20:19:51 +00:00
Matthias Krüger
65398c46b8
Rollup merge of #123421 - taiki-e:netbsd-doc, r=Nilstrieb
Fix target name in NetBSD platform-support doc

NetBSD platform-support doc currently mentions `amd64-unknown-netbsd`, but it is not a valid target name (the correct name is `x86_64-unknown-netbsd`).

ceab6128fa/src/doc/rustc/src/platform-support/netbsd.md (L16)

```console
$ rustc --print target-list | grep netbsd
aarch64-unknown-netbsd
aarch64_be-unknown-netbsd
armv6-unknown-netbsd-eabihf
armv7-unknown-netbsd-eabihf
i586-unknown-netbsd
i686-unknown-netbsd
mipsel-unknown-netbsd
powerpc-unknown-netbsd
riscv64gc-unknown-netbsd
sparc64-unknown-netbsd
x86_64-unknown-netbsd
```
2024-04-03 22:11:02 +02:00
Matthias Krüger
25b0e84170
Rollup merge of #123419 - petrochenkov:zeroindex, r=compiler-errors
rustc_index: Add a `ZERO` constant to index types

It is commonly used.
2024-04-03 22:11:02 +02:00
Matthias Krüger
202509b427
Rollup merge of #123395 - compiler-errors:postfix-matches-fixes-2, r=petrochenkov
More postfix match fixes

These affect diagnostics only, as far as I can tell. I'm too lazy to come up with UI tests, but I could be convinced otherwise.

Specifically, I think changing the precedence computation actually doesn't change anything, but tweaking `contains_exterior_struct_lit` does mean that some diagnostics will begin parenthesizing `S {}.match {}`.
2024-04-03 22:11:01 +02:00
Matthias Krüger
5f74403c8e
Rollup merge of #123301 - Nadrieril:unions, r=compiler-errors
pattern analysis: fix union handling

Little known fact: rust supports union patterns. Exhaustiveness handles them soundly but reports nonsensical missing patterns. This PR fixes the reported patterns and documents what we're doing.

r? `@compiler-errors`
2024-04-03 22:11:01 +02:00
Matthias Krüger
0c8c18fcc6
Rollup merge of #123291 - c410-f3r:testsssssss, r=petrochenkov
Move some tests

r? `@petrochenkov`
2024-04-03 22:11:01 +02:00
Matthias Krüger
80d592cc24
Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu
Rename `expose_addr` to `expose_provenance`

`expose_addr` is a bad name, an address is just a number and cannot be exposed. The operation is actually about the provenance of the pointer.

This PR thus changes the name of the method to `expose_provenance` without changing its return type. There is sufficient precedence for returning a useful value from an operation that does something else without the name indicating such, e.g. [`Option::insert`](https://doc.rust-lang.org/nightly/std/option/enum.Option.html#method.insert) and [`MaybeUninit::write`](https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.write).

Returning the address is merely convenient, not a fundamental part of the operation. This is implied by the fact that integers do not have provenance since
```rust
let addr = ptr.addr();
ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
must behave exactly like
```rust
let addr = ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
as the result of `ptr.expose_provenance()` and `ptr.addr()` is the same integer. Therefore, this PR removes the `#[must_use]` annotation on the function and updates the documentation to reflect the important part.

~~An alternative name would be `expose_provenance`. I'm not at all opposed to that, but it makes a stronger implication than we might want that the provenance of the pointer returned by `ptr::with_exposed_provenance`[^1] is the same as that what was exposed, which is not yet specified as such IIUC. IMHO `expose` does not make that connection.~~

A previous version of this PR suggested `expose` as name, libs-api [decided on](https://github.com/rust-lang/rust/pull/122964#issuecomment-2033194319) `expose_provenance` to keep the symmetry with `with_exposed_provenance`.

CC `@RalfJung`
r? libs-api

[^1]: I'm using the new name for `from_exposed_addr` suggested by #122935 here.
2024-04-03 22:11:00 +02:00
Matthias Krüger
bc8415b9e6
Rollup merge of #122619 - erikdesjardins:cast, r=compiler-errors
Fix some unsoundness with PassMode::Cast ABI

Fixes #122617

Reviewable commit-by-commit. More info in each commit message.
2024-04-03 22:11:00 +02:00
Matthias Krüger
32c8c5cb7e
Rollup merge of #121595 - strottos:issue_116615, r=compiler-errors
Better reporting on generic argument mismatchs

This allows better reporting as per issue #116615 .

If you have a function:
```
fn foo(a: T, b: T) {}
```
and call it like so:
```
foo(1, 2.)
```
it'll give improved error reported similar to the following:
```
error[E0308]: mismatched types
 --> generic-mismatch-reporting-issue-116615.rs:6:12
  |
6 |     foo(1, 2.);
  |     --- -  ^^ expected integer, found floating-point number
  |     |   |
  |     |   expected argument `b` to be an integer because that argument needs to match the type of this parameter
  |     arguments to this function are incorrect
  |
note: function defined here
 --> generic-mismatch-reporting-issue-116615.rs:1:4
  |
1 | fn foo<T>(a: T, b: T) {}
  |    ^^^ -  ----  ----
  |        |  |     |
  |        |  |     this parameter needs to match the integer type of `a`
  |        |  `b` needs to match the type of this parameter
  |        `a` and `b` all reference this parameter T
```

Open question, do we need to worry about error message translation into other languages? Not sure what the status of that is in Rust.

NB: Needs some checking over and some tests have altered that need sanity checking, but overall this is starting to get somewhere now. Will take out of draft PR status when this has been done, raising now to allow feedback at this stage, probably 90% ready.
2024-04-03 22:10:59 +02:00
Trevor Gross
5afe072ead Fix f16 and f128 feature gates in editions other than 2015
Fixes https://github.com/rust-lang/rust/issues/123282

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2024-04-03 16:03:22 -04:00
Trevor Gross
9a7b176227 Update f16 and f128 tests to run on both 2015 and 2018 editions
Reproduce the bug from <https://github.com/rust-lang/rust/issues/123282>
that indicates this feature gate hits edition-dependent resolution paths.
Resolution changed in edition 2018, so test that as well.
2024-04-03 16:03:22 -04:00
Nadrieril
8021192d34 More precise false edges 2024-04-03 21:02:47 +02:00
Nadrieril
8f80259f10 Explain false edges in more detail 2024-04-03 21:02:47 +02:00
Nadrieril
50103ab14d Add tests 2024-04-03 21:02:47 +02:00
bors
98efd808e1 Auto merge of #123415 - petrochenkov:parenting, r=compiler-errors
hir: Drop owner's own item-local id (zero) from parenting tables

I expect this to be a common case.
2024-04-03 18:18:44 +00:00
Zander Milroy
ce4cc9df96 Use SVG logos in the README.md.
These should likely eventually reference the rust-lang.org site instead
of raw.githubusercontent.com
2024-04-03 19:48:20 +02:00
Taiki Endo
6edb021fd3 Fix target name in NetBSD platform-support doc 2024-04-04 01:31:04 +09:00
bors
703dc9ce64 Auto merge of #123416 - matthiaskrgr:rollup-j85wj05, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #123209 (Add section to sanitizer doc for `-Zexternal-clangrt`)
 - #123342 (x.py test: remove no-op --skip flag)
 - #123382 (Assert `FnDef` kind)
 - #123386 (Set `CARGO` instead of `PATH` for Rust Clippy)
 - #123393 (rustc_ast: Update `P<T>` docs to reflect mutable status.)
 - #123394 (Postfix match fixes)
 - #123412 (Output URLs of CI artifacts to GitHub summary)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 16:16:52 +00:00
Vadim Petrochenkov
b40ea03f8a rustc_index: Add a ZERO constant to index types
It is commonly used.
2024-04-03 19:06:22 +03:00
Michael Goulet
bd8ca780a5 Fix up error message for debug_assert_args_compat for IATs 2024-04-03 11:18:56 -04:00
Michael Goulet
03163ef9d9 Don't fill non-ty args with ty::Error 2024-04-03 11:18:56 -04:00
Michael Goulet
657dadf2cc Simplify some cfging 2024-04-03 11:18:56 -04:00
Michael Goulet
c9f8529793 Uplift and start using check_args_compatible more liberally 2024-04-03 11:18:55 -04:00
Michael Goulet
e3025d6a55 Stop chopping off args for no reason 2024-04-03 11:16:58 -04:00
Matthias Krüger
658c8f7367
Rollup merge of #123412 - Kobzol:ci-artifacts-in-summary, r=Mark-Simulacrum
Output URLs of CI artifacts to GitHub summary

I often want to download CI artifacts published from our workflows (I suspect others might do the same), but it's a bit annoying to extract their links from the CI logs currently. This PR also outputs URLs to them to the GitHub Actions summaries.

r? `@Mark-Simulacrum`
2024-04-03 17:15:50 +02:00
Matthias Krüger
deb48aa0f5
Rollup merge of #123394 - compiler-errors:postfix-match-fixes, r=estebank
Postfix match fixes

1. Don't ice on `expr as Ty.match {}`
2. Fix the suggestion span for non-exhaustive matches to add `_ => todo!(),`

Fixes #123383
2024-04-03 17:15:50 +02:00
Matthias Krüger
0c11f13a57
Rollup merge of #123393 - aDotInTheVoid:ast-p-docs, r=Nilstrieb
rustc_ast: Update `P<T>` docs to reflect mutable status.

`P<T>` has implemented `DerefMut` since #54277. While this was lamented at the time [1], rustc now relies on it extensively via the many implementors of MutVisitor [2].

Updates the docs to reflect that `P<T>` is fundamentally mutable, and a few other cleanups to make them nicer to browse.

[1]: https://github.com/rust-lang/rust/pull/54277#discussion_r257181754
[2]: https://doc.rust-lang.org/1.77.1/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html#implementors

r? `@Nilstrieb`
2024-04-03 17:15:49 +02:00
Matthias Krüger
29c72ce183
Rollup merge of #123386 - Rajveer100:branch-for-issue-123227, r=onur-ozkan
Set `CARGO` instead of `PATH` for Rust Clippy

Resolves #123227

Previously, clippy was using `cargo` from `PATH`, but since [PR](https://github.com/rust-lang/rust-clippy/pull/11944), it now prioritises checking `CARGO` first.
2024-04-03 17:15:49 +02:00
Matthias Krüger
94c402733d
Rollup merge of #123382 - compiler-errors:assert-fndef-kind, r=fmease
Assert `FnDef` kind

Only found one bug, where we were using the variant def id rather than its ctor def id to make the `FnDef` for a `type_of`

r? fmease
2024-04-03 17:15:48 +02:00
Matthias Krüger
f7c34c03be
Rollup merge of #123342 - RalfJung:noskip, r=onur-ozkan
x.py test: remove no-op --skip flag

None of the test commands seems to do anything with this flag, so we might as well remove it.
2024-04-03 17:15:48 +02:00
Matthias Krüger
1bde86b18b
Rollup merge of #123209 - ObsidianMinor:doc/external-clangrt, r=michaelwoerister
Add section to sanitizer doc for `-Zexternal-clangrt`

After spending a week looking for answers to how to do the very thing this flag lets me do, it felt appropriate to document it where I would've expected it to be.
2024-04-03 17:15:47 +02:00
Vadim Petrochenkov
44b3602478 hir: Drop owner's own item-local id (zero) from parenting tables 2024-04-03 17:33:34 +03:00
joboet
989660c3e6
rename expose_addr to expose_provenance 2024-04-03 16:00:38 +02:00
Jakub Beránek
508530dbc5 Output URLs of CI artifacts to GitHub summary 2024-04-03 15:33:40 +02:00
bors
ceab6128fa Auto merge of #123390 - tgross35:f16-f128-libs-basic-impls-bootstrap, r=jhpratt
Put basic impls for f16 and f128 behind cfg(not(bootstrap))

We will lose `f16` and `f128` in the beta compiler after the revert for <https://github.com/rust-lang/rust/issues/123282> lands. Change what was added in <https://github.com/rust-lang/rust/pull/123085> to be behind `#[cfg(not(bootstrap))]` to account for this.
2024-04-03 12:32:34 +00:00
Rajveer
66dee4a9aa Set CARGO instead of PATH for Rust Clippy
Resolves #123227
2024-04-03 17:17:40 +05:30
bors
99c42d2340 Auto merge of #123322 - matthewjasper:remove-mir-unsafeck, r=lcnr,compiler-errors
Remove MIR unsafe check

Now that THIR unsafeck is enabled by default in stable I think we can remove MIR unsafeck entirely. This PR also removes safety information from MIR.
2024-04-03 10:30:34 +00:00
Matthew Jasper
a277c901d9 Remove MIR unsafe check
This also remove safety information from MIR.
2024-04-03 08:50:12 +00:00
Alona Enraght-Moony
5075931290 rustc_ast: Update P<T> docs to reflect mutable status.
`P<T>` has implemented `DerefMut` since #54277. While this was lamented
at the time [1], rustc now relies on it extensively via the many
implementors of MutVisitor [2].

Updates the docs to reflect that `P<T>` is fundamentally mutable, and a
few other cleanups to make them nicer to browse.

[1]: https://github.com/rust-lang/rust/pull/54277#discussion_r257181754
[2]: https://doc.rust-lang.org/1.77.1/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html#implementors
2024-04-03 08:41:03 +00:00
bors
c7491b9733 Auto merge of #123402 - workingjubilee:rollup-0j5ihn6, r=workingjubilee
Rollup of 4 pull requests

Successful merges:

 - #122411 ( Provide cabi_realloc on wasm32-wasip2 by default )
 - #123349 (Fix capture analysis for by-move closure bodies)
 - #123359 (Link against libc++abi and libunwind as well when building LLVM wrappers on AIX)
 - #123388 (use a consistent style for links)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 08:28:48 +00:00
Jubilee
0c0d88864a
Rollup merge of #123388 - tshepang:consistency, r=jhpratt
use a consistent style for links
2024-04-02 23:44:29 -07:00
Jubilee
04a7a559fc
Rollup merge of #123359 - bzEq:aix-libc++abi, r=cuviper
Link against libc++abi and libunwind as well when building LLVM wrappers on AIX

Unlike `libc++.so` on Linux which is a linker script
```ld
INPUT(libc++.so.1 -lc++abi -lunwind)
```
AIX linker doesn't support such script, so `c++abi` and `unwind` have to be specified explicitly.
2024-04-02 23:44:29 -07:00
Jubilee
f700fb24f3
Rollup merge of #123349 - compiler-errors:async-closure-captures, r=oli-obk
Fix capture analysis for by-move closure bodies

The check we were doing to figure out if a coroutine was borrowing from its parent coroutine-closure was flat-out wrong -- a misunderstanding of mine of the way that `tcx.closure_captures` represents its captures.

Fixes #123251 (the miri/ui test I added should more than cover that issue)

r? `@oli-obk` -- I recognize that this PR may be underdocumented, so please ask me what I should explain further.
2024-04-02 23:44:29 -07:00
Jubilee
abb0393595
Rollup merge of #122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-se
Provide cabi_realloc on wasm32-wasip2 by default

This commit provides a component model intrinsic in the standard library
by default on the `wasm32-wasip2` target. This intrinsic is not
required by the component model itself but is quite common to use, for
example it's needed if a wasm module receives a string or a list.

The intention of this commit is to provide an overridable definition in
the standard library through a weak definition of this function. That
means that downstream crates can provide their own customized and more
specific versions if they'd like, but the standard library's version
should suffice for general-purpose use.
2024-04-02 23:44:28 -07:00
bors
76cf07d5df Auto merge of #122225 - DianQK:nits-120268, r=cjgillot
Rename `UninhabitedEnumBranching` to `UnreachableEnumBranching`

Per [#120268](https://github.com/rust-lang/rust/pull/120268#discussion_r1517492060), I rename `UninhabitedEnumBranching` to `UnreachableEnumBranching` .

I solved some nits to add some comments.

I adjusted the workaround restrictions. This should be useful for `a <= b` and `if let Some/Ok(v)`. For enum with few variants, `early-tailduplication` should not cause compile time overhead.

r? RalfJung
2024-04-03 06:22:23 +00:00
Urgau
120c6b1684 Add nice header to our README.md 2024-04-03 08:00:51 +02:00