Commit Graph

255434 Commits

Author SHA1 Message Date
Xiretza
eee14e9adf Add note_once/help_once to diagnostic derives 2024-05-21 20:11:42 +00:00
Xiretza
56bca95875 Implement IntoDiagArg for RustcVersion 2024-05-21 20:11:42 +00:00
Xiretza
3b979aebfe Implement IntoDiagArg for hir Namespace 2024-05-21 20:11:42 +00:00
bors
506512391b Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvalle
Relax restrictions on multiple sanitizers

Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms.

I used this python script to generate the mutually-exclusive sanitizer combinations:

```python
#!/usr/bin/python3

import subprocess

flags = [
    ["-fsanitize=address"],
    ["-fsanitize=leak"],
    ["-fsanitize=memory"],
    ["-fsanitize=thread"],
    ["-fsanitize=hwaddress"],
    ["-fsanitize=cfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=memtag", "--target=aarch64-linux-android", "-march=armv8a+memtag"],
    ["-fsanitize=shadow-call-stack"],
    ["-fsanitize=kcfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=kernel-address"],
    ["-fsanitize=safe-stack"],
    ["-fsanitize=dataflow"],
]

for i in range(len(flags)):
    for j in range(i):
        command = ["clang++"] + flags[i] + flags[j] + ["-o", "main.o", "-c", "main.cpp"]
        completed = subprocess.run(command, stderr=subprocess.DEVNULL)
        if completed.returncode != 0:
            first = flags[i][0][11:].replace('-', '').upper()
            second = flags[j][0][11:].replace('-', '').upper()
            print(f"(SanitizerSet::{first}, SanitizerSet::{second}),")
```
2024-05-21 15:35:29 +00:00
bors
6715446db6 Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124570 (Miscellaneous cleanups)
 - #124772 (Refactor documentation for Apple targets)
 - #125011 (Add opt-for-size core lib feature flag)
 - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`)
 - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS)
 - #125266 (compiler: add simd_ctpop intrinsic)
 - #125348 (Small fixes to `std::path::absolute` docs)

Failed merges:

 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 12:50:09 +00:00
Matthias Krüger
e6e05d51ec
Rollup merge of #125348 - tbu-:pr_doc_path_absolute, r=jhpratt
Small fixes to `std::path::absolute` docs
2024-05-21 12:47:07 +02:00
Matthias Krüger
fd975f75fa
Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic
compiler: add simd_ctpop intrinsic

Fairly straightforward addition.

cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-21 12:47:06 +02:00
Matthias Krüger
a8ee8d5086
Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubilee
Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS

Use `_NSGetEnviron`, `_NSGetArgc` and `_NSGetArgv` on iOS/tvOS/watchOS/visionOS, see each commit and the code comments for details. This allows us to unify more code with the macOS implementation, as well as avoiding linking to the `Foundation` framework (which is good for startup performance).

The biggest problem with doing this would be if it lead to App Store rejections. After doing a bunch of research on this, while [it did happen once in 2009](https://blog.unity.com/engine-platform/unity-app-store-submissions-problem-solved), I find it fairly unlikely to happen nowadays, especially considering that Apple has later _added_ `crt_externs.h` to the iOS/tvOS/watchOS/visionOS SDKs, strongly signifying the functions therein is indeed supported on those platforms (even though they lack an availability attribute).

That we've been overly cautious here has also been noted by `@thomcc` in https://github.com/rust-lang/rust/pull/117910#issuecomment-1903372350.

r? `@workingjubilee`

`@rustbot` label O-apple
2024-05-21 12:47:05 +02:00
Matthias Krüger
7ef533bce6
Rollup merge of #125218 - Oneirical:easy-test-the-third, r=jieyouxu
Migrate `run-make/no-intermediate-extras` to new `rmake.rs`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-21 12:47:05 +02:00
Matthias Krüger
4abf179b14
Rollup merge of #125011 - diondokter:opt-for-size, r=Amanieu,kobzol
Add opt-for-size core lib feature flag

Adds a feature flag to the core library that enables the possibility to have smaller implementations for certain algorithms.

So far, the core lib has traded performance for binary size. This is likely what most people want since they have big simd-capable machines. However, people on small machines, like embedded devices, don't enjoy the potential speedup of the bigger algorithms, but do have to pay for them. These microcontrollers often only have 16-1024kB of flash memory.

This PR is the result of some talks with project members like `@Amanieu` at RustNL.
There are some open questions of how this is eventually stabilized, but it's a similar question as with the existing `panic_immediate_abort` feature.

Speaking as someone from the embedded side, we'd rather have this unstable for a while as opposed to not having it at all. In the meantime we can try to use it and also add additional PRs to the core lib that uses the feature flag in areas where we find benefit.

Open questions from my side:
- Is this a good feature name?
  - `panic_immediate_abort` is fairly verbose, so I went with something equally verbose
  - It's easy to refactor later
- I've added the feature to `std` and `alloc` as well as they might benefit too. Do we agree?
  - I expect these to get less usage out of the flag since most size-constraint projects don't use these libraries often.
2024-05-21 12:47:04 +02:00
Matthias Krüger
4a4883bfb7
Rollup merge of #124772 - madsmtm:apple-platform-support-docs, r=oli-obk
Refactor documentation for Apple targets

Refactor the documentation for Apple targets in `rustc`'s platform support page to make it clear what the supported OS version is and which environment variables are being read (`*_DEPLOYMENT_TARGET` and `SDKROOT`). This fixes https://github.com/rust-lang/rust/issues/124215.

Note that I've expanded the `aarch64-apple-ios-sim` maintainers `@badboy` and `@deg4uss3r` to include being maintainer of all `*-apple-ios-*` targets. If you do not wish to be so, please state that, then I'll explicitly note that in the docs.

Additionally, I've added myself as co-maintainer of most of these targets.

r? `@thomcc`

I think the documentation you've previously written on tvOS is great, have mostly modified it to have a more consistent formatting with the rest of the Apple target.

I recognize that there's quite a few changes here, feel free to ask about any of them!

---

CC `@simlay` `@Nilstrieb`

`@rustbot` label O-apple
2024-05-21 12:47:04 +02:00
Matthias Krüger
df59800b08
Rollup merge of #124570 - nnethercote:misc-cleanups, r=michaelwoerister
Miscellaneous cleanups

A mix of small cleanups made while looking at various things.

r? `@wesleywiser`
2024-05-21 12:47:03 +02:00
bors
e8fbd99128 Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: https://github.com/rust-lang/rust/issues/123759

Crater run was done here: https://github.com/rust-lang/rust/pull/116607#issuecomment-1770293013
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.
2024-05-21 10:13:53 +00:00
bors
e875391458 Auto merge of #123812 - compiler-errors:additional-fixes, r=fmease
Follow-up fixes to `report_return_mismatched_types`

Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
2024-05-21 08:06:41 +00:00
bors
1d0e4afd4c Auto merge of #125298 - tesuji:arrcmp, r=nikic
Add codegen test for array comparision opt

Fixed since rust 1.55
closes #62531
2024-05-21 05:55:39 +00:00
Nicholas Nethercote
3ac816a1ca Sort rustc_middle attributes.
As is already done in several other crates, such as `rustc_errors`.
2024-05-21 14:56:57 +10:00
Nicholas Nethercote
ac847b2583 Remove unused features from rustc_middle. 2024-05-21 14:56:57 +10:00
Nicholas Nethercote
c1d5b6a480 Remove erroneous comment.
The comment was originally in `src/librustc_mir/lib.rs`, but now that
it's in `compiler/rustc_const_eval/src/lib.rs` it's no longer
appropriate.
2024-05-21 14:56:57 +10:00
Nicholas Nethercote
ce222328d7 Minor pub and whitespace cleanups. 2024-05-21 14:56:57 +10:00
Nicholas Nethercote
d8ea468994 Reorder some use items. 2024-05-21 14:55:37 +10:00
Nicholas Nethercote
eb10eb2b45 Reorder top-level attributes.
And remove an unnecessary `feature(try_blocks)`.
2024-05-21 14:55:37 +10:00
bors
9cb6bb8599 Auto merge of #125284 - compiler-errors:uplift-misc, r=lcnr
Uplift `RegionVid`, `TermKind` to `rustc_type_ir`, and `EagerResolver` to `rustc_next_trait_solver`

- Uplift `RegionVid`. This was complicated due to the fact that we implement `polonius_engine::Atom` for `RegionVid` -- but I just separated that into `PoloniusRegionVid`, and added `From`/`Into` impls so it can be defined in `rustc_borrowck` separately. Coherence 😵
- Change `InferCtxtLike` to expose `opportunistically_resolve_{ty,ct,lt,int,float}_var` so that we can uplift `EagerResolver` for use in the canonicalization methods.
- Uplift `TermKind` much like `GenericArgKind`

All of this is miscellaneous dependencies for making more `EvalCtxt` methods generic.
2024-05-21 02:51:38 +00:00
Oneirical
95c47d3396 simplify 2024-05-20 21:30:48 -04:00
bors
8e7517d99a Auto merge of #125349 - matthiaskrgr:rollup-p2mbdxi, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #124050 (Remove libc from MSVC targets)
 - #124283 (Note for E0599 if shadowed bindings has the method.)
 - #125123 (Fix `read_exact` and `read_buf_exact` for `&[u8]` and `io:Cursor`)
 - #125158 (hir pretty: fix block indent)
 - #125308 (track cycle participants per root)
 - #125332 (Update books)
 - #125333 (switch to the default implementation of `write_vectored`)
 - #125346 (Remove some `Path::to_str` from `rustc_codegen_llvm`)

Failed merges:

 - #125310 (Move ~100 tests from tests/ui to subdirs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 00:46:30 +00:00
Michael Goulet
a2a6fe7e51 Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in report_return_mismatched_types 2024-05-20 20:16:29 -04:00
Lzu Tao
e7d6da3676 Add codegen test for array comparision opt 2024-05-21 00:09:25 +00:00
Michael Goulet
b826eb219c Rename confusing function name 2024-05-20 19:56:48 -04:00
Michael Goulet
d2dabeee76 Remove redundant blk_id parameter 2024-05-20 19:56:48 -04:00
Michael Goulet
5915850071 No need to pass parent of block for BlockTailExpression 2024-05-20 19:56:48 -04:00
Michael Goulet
ffdf277618 Consolidate two arms doing the same thing 2024-05-20 19:56:48 -04:00
Michael Goulet
addd931fdb Remove get_parent_fn_decl; it's redundant 2024-05-20 19:56:48 -04:00
Michael Goulet
917bb8396c Fix miri too 2024-05-20 19:21:38 -04:00
Michael Goulet
bd0d306c14 Remove a clippy test that doesn't apply anymore 2024-05-20 19:21:38 -04:00
Michael Goulet
bc6b70f1d1 Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
Michael Goulet
a502e7ac1d Implement BOXED_SLICE_INTO_ITER 2024-05-20 19:21:30 -04:00
Michael Goulet
1a81092531 Add the impls for Box<[T]>: IntoIterator
Co-authored-by: ltdk <usr@ltdk.xyz>
2024-05-20 19:21:30 -04:00
Michael Goulet
c86a4aa5ca Backticks 2024-05-20 19:16:36 -04:00
Matthias Krüger
63fa01eb09
Rollup merge of #125346 - tbu-:pr_rm_path_to_str, r=wesleywiser
Remove some `Path::to_str` from `rustc_codegen_llvm`

Unnecessary panic paths when there's a better option.
2024-05-21 00:47:04 +02:00
Matthias Krüger
73bb47eecd
Rollup merge of #125333 - hermit-os:fuse, r=workingjubilee
switch to the default implementation of `write_vectored`

HermitOS doesn't support write_vectored and switch to the default implementation of `write_vectored`.
2024-05-21 00:47:03 +02:00
Matthias Krüger
75728fe8e0
Rollup merge of #125332 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

8 commits in bebcf527e67755a989a1739b7cfaa8f0e6b30040..5e9051f71638aa941cd5dda465e25c61cde9594f
2024-05-16 14:58:56 UTC to 2024-05-07 23:58:22 UTC

- Convert ch01-03-hello-cargo.md Listing 1-2 using `<Listing>` (rust-lang/book#3924)
- infra: fix rendering bug in mdbook-trpl-note (rust-lang/book#3925)
- infra: support `Listing`s without `file-name` (rust-lang/book#3920)
- Add a `<Listing>` preprocessor (rust-lang/book#3918)
- Update explanation according to code listing (rust-lang/book#3916)
- infra: run package tests (rust-lang/book#3915)
- Fix workspace behavior by excluding `listings` (rust-lang/book#3914)
- Backport changes to chapter 8 (rust-lang/book#3913)

## rust-embedded/book

1 commits in 17842ebb050f62e40a4618edeb8e8ee86e758707..dd962bb82865a5284f2404e5234f1e3222b9c022
2024-05-17 23:43:59 UTC to 2024-05-17 23:43:59 UTC

- 'llvm-tools-preview' component is now named 'llvm-tools' (rust-embedded/book#372)

## rust-lang/reference

2 commits in 51817951d0d213a0011f82b62aae02c3b3f2472e..e356977fceaa8591c762312d8d446769166d4b3e
2024-05-10 12:49:15 UTC to 2024-05-07 13:32:57 UTC

- Document inline const/const block expression (rust-lang/reference#1295)
- patterns: include yet unstable exclusive range patterns (rust-lang/reference#1484)

## rust-lang/rust-by-example

7 commits in 229ad13b64d919b12e548d560f06d88963b25cd3..20482893d1a502df72f76762c97aed88854cdf81
2024-05-20 14:36:21 UTC to 2024-05-14 16:17:03 UTC

- Clarify interchangability for From and Into (rust-lang/rust-by-example#1851)
- Update ja.po based on the latest master (rust-lang/rust-by-example#1850)
- Add explicit section link (rust-lang/rust-by-example#1847)
- Adjust translation build on CI (rust-lang/rust-by-example#1849)
- Update mdbook version in CI (rust-lang/rust-by-example#1848)
- Fix some broken links in ja.po (rust-lang/rust-by-example#1844)
- Fix an external link to absolute (rust-lang/rust-by-example#1842)

## rust-lang/rustc-dev-guide

8 commits in 2d1947ff34d50ca46dfe242ad75531a4c429bb52..b6d4a4940bab85cc91eec70cc2e3096dd48da62d
2024-05-17 17:04:58 UTC to 2024-05-09 13:22:03 UTC

- Add a high level explanation of early/late bound params (rust-lang/rustc-dev-guide#1982)
- Fix broken link to "Lowering" (rust-lang/rustc-dev-guide#1981)
- Broken link fix (rust-lang/rustc-dev-guide#1980)
- Add note about how to pick up abandoned PRs (rust-lang/rustc-dev-guide#1977)
- Toc here is overkill (rust-lang/rustc-dev-guide#1976)
- Link to lint `L-*` labels (rust-lang/rustc-dev-guide#1975)
- Update the rustc_interface examples for current rustc (rust-lang/rustc-dev-guide#1974)
- Edit `Parameter Environments`'s url as it has been edited in #1953 (rust-lang/rustc-dev-guide#1973)
2024-05-21 00:47:03 +02:00
Matthias Krüger
e97103ff6c
Rollup merge of #125308 - lcnr:search-graph-5, r=compiler-errors
track cycle participants per root

The search graph may have multiple roots, e.g. in
```
A :- B
B :- A, C
C :- D
D :- C
```
we first encounter the `A -> B -> A` cycle which causes `A` to be a root. We then later encounter the `C -> D -> C` cycle as a nested goal of `B`. This cycle is completely separate and `C` will get moved to the global cache. This previously caused us to use `[B, D]` as the `cycle_participants` for `C` and `[]` for `A`.

split off from #125167 as I would like to merge this change separately and will rebase that PR on top of this one. There is no test for this issue and I don't quite know how to write one. It is probably worth it to generalize the search graph to enable us to write unit tests for it.

r? `@compiler-errors`
2024-05-21 00:47:02 +02:00
Matthias Krüger
4b26045b92
Rollup merge of #125158 - Nilstrieb:block-indent, r=compiler-errors
hir pretty: fix block indent

before:
```rust
fn main() {
        {
                {
                        ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"]));
                    };
            }
    }
