Commit Graph

252437 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
1870e2d09f
Rollup merge of #123922 - TDecking:base_n_magic_removal, r=jieyouxu
Remove magic constants when using `base_n`.

Some use cases of `base_n` use number literals instead of the predefined constants. The latter are more descriptive so it might be better to use those instead.
2024-04-15 16:56:17 +01:00
许杰友 Jieyou Xu (Joe)
b1d1e081be
Rollup merge of #123919 - RalfJung:discriminant, r=compiler-errors
builtin-derive: tag → discriminant

As far as I can tell, all of this operates on the discriminant, not the tag. After all, with something like `Option<&T>`, the "tag" of the `Some` variant is basically just the reference value, which is never what you want to compare when figuring out which variant the enum is in.

See [here](https://rustc-dev-guide.rust-lang.org/appendix/glossary.html) for an explanation of the difference between tag and discriminant.
2024-04-15 16:56:16 +01:00
许杰友 Jieyou Xu (Joe)
18e6bb2851
Rollup merge of #123896 - JeanCASPAR:rustc_resolve-to-session-diagnostic, r=jieyouxu
Migrate some diagnostics in `rustc_resolve` to session diagnostic

Hello, I migrated some diagnostics in `rustc_resolve` to session diagnostic.

r? ``@davidtwco``
2024-04-15 16:56:15 +01:00
许杰友 Jieyou Xu (Joe)
699612fb8a
Rollup merge of #123864 - oli-obk:define_opaque_types3, r=compiler-errors
Remove a HACK by instead inferring opaque types during expected/formal type checking

I was wondering why I couldn't come up with a test that hits the code path of the argument check checking the types we inferred from the return type... Turns out we reject those attempts early during fudging.

I have absolutely no information for you as to what kind of type inference changes this may incur, but I think we should just land this out of two reasons:

* had I found the other place to use opaque type inference on before I added the hack, we'd be using that today and this PR would never have happened
* if it is possible to hit this path, it requires some god awful recursive RPIT logic that I doubt anyone would have written without actively trying to write obscure code

r? ``@ghost``
2024-04-15 16:56:15 +01:00
许杰友 Jieyou Xu (Joe)
4d2a8e3692
Rollup merge of #123666 - mountcount:master, r=lqd
Fix some typos in doc
2024-04-15 16:56:14 +01:00
许杰友 Jieyou Xu (Joe)
2074631732
Rollup merge of #123548 - RalfJung:what-is-time, r=joboet
libtest: also measure time in Miri

A long time ago we disabled timekeeping of the default test harness in Miri, as otherwise it would fail to run without `-Zmiri-disable-isolation`. However, since then Miri gained a "fake clock" that lets it present some deterministic notion of time when isolation is enabled.

So we could now let libtest do timekeeping again when running in Miri. That's nice as it can help detect tests that run too long. However it can also be confusing as the results with isolation can be quite different than the real time.

``@rust-lang/miri`` what do you think?
2024-04-15 16:56:14 +01:00
许杰友 Jieyou Xu (Joe)
e07d18fb2f
Rollup merge of #123423 - kjetilkjeka:llvm_bitcode_linker_component, r=Mark-Simulacrum
Distribute LLVM bitcode linker as a preview component

The self-contained LLVM bitcode linker was recently added in #117458. It is currently only in use to link the Nvidia ptx assembly tests when running rustc tests (local or CI). In fact, the linker itself is currently only usable for the `nvptx64-nvidia-cuda` target, but more targets will be supported in the future.

The reason a new linker was needed for the ptx format is that the [old one](https://github.com/denzp/rust-ptx-linker) has not been updated the last few years. It worked fine for a while, but as LLVM changed it broke and the nvptx tests was [disabled in rustc back in 2019](f8f9a2869c). It was ad-hoc patched and have been used in a sub-optimal state by the community until now.

If this PR is merged, the LLVM bitcode linker will be distributed as a preview component that can be used as a replacement for the old ptx-linker for development in addition to rustc tests. In addition to installing the `llvm-bitcode-linker` component, also the `llvm-tools` component must be installed as the `llvm-bitcode-linker` works by calling llvm tools.

Even though the LLVM bitcode linker is in its early stages it already now provides a lot of value over the old ptx-linker just by working and using up-to-date llvm tooling. By shipping it as a component it will be easier to gather user experience and improving it.

``@petrochenkov`` when installing as a component it will be installed in the self-contained folder and will not work with `-Clink-self-contained=no` (although for some reason I expect to be a bug `-Clink-self-contained=-linker` doesn't properly disable it). However, when building using `x.py build` it will be placed in the `lib/rustlib/<target>/bin` directory and will be available for internal tests even if `-Clink-self-contained=no` is passed.

CC: ``@Mark-Simulacrum`` as I very briefly discussed it with you some months ago https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/.E2.9C.94.20How.20to.20ship.20a.20new.20tool.20.28embedded.20linker.29.20to.20users.3F
2024-04-15 16:56:13 +01:00
Kjetil Kjeka
235d45e9c9 Distribute LLVM bitcode linker as a preview component 2024-04-15 15:11:28 +02:00
bors
84e729a59f Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi
Update document for std::io::Error::downcast

Resolve concern raised by `@BurntSushi` https://github.com/rust-lang/rust/issues/99262#issuecomment-2042641813
2024-04-15 12:32:57 +00:00
Jiahao XU
05366ee270
Update doc for std::io::Error::downcast 2024-04-15 21:58:36 +10:00
bors
d493fd148d Auto merge of #115717 - jsgf:stablize-json-unused-externs, r=oli-obk
Stabilize --json unused-externs(-silent)

Implement https://github.com/rust-lang/compiler-team/issues/674 ~~(pending its approval)~~
2024-04-15 10:11:46 +00:00
mountcount
7d1ee8c0fb Fix some typos in doc
Signed-off-by: mountcount <cuimoman@outlook.com>
2024-04-15 16:39:37 +08:00
bors
5dcb678ad8 Auto merge of #122917 - saethlin:atomicptr-to-int, r=nikic
Add the missing inttoptr when we ptrtoint in ptr atomics

Ralf noticed this here: https://github.com/rust-lang/rust/pull/122220#discussion_r1535172094

Our previous codegen forgot to add the cast back to integer type. The code compiles anyway, because of course all locals are in-memory to start with, so previous codegen would do the integer atomic, store the integer to a local, then load a pointer from that local. Which is definitely _not_ what we wanted: That's an integer-to-pointer transmute, so all pointers returned by these `AtomicPtr` methods didn't have provenance. Yikes.

Here's the IR for `AtomicPtr::fetch_byte_add` on 1.76: https://godbolt.org/z/8qTEjeraY
```llvm
define noundef ptr `@atomicptr_fetch_byte_add(ptr` noundef nonnull align 8 %a, i64 noundef %v) unnamed_addr #0 !dbg !7 {
start:
  %0 = alloca ptr, align 8, !dbg !12
  %val = inttoptr i64 %v to ptr, !dbg !12
  call void `@llvm.lifetime.start.p0(i64` 8, ptr %0), !dbg !28
  %1 = ptrtoint ptr %val to i64, !dbg !28
  %2 = atomicrmw add ptr %a, i64 %1 monotonic, align 8, !dbg !28
  store i64 %2, ptr %0, align 8, !dbg !28
  %self = load ptr, ptr %0, align 8, !dbg !28
  call void `@llvm.lifetime.end.p0(i64` 8, ptr %0), !dbg !28
  ret ptr %self, !dbg !33
}
```

r? `@RalfJung`
cc `@nikic`
2024-04-15 08:07:47 +00:00
Ralf Jung
510720e9fc libtest: also measure time in Miri 2024-04-15 09:50:42 +02:00
bors
85b884b058 Auto merge of #122997 - matthiaskrgr:compiletest_ices, r=oli-obk
compiletest ice tracking

see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/where.20to.20mass-add.20known.20ices.20.2F.20merging.20glacier.20into.20rust/near/429082963

This will allow us to sunset most of https://github.com/rust-lang/glacier
The rustc ices will be tracked directly inside the rust testsuite
There are a couple of .sh tests remaining that I have not ported over yet.

This adds `tests/crashes`, a file inside this directory MUST ice, otherwise it is considered test-fail.
This will be used to track ICEs from glacier and the bugtracker.
When someones pr accidentally fixes one of these ICEs, they can move the test from `crashes` into `ui` for example.

I also added a new tidy lint that warns when a test inside `tests/crashes` does not have a `//@ known-bug: ` line

the env var `COMPILETEST_VERBOSE_CRASHES` can be set to get exit code, stderr and stdout of a crash-test to aid debugging/adding tests.
2024-04-15 06:04:50 +00:00
bors
9db7a74525 Auto merge of #123928 - tbu-:pr_statx_enosys, r=workingjubilee
`statx` probe: `ENOSYS` might come from a faulty FUSE driver

Do the availability check regardless of the error returned from `statx`.

CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-15 02:07:35 +00:00
bors
1d8f4a6d9c Auto merge of #123828 - cuviper:cargo-aarch64-gnu, r=Mark-Simulacrum
ci: test cargo on `aarch64-gnu`

Since `aarch64-unknown-linux-gnu` is a tier-1 target, we should also test cargo on it, especially since cargo's own CI doesn't cover this yet. This might have helped us discover #123733 sooner, which is not a cargo problem but was uncovered by a new cargo test (which we'll have to skip for now). Everything else passes in my local run, so at least we'll have a guard against future regressions.
2024-04-15 00:04:04 +00:00
Matthias Krüger
2ce487c45c crashes: limit a couple tests to only run on x86_64 and/or not on windows 2024-04-14 23:53:39 +02:00
bors
0d8b3346a3 Auto merge of #123945 - GuillaumeGomez:rollup-14x3enh, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #120900 (std: use `stream_position` where applicable)
 - #123373 (skip Codegen{GCC,Cranelift} when using CI rustc)
 - #123618 (Discard overflow obligations in `impl_may_apply`)
 - #123905 (rustdoc: check redundant explicit links with correct itemid)
 - #123915 (improve documentation slightly regarding some pointer methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-14 21:47:39 +00:00
Guillaume Gomez
32be7b7129
Rollup merge of #123915 - shenawy29:patch-1, r=Nilstrieb
improve documentation slightly regarding some pointer methods
2024-04-14 23:24:34 +02:00
Guillaume Gomez
4d32bc3801
Rollup merge of #123905 - notriddle:notriddle/redundant-explicit-link-hunks, r=GuillaumeGomez
rustdoc: check redundant explicit links with correct itemid

Fixes #123677 (a regression caused by #120702)
2024-04-14 23:24:34 +02:00
Guillaume Gomez
86b791a272
Rollup merge of #123618 - compiler-errors:overflow-ambig, r=spastorino
Discard overflow obligations in `impl_may_apply`

Hacky fix for #123493. Throws away obligations that are overflowing in `impl_may_apply` when we recompute if an impl applies, since those will lead to fatal overflow if processed during fulfillment.

Something about #114811 (I think it's the predicate reordering) caused us to evaluate predicates differently in error reporting leading to fatal overflow, though I believe the underlying overflow is possible to hit since this code was rewritten to use fulfillment.

Fixes #123493
2024-04-14 23:24:33 +02:00
Guillaume Gomez
f3a68fb718
Rollup merge of #123373 - onur-ozkan:skip-codegen, r=Mark-Simulacrum
skip Codegen{GCC,Cranelift} when using CI rustc

CI rustc uses the default codegen backend, therefore we can't run `CodegenGCC` and `CodegenCranelift` tests when using it.

cc `@bjorn3` (to make sure I am not doing anything wrong)

Fixes #123331
2024-04-14 23:24:33 +02:00
Guillaume Gomez
fa483a4829
Rollup merge of #120900 - marcospb19:std-use-seek-stream-position, r=joshtriplett
std: use `stream_position` where applicable

by replacing `seek(SeekFrom::Current(0))` calls
2024-04-14 23:24:32 +02:00
Jeremy Fitzhardinge
8880b702fe Add documentation for unused-externs(-silent) 2024-04-14 14:20:58 -07:00
Jeremy Fitzhardinge
fdcb8a9fea Stabilize --json unused-externs(-silent)
Implement https://github.com/rust-lang/compiler-team/issues/674
2024-04-14 14:20:55 -07:00
bors
29b120740b Auto merge of #123719 - RalfJung:compiler_builtins, r=Mark-Simulacrum
update compiler_builtins to 0.1.109

This pulls in https://github.com/rust-lang/compiler-builtins/pull/583 so we should make sure that does not come with any perf surprises.

Cc `@Amanieu`
2024-04-14 18:42:50 +00:00
Josh Stone
2970ae5a6b
Fix ENV quotes in aarch64-gnu/Dockerfile
Co-authored-by: Eric Huss <eric@huss.org>
2024-04-14 10:42:59 -07:00
Tobias Bucher
2325b81d04 statx probe: ENOSYS might come from a faulty FUSE driver
Do the availability check regardless of the error returned from `statx`.

CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281
2024-04-14 17:04:41 +02:00
bors
a8a88fe524 Auto merge of #122268 - ChrisDenton:no-libc, r=Mark-Simulacrum
Link MSVC default lib in core

## The Problem

On Windows MSVC, Rust invokes the linker directly. This means only the objects and libraries Rust explicitly passes to the linker are used. In short, this is equivalent to passing `-nodefaultlibs`, `-nostartfiles`, etc for gnu compilers.

To compensate for this [the libc crate links to the necessary libraries](a0f5b4b213/src/windows/mod.rs (L258-L261)). The libc crate is then linked from std, thus when you use std you get the defaults back.or integrate with C/C++.

However, this has a few problems:

- For `no_std`, users are left to manually pass the default lib to the linker
- Whereas `std` has the opposite problem, using [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170) doesn't work as expected because Rust treats them as normal libs. This is a particular problem when you want to use e.g. the debug CRT libraries in their place or integrate with C/C++..

## The solution

This PR fixes this in two ways:

- moves linking the default lib into `core`
- passes the lib to the linker using [`/defaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/defaultlib-specify-default-library?view=msvc-170). This allows users to override it in the normal way (i.e. with [`/nodefaultlib`](https://learn.microsoft.com/en-us/cpp/build/reference/nodefaultlib-ignore-libraries?view=msvc-170)).

This is more or less equivalent to what the MSVC C compiler does. You can see what this looks like in my second commit, which I'll reproduce here for convenience:

```rust
// In library/core
#[cfg(all(windows, target_env = "msvc"))]
#[link(
    name = "/defaultlib:msvcrt",
    modifiers = "+verbatim",
    cfg(not(target_feature = "crt-static"))
)]
#[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))]
extern "C" {}
```

## Alternatives

- Add the above to `unwind` and `std` but not `core`
- The status quo
- Some other kind of compiler magic maybe

This bares some discussion so I've t-libs nominated it.
2024-04-14 13:28:21 +00:00
Tobias Decking
e5cf30cd63
Update v0.rs 2024-04-14 15:01:04 +02:00
Tobias Decking
be7fb2ed55
Update encode.rs 2024-04-14 14:56:41 +02:00
Ralf Jung
ec3ac1dcd6 builtin-derive: tag → discriminant 2024-04-14 11:34:15 +02:00
Matthias Krüger
37df49059d update README and add COMPILETEST_VERBOSE_CRASHES env var which when set print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests 2024-04-14 11:30:29 +02:00
Matthias Krüger
6d9175f98e crashes: fix ice detection which did not trigger if code compiled without error by accident 2024-04-14 11:21:58 +02:00
Matthias Krüger
7d826ae43e tests/crashes: add ICEs from matthiaskrgr/glacier2 2024-04-14 11:21:51 +02:00
Matthias Krüger
98dd566033 add .rs crashes from https://github.com/rust-lang/glacier 2024-04-14 11:18:23 +02:00
Matthias Krüger
a5932b1507 compiletest: switch crash detection logic for run_crash_test around
previously we would explicitly look for exit code 101 and call it a crash,
however in case of stack overflows for example, exit code could differ due to the
process being killed by a signal which is not easy to detect on none-unix.

So now we reject everything that exits with 0 (no error) or 1 (compiler failed to compile code)
and "accept" everyhing else as an internal compiler error.
2024-04-14 11:18:23 +02:00
Matthias Krüger
dd1e35f9c0 run_crash_test(): better error message when we get a none-ice 2024-04-14 11:18:23 +02:00
Matthias Krüger
dde3178d58 compiletest: crashes: turn off backtraces for faster tests 2024-04-14 11:17:12 +02:00
Matthias Krüger
7048ce7e8f tidy: add tidy check agains \.rs files inside tests/crashes that are missing "//@ known-bug: " 2024-04-14 11:16:26 +02:00
Matthias Krüger
e09244fab2 add ignore-mode-crashes to the know list of compiletest directive names 2024-04-14 11:16:26 +02:00
Matthias Krüger
d6e70df1a2 crashes: add another test showing that everything works fine when we need compile-flags to repro an ice and add README 2024-04-14 11:16:15 +02:00
Matthias Krüger
7b05360a1e bootstrap/compiletest: implement "crashes" tests that fail if no ice is reproduced 2024-04-14 11:14:45 +02:00
Matthias Krüger
65ca71815a add initial ice as test 2024-04-14 11:04:27 +02:00
bors
78bc0a5656 Auto merge of #123913 - matthiaskrgr:rollup-w8stnwl, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #123651 (Thread local updates for idiomatic examples)
 - #123699 (run-make-support: tidy up support library)
 - #123779 (OpenBSD fix long socket addresses)
 - #123875 (Doc: replace x with y for hexa-decimal fmt)
 - #123879 (Add missing `unsafe` to some internal `std` functions)
 - #123889 (reduce tidy overheads in run-make checks)
 - #123898 (Generic associated consts: Check regions earlier when comparing impl with trait item def)
 - #123902 (compiletest: Update rustfix to 0.8.1)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-14 09:02:22 +00:00
Mohamed El-Shenawy
5b8864ab80
improve documentation slightly regarding some pointer methods 2024-04-14 09:56:33 +02:00
Chris Denton
87e1dd0dfd
Move msvc libs to core 2024-04-14 07:11:53 +00:00
Chris Denton
b1f1039d8b
Replace libc::c_int with core::ffi::c_int
And remove the libc crate when it isn't needed
2024-04-14 07:11:51 +00:00
Matthias Krüger
ab65c68585
Rollup merge of #123902 - ehuss:update-rustfix2, r=Mark-Simulacrum
compiletest: Update rustfix to 0.8.1

This updates the version of rustfix used in compiletest to be closer to what cargo is using. This is to help ensure `cargo fix` and compiletest are aligned. There are some unpublished changes to `rustfix`, which will update in a future PR when those are published.

Will plan to update ui_test in the near future to avoid the duplicate.
2024-04-14 09:02:00 +02:00