Commit graph

254498 commits

Author SHA1 Message Date
Jules Bertholet 4f76f1069a
Match ergonomics 2024: let & patterns eat &mut 2024-05-10 13:47:34 -04:00
bors 66f877007d Auto merge of #124932 - RalfJung:temporal, r=compiler-errors
codegen: memmove/memset cannot be non-temporal

non-temporal memset is not a thing.
And for memmove, since the LLVM backend doesn't support this, surely we don't need it in the GCC backend.
2024-05-10 13:55:59 +00:00
bors cf774742b6 Auto merge of #124863 - DaniPopes:from-str-radix-panic, r=Amanieu
from_str_radix: outline only the panic function

In the `{integer}::from_str_radix` function, the radix check is labeled as `cold` and `inline(never)`, along with its corresponding panic. It probably was intended to apply these attributes only to the panic function.
2024-05-10 11:48:15 +00:00
bors e93f342101 Auto merge of #124774 - the8472:subnanosecond-benches, r=jhpratt
Display walltime benchmarks with subnanosecond precision

With modern CPUs running at more than one cycle per nanosecond the current precision is insufficient to resolve differences worth several cycles per iteration.

Granted, walltime benchmarks often are noisy but occasionally, especially when no allocations are involved, the difference really is just a few cycles.

example results when benchmarking 1-4 serialized ADD instructions and an empty bench body

```
running 4 tests
test add  ... bench:           0.24 ns/iter (+/- 0.00)
test add2 ... bench:           0.48 ns/iter (+/- 0.01)
test add3 ... bench:           0.72 ns/iter (+/- 0.01)
test add4 ... bench:           0.96 ns/iter (+/- 0.01)
test empty ... bench:           0.24 ns/iter (+/- 0.00)
```
2024-05-10 08:59:08 +00:00
bors f7b1501ce7 Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124551 (Add benchmarks for `impl Debug for str`)
 - #124915 (`rustc_target` cleanups)
 - #124918 (Eliminate some `FIXME(lcnr)` comments)
 - #124927 (opt-dist: use xz2 instead of xz crate)
 - #124936 (analyse visitor: build proof tree in probe)
 - #124943 (always use `GenericArgsRef`)
 - #124955 (Use fewer origins when creating type variables.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-10 06:50:46 +00:00
Matthias Krüger 0ee258009c
Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnr
Use fewer origins when creating type variables.

To reduce lots of repetitive boilerplate code. Details in the individual commit messages.

r? ``@lcnr``
2024-05-10 07:30:22 +02:00
Matthias Krüger 30bd6cb726
Rollup merge of #124943 - lcnr:generic-args-ref, r=compiler-errors
always use `GenericArgsRef`

r? ```@compiler-errors```
2024-05-10 07:30:21 +02:00
Matthias Krüger 43ddd1d963
Rollup merge of #124936 - lcnr:cool-beans, r=compiler-errors
analyse visitor: build proof tree in probe

see inline comments

fixes #124791
fixes #124702

r? ```@compiler-errors```
2024-05-10 07:30:21 +02:00
Matthias Krüger 4313281914
Rollup merge of #124927 - klensy:xz3, r=Kobzol
opt-dist: use xz2 instead of xz crate

xz crate consist of simple reexport of xz2 crate. Why? Idk.

Totally not a backdoor.
2024-05-10 07:30:20 +02:00
Matthias Krüger 7e4f6082ce
Rollup merge of #124918 - nnethercote:FIXME-lcnr, r=lcnr
Eliminate some `FIXME(lcnr)` comments

In some cases this involved changing code. In some cases the comment was able to removed or replaced.

r? ``@lcnr``
2024-05-10 07:30:20 +02:00
Matthias Krüger 0b4715e7f8
Rollup merge of #124915 - nnethercote:rustc_target-cleanups, r=bjorn3
`rustc_target` cleanups

Minor improvement I found while looking at this code.