```
after:
```rust
fn main() {
    {
        {
            ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"]));
        };
    }
}
```

AST pretty does the same.
2024-05-21 00:47:02 +02:00
Matthias Krüger
62da957c92
Rollup merge of #125123 - a1phyr:fix-read_exact, r=workingjubilee
Fix `read_exact` and `read_buf_exact` for `&[u8]` and `io:Cursor`

- Drain after `read_exact` and `read_buf_exact`
- Append to cursor in `read_buf_exact`
2024-05-21 00:47:01 +02:00
Matthias Krüger
e275d2dad6
Rollup merge of #124283 - surechen:fix_123558, r=estebank
Note for E0599 if shadowed bindings has the method.

implement #123558

Use a visitor to find earlier shadowed bingings which has the method.

r? ``@estebank``
2024-05-21 00:47:01 +02:00
Matthias Krüger
8903de31ca
Rollup merge of #124050 - saethlin:less-sysroot-libc, r=ChrisDenton
Remove libc from MSVC targets

``@ChrisDenton`` started working on a project to remove libc from Windows MSVC targets. I'm completing that work here.

The primary change is to cfg out the dependency in `library/`. And then there's a lot of test patching. Happy to separate this more if people want.
2024-05-21 00:47:00 +02:00
bors
60faa271d9 Auto merge of #125166 - lovesegfault:embed-rustc-perf, r=Mark-Simulacrum
refactor: add rustc-perf submodule to src/tools

Currently, it's very challenging to perform a sandboxed `opt-dist`
bootstrap because the tool requires `rustc-perf` to be present, but
there is no proper management/tracking of it. Instead, a specific commit
is hardcoded where it is needed, and a non-checksummed zip is fetched
ad-hoc. This happens in two places:

`src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile`:

```dockerfile
ENV PERF_COMMIT 4f313add609f43e928e98132358e8426ed3969ae
RUN curl -LS -o perf.zip https://ci-mirrors.rust-lang.org/rustc/rustc-perf-$PERF_COMMIT.zip && \
    unzip perf.zip && \
    mv rustc-perf-$PERF_COMMIT rustc-perf && \
    rm perf.zip
```

`src/tools/opt-dist/src/main.rs`

```rust
// FIXME: add some mechanism for synchronization of this commit SHA with
// Linux (which builds rustc-perf in a Dockerfile)
// rustc-perf version from 2023-10-22
const PERF_COMMIT: &str = "4f313add609f43e928e98132358e8426ed3969ae";

let url = format!("https://ci-mirrors.rust-lang.org/rustc/rustc-perf-{PERF_COMMIT}.zip");
let client = reqwest::blocking::Client::builder()
    .timeout(Duration::from_secs(60 * 2))
    .connect_timeout(Duration::from_secs(60 * 2))
    .build()?;
let response = retry_action(
    || Ok(client.get(&url).send()?.error_for_status()?.bytes()?.to_vec()),
    "Download rustc-perf archive",
    5,
)?;
```

This causes a few issues:

1. Maintainers need to be careful to bump PERF_COMMIT in both places
   every time
2. In order to run `opt-dist` in a sandbox, you need to provide your own
   `rustc-perf` (https://github.com/rust-lang/rust/pull/125125), but to
   figure out which commit to provide you need to grep the Dockerfile
3. Even if you manage to provide the correct `rustc-perf`, its
   dependencies are not included in the `vendor/` dir created during
   `dist`, so it will fail to build from the published source tarballs
4. It is hard to provide any level of automation around updating the
   `rustc-perf` in use, leading to staleness

Fundamentally, this means `rustc-src` tarballs no longer contain
everything you need to bootstrap Rust, and packagers hoping to leverage
`opt-dist` need to go out of their way to keep track of this "hidden"
dependency on `rustc-perf`.

This change adds rustc-perf as a git submodule, pinned to the current
`PERF_COMMIT` 4f313add609f43e928e98132358e8426ed3969ae. Subsequent
commits ensure the submodule is initialized when necessary, and make use
of it in `opt-dist`.
2024-05-20 22:36:55 +00:00
Tobias Bucher
f6cf103da2 Small fixes to std::path::absolute docs 2024-05-21 00:36:52 +02:00
Tobias Bucher
fa1b7f2d78 Remove some Path::to_str from rustc_codegen_llvm
Unnecessary panic paths when there's a better option.
2024-05-20 23:17:11 +02:00
lcnr
f99c9ffd88 track cycle participants per entry 2024-05-20 20:57:14 +00:00
lcnr
ee0f20bb97 move global cache lookup into fn 2024-05-20 20:40:02 +00:00