r? ```@lqd```
2024-05-10 07:30:19 +02:00
Matthias Krüger f3f9f0c5e6
Rollup merge of #124551 - Swatinem:debug-str-bench, r=cuviper
Add benchmarks for `impl Debug for str`

In order to inform future perf improvements and prevent regressions, lets add some benchmarks that stress `impl Debug for str`.

---

As I am currently working on improving the perf in https://github.com/rust-lang/rust/pull/121150, its nice to have these benchmarks.

Writing them, I also saw that escapes are written out one char at a time, even though other parts of the code are already optimizing that via `as_str`, which I intend to do as well as a followup improvement.

r? ``@cuviper``
☝🏻 as you were also assigned to https://github.com/rust-lang/rust/pull/121150, CC ``@the8472`` if you want to steal the review :-)
2024-05-10 07:30:19 +02:00
bors 98dabb622a Auto merge of #124953 - compiler-errors:own-params, r=lcnr
Rename `Generics::params` to `Generics::own_params`

I hope this makes it slightly more obvious that `generics.own_params` is insufficient when considering nested items. I didn't actually audit any of the usages, for the record.

r? lcnr
2024-05-10 04:43:57 +00:00
Michael Goulet 1c19b6ad60 Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00
bors a6e87c546d Auto merge of #124850 - dpaoliello:clang2022, r=Kobzol
Upgrade pre-built Clang used in MSVC and MacOS builds, move MSVC builds to Server 2022

Fixes #92948

Example working MacOS and Windows builds: <https://github.com/rust-lang/rust/actions/runs/8989360201>

There is a [bug in Clang 18](https://github.com/llvm/llvm-project/pull/81849) that causes issues when building for Arm64 in later parts of the build (specifically `libgit2`). As a workaround, we will still use the pre-built Clang to build LLVM but will use MSVC for the rest of the Arm64 build.
2024-05-10 00:04:22 +00:00
Nicholas Nethercote df6f7133ee De-tuple two vtable_trait_first_method_offset args.
Thus eliminating a `FIXME` comment.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote 24445d3b6a Remove out-of-date comment.
The use of `Binder` was removed in the recent #123900, but the comment
wasn't removed at the same time.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote d13612bce7 Remove TyCtxt::try_normalize_erasing_late_bound_regions.
It's unused.
2024-05-10 09:55:09 +10:00
Nicholas Nethercote 5b5dd1b3de Fix out-of-date comment.
The type name has changed.
2024-05-10 09:55:07 +10:00
Nicholas Nethercote fe843feaab Use fewer origins when creating type variables.
`InferCtxt::next_{ty,const}_var*` all take an origin, but the
`param_def_id` is almost always `None`. This commit changes them to just
take a `Span` and build the origin within the method, and adds new
methods for the rare cases where `param_def_id` might not be `None`.
This avoids a lot of tedious origin building.

Specifically:
- next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of
  `TypeVariableOrigin`
- next_ty_var_with_origin: added

- next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin
- next_const_var_with_origin: added

- next_region_var, next_region_var_in_universe: these are unchanged,
  still take RegionVariableOrigin

The API inconsistency (ty/const vs region) seems worth it for the
large conciseness improvements.
2024-05-10 09:47:46 +10:00
Nicholas Nethercote 11f2ca340c Inline and remove unused methods.
`InferCtxt::next_{ty,const,int,float}_var_id` each have a single call
site, in `InferCtt::next_{ty,const,int,float}_var` respectively.

The only remaining method that creates a var_id is
`InferCtxt::next_ty_var_id_in_universe`, which has one use outside the
crate.
2024-05-10 09:47:22 +10:00
bors 8f9080db42 Auto merge of #124847 - Oneirical:master, r=jieyouxu
Document tests in the `run-make` directory (A to C)

Part of the #121876 project.

This PR adds comments to some `run-make` tests which lack one, explaining _what_ is being tested. If possible, a link to the relevant PR or Issue responsible for the test is also provided.

This will help the porting efforts to `rmake.rs`, and will also allow maintainers to focus efforts on tests which are more pertinent to port. For example, [this test](https://github.com/rust-lang/rust/blob/master/tests/run-make/cat-and-grep-sanity-check/Makefile) will become useless after all tests containing `CGREP` are successfully ported.

In order to simplify review and at the suggestion of Kobzol on the rust-lang #gsoc Zulip, only the first 23 comments are part of this PR. If it is merged, future PRs will ensue commenting the rest of the tests.

Could be an UI test:

- `dep-info-doesnt-run-much`
2024-05-09 21:19:38 +00:00
lcnr 8f9062530b always use GenericArgsRef 2024-05-09 19:52:02 +00:00
Daniel Paoliello 5212e07a4e Upgrade the version of Clang used in the build, move MSVC builds to Server 2022 2024-05-09 12:18:09 -07:00
bors e6e262f125 Auto merge of #124934 - matthiaskrgr:rollup-eqor0ot, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124893 (Make a minimal amount of region APIs public)
 - #124919 (Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.)
 - #124923 (interpret/miri: better errors on failing offset_from)
 - #124924 (chore: remove repetitive words)
 - #124926 (Make `#![feature]` suggestion MaybeIncorrect)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-09 19:12:13 +00:00
lcnr feff7520df update crashes 2024-05-09 17:51:05 +00:00
lcnr 83e6da0be5 analyse visitor: build proof tree in probe 2024-05-09 17:29:53 +00:00
Julien bdab8b1c0c
add FIXME 2024-05-09 13:29:46 -04:00
Matthias Krüger 779fe95298
Rollup merge of #124926 - Alexendoo:feature-maybe-incorrect, r=est31
Make `#![feature]` suggestion MaybeIncorrect

Fixes https://github.com/rust-lang/rust-clippy/issues/12784

The `unstable_name_collisions` lint uses `disabled_nightly_features` to mention the feature name, but accepting the suggestion would result in an ambiguity error

There are other calls where accepting the feature gate would fix code when ran with `cargo fix --broken-code`, though it's not always desirable to add a feature gate even if the user is currently on nightly so MaybeIncorrect seems appropriate
2024-05-09 19:09:31 +02:00
Matthias Krüger a40fa8f443
Rollup merge of #124924 - goofylfg:master, r=est31
chore: remove repetitive words
2024-05-09 19:09:31 +02:00
Matthias Krüger 024881a36b
Rollup merge of #124923 - RalfJung:offset-from-errors, r=compiler-errors
interpret/miri: better errors on failing offset_from

Fixes https://github.com/rust-lang/miri/issues/3104
2024-05-09 19:09:30 +02:00
Matthias Krüger 0a917f89f3
Rollup merge of #124919 - nnethercote:Recovered-Yes-ErrorGuaranteed, r=compiler-errors
Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.

The starting point for this was identical comments on two different fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`:
```
    // FIXME: investigate making this a `Option<ErrorGuaranteed>`
    recovered: bool
```
I tried that, and then found that I needed to add an `ErrorGuaranteed` to `Recovered::Yes`. Then I ended up using `Recovered` instead of `Option<ErrorGuaranteed>` for these two places and elsewhere, which required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`.

This makes things more consistent, because `Recovered` is used in more places, and there are fewer uses of `bool` and
`Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible to set `recovered` to `Recovered::Yes` without having emitted an error.

r? `@oli-obk`
2024-05-09 19:09:30 +02:00
Matthias Krüger ebeedf05cb
Rollup merge of #124893 - xldenis:public-region-apis, r=lcnr
Make a minimal amount of region APIs public

Tools like Creusot, Prusti or Gillian-Rust need to access information about the loans and regions that exist in MIR programs. While `rustc` provides information about loans, there is currently no public way to reason about the regions present in a MIR program. In particular, we to know which regions are actually equal to each other and which ones outlive each other. Currently, `rustc` provides access to `RegionInferenceContext` but the public api hides that last portion of the information.

This PR proposes to make a few apis public, allowing verifiers to reason about the lifetimes present in Rust programs:
- [eval_equal](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.eval_equal)
- [eval_outlives](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.eval_outlives)
- (Optional) [constraint_sccs](https://doc.rust-lang.org/beta/nightly-rustc/rustc_borrowck/region_infer/struct.RegionInferenceContext.html#method.constraint_sccs)

The first two functions would allow us to compare regions and from this we can construct the set of `RegionVid` which are actually equal to each other, and then recover the inclusions between those regions, while the second allows for more direct, but _low level_ access to that information.
2024-05-09 19:09:29 +02:00
bors 238c1e798d Auto merge of #124773 - Marcondiro:master, r=joboet
fix #124714 str.to_lowercase sigma handling

Hello,
This PR fixes issue #124714 about 'Σ' handling in `str.to_lowercase()`.
The fix consists in considering the full original string during 'Σ' handling instead of considering just the substring left after the optimized ascii handling.
A new test is added to avoid regression.
Thanks!
2024-05-09 16:59:56 +00:00
Ralf Jung 95582e6fcb codegen: memmove/memset cannot be non-temporal 2024-05-09 18:59:00 +02:00
klensy 39159a3629 opt-dist: use xz2 instead of xz crate
xz crate consist of simple reexport of xz2 crate. Why? Idk.
2024-05-09 16:43:14 +03:00
bors 8c7c151a7a Auto merge of #124706 - Zalathar:revision-checker, r=jieyouxu
Tidy check for test revisions that are mentioned but not declared

If a `[revision]` name appears in a test header directive or error annotation, but isn't declared in the `//@ revisions:` header, that is almost always a mistake.

In cases where a revision needs to be temporarily disabled, adding it to an `//@ unused-revision-names:` header will suppress these checks for that name.

Adding the wildcard name `*` to the unused list will suppress these checks for the entire file.

(None of the tests actually use `*`; it's just there because it was easy to add and could be handy as an escape hatch when dealing with other problems.)

---

Most of the existing problems discovered by this check were fairly straightforward to fix (or ignore); the trickiest cases are in `borrowck` tests.
2024-05-09 13:06:40 +00:00
goofylfg 5120010b02 chore: remove repetitive words 2024-05-09 12:41:48 +00:00
Alex Macleod 3c52553912 Make #![feature] suggestion MaybeIncorrect 2024-05-09 13:18:09 +01:00
Ralf Jung 41d36a0951 interpret/miri: better errors on failing offset_from 2024-05-09 13:09:47 +02:00
bors 6f7e00a3e6 Auto merge of #124743 - Kobzol:arbitrary-try-build, r=pietroalbini
CI: enable arbitrary try builds, take two

Fixed version of https://github.com/rust-lang/rust/pull/124631, which hopefully won't completely break our CI this time 🤦‍♂️ Sorry once again. Only the last commit is new.

r? `@pietroalbini`
2024-05-09 10:39:50 +00:00
Nicholas Nethercote d6c63bdb21 Fix up DescriptionCtx::new.
The comment mentions that `ReBound` and `ReVar` aren't expected here.
Experimentation with the full test suite indicates this is true, and
that `ReErased` also doesn't occur. So the commit introduces `bug!` for
those cases. (If any of them show up later on, at least we'll have a
test case.)

The commit also remove the first sentence in the comment.
`RePlaceholder` is now handled in the match arm above this comment and
nothing is printed for it, so that sentence is just wrong. Furthermore,
issue #13998 was closed some time ago.
2024-05-09 20:15:44 +10:00
Nicholas Nethercote 609b9a67c9 Correct a comment.
I tried simplifying `RegionCtxt`, which led me to finding that the
fields are printed in `sccs_info`.
2024-05-09 20:15:42 +10:00
Nicholas Nethercote fd91925bce Add ErrorGuaranteed to Recovered::Yes and use it more.
The starting point for this was identical comments on two different
fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`:
```
    // FIXME: investigate making this a `Option<ErrorGuaranteed>`
    recovered: bool
```
I tried that, and then found that I needed to add an `ErrorGuaranteed`
to `Recovered::Yes`. Then I ended up using `Recovered` instead of
`Option<ErrorGuaranteed>` for these two places and elsewhere, which
required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`.

This makes things more consistent, because `Recovered` is used in more
places, and there are fewer uses of `bool` and
`Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible
to set `recovered` to `Recovered::Yes` without having emitted an error.
2024-05-09 20:12:07 +10:00
bors cb93c24bf3 Auto merge of #124157 - wutchzone:partial_eq, r=estebank
Do not add leading asterisk in the `PartialEq`

I think we should address this issue, however I am not exactly sure, if this is the right way to do it. It is related to the #123056.

Imagine the simplified code:

```rust
trait MyTrait {}

impl PartialEq for dyn MyTrait {
    fn eq(&self, _other: &Self) -> bool {
        true
    }
}

#[derive(PartialEq)]
enum Bar {
    Foo(Box<dyn MyTrait>),
}
```

On the nightly compiler, the `derive` produces invalid code with the weird error message:
```
error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
  --> src/main.rs:11:9
   |
9  | #[derive(PartialEq)]
   |          --------- in this derive macro expansion
10 | enum Things {
11 |     Foo(Box<dyn MyTrait>),
   |         ^^^^^^^^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn MyTrait>`, which does not implement the `Copy` trait
   |
   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
```

It may be related to the perfect derive problem, although requiring the _type_ to be `Copy` seems unfortunate because it is not necessary. Besides, we are adding the extra dereference only for the diagnostics?
2024-05-09 08:34:14 +00:00
bors 5f8c17dcc0 Auto merge of #124916 - matthiaskrgr:rollup-vmpmt4u, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #124777 (Fix Error Messages for `break` Inside Coroutines)
 - #124837 (Migrate `run-make/rustdoc-map-file` to rmake)
 - #124875 (Fix more ICEs in `diagnostic::on_unimplemented`)
 - #124908 (Handle field projections like slice indexing in invalid_reference_casting)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-09 06:14:00 +00:00
Zalathar 14d56e8338 Fix test problems discovered by the revision check
Most of these changes either add revision names that were apparently missing,
or explicitly mark a revision name as currently unused.
2024-05-09 14:47:09 +10:00
Zalathar be590d3887 Tidy check for test revisions that are mentioned but not declared
If a `[revision]` name appears in a test header directive or error annotation,
but isn't declared in the `//@ revisions:` header, that is almost always a
mistake.

In cases where a revision needs to be temporarily disabled, adding it to an
`//@ unused-revision-names:` header will suppress these checks for that name.

Adding the wildcard name `*` to the unused list will suppress these checks for
the entire file.
2024-05-09 14:47:09 +10:00
Zalathar 1fbabc622f Include the line number in tidy's iter_header 2024-05-09 14:38:25 +10:00
Matthias Krüger 48b1e1a280
Rollup merge of #124908 - saethlin:ref-casting_bigger_place_projection, r=fee1-dead
Handle field projections like slice indexing in invalid_reference_casting

r? `@Urgau`

I saw the implementation in https://github.com/rust-lang/rust/pull/124761, and I was wondering if we also need to handle field access. We do. Without this PR, we get this errant diagnostic:
```
error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
  --> /home/ben/rust/tests/ui/lint/reference_casting.rs:262:18
   |
LL |         let r = &mut v.0;
   |                      --- backing allocation comes from here
LL |         let ptr = r as *mut i32 as *mut Vec3<i32>;
   |                   ------------------------------- casting happend here
LL |         unsafe { *ptr = Vec3(0, 0, 0) }
   |                  ^^^^^^^^^^^^^^^^^^^^
   |
   = note: casting from `i32` (4 bytes) to `Vec3<i32>` (12 bytes)
```
2024-05-09 06:04:40 +02:00