Commit Graph

228093 Commits

Author SHA1 Message Date
Weihang Lo
80423fd6e7
Update cargo 2023-07-01 11:08:31 +01:00
bors
e5bb341f0e Auto merge of #111992 - ferrocene:pa-panic-abort-tests-bench, r=m-ou-se
Test benchmarks with `-Z panic-abort-tests`

During test execution, when a `#[bench]` benchmark is encountered it's executed once to check whether it works. Unfortunately that was not compatible with `-Z panic-abort-tests`: the feature works by spawning a subprocess for each test, which prevents the use of dynamic tests as we cannot pass closures to child processes, and before this PR the conversion from benchmark to test was done by turning benchmarks into dynamic tests whose closures execute the benchmark once.

The approach this PR took was to add two new kinds of `TestFn`s: `StaticBenchAsTestFn` and `DynBenchAsTestFn` (⚠️ **this is a breaking change** ⚠️). With that change, a `StaticBenchFn` can be converted into a `StaticBenchAsTestFn` without creating dynamic tests, and making it possible to test `#[bench]` functions with `-Z panic-abort-tests`. The subprocess test runner also had to be updated to perform the conversion from benchmark to test when appropriate.

Along with the bug fix, in the first commit I refactored how tests are executed: rather than executing the test function in multiple places across `libtest`, there is now a private `TestFn::into_runnable()` method, which returns either a `RunnableTest` or `RunnableBench`, on which you can call the `run()` method. This simplified the rest of the changes in the PR.

This PR is best reviewed commit-by-commit.
Fixes https://github.com/rust-lang/rust/issues/73509
2023-07-01 07:07:50 +00:00
bors
6b06fdfcd4 Auto merge of #113194 - lu-zero:intrinsics-inline, r=thomcc
Mark wrapped intrinsics as inline(always)

This should mitigate having the inliner decide not to inline when the architecture is lacking an implementation of
TargetTransformInfo::areInlineCompatible aware of the target features (e.g. PowerPC as today).

See https://github.com/rust-lang/stdarch/pull/1443#issuecomment-1613788080
2023-07-01 04:24:26 +00:00
bors
7383ab7378 Auto merge of #113154 - lcnr:better-probe-check, r=compiler-errors
change snapshot tracking in fulfillment contexts

use the exact snapshot number to prevent misuse even when created inside of a snapshot
2023-07-01 01:53:10 +00:00
bors
e013d8f8b3 Auto merge of #113216 - matthiaskrgr:rollup-8xe65sj, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #113072 (str docs: remove "Basic usage" text where not useful)
 - #113153 (make HashMap::or_insert_with example more simple)
 - #113185 (Set `channel = nightly` in dist profile)
 - #113186 (document that the panic in collect_intra_doc_links is load-bearing)
 - #113187 (No need to distinguish `LocalTy` from `Ty`)
 - #113189 (compiletest: Only trim the end of process output)
 - #113191 (Update browser-ui-test version and improve GUI test)
 - #113206 (User may want to skip tidy check sometimes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-30 22:40:34 +00:00
Matthias Krüger
58a61eea89
Rollup merge of #113206 - chenyukang:yukang-trivial-fix-113135, r=Kobzol
User may want to skip tidy check sometimes

Fixes #113135
2023-07-01 00:35:08 +02:00
Matthias Krüger
626e1ea63c
Rollup merge of #113191 - GuillaumeGomez:update-browser-ui-test, r=notriddle
Update browser-ui-test version and improve GUI test

Few small fixes and added new commands which allow to compare elements size.

r? ``@notriddle``
2023-07-01 00:35:07 +02:00
Matthias Krüger
00efc94a6c
Rollup merge of #113189 - Zalathar:trim-end, r=ozkanonur
compiletest: Only trim the end of process output

As of #94196, compiletest automatically trims process stderr/stdout output before printing it, to make failure info more compact.

This causes the first line of `run-coverage` output to be displayed incorrectly, because it uses leading whitespace to align line numbers.

Trimming only the end of the output string should still have the intended effect (e.g. removing trailing newlines), without causing problems for output that deliberately uses leading whitespace on the first line.

## Before
```
--- stdout -------------------------------
1|      1|fn main() { //
    2|      1|    let num = 9;
    3|      1|    while num >= 10 {
    4|      0|    }
    5|      1|}
------------------------------------------
stderr: none
```

## After
```
--- stdout -------------------------------
    1|      1|fn main() { //
    2|      1|    let num = 9;
    3|      1|    while num >= 10 {
    4|      0|    }
    5|      1|}
------------------------------------------
stderr: none
```
2023-07-01 00:35:07 +02:00
Matthias Krüger
e1165300e8
Rollup merge of #113187 - compiler-errors:local-ty, r=b-naber
No need to distinguish `LocalTy` from `Ty`

I think the distinction between `decl_ty` and `revealed_ty` was from when you were allowed to put `impl Trait` in let bindings... I don't think we need that anymore, and it makes typeck that much more confusing 😆

Side-note: I don't know why we store this in a separate field [`locals`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/struct.Inherited.html#structfield.locals) in `Inherited`, rather than just the `TypeckResults`... Might look into changing that next.
2023-07-01 00:35:06 +02:00
Matthias Krüger
e823969573
Rollup merge of #113186 - jyn514:intra-doc-panic, r=petrochenkov
document that the panic in collect_intra_doc_links is load-bearing

r? ``@petrochenkov``
2023-07-01 00:35:06 +02:00
Matthias Krüger
a2c18616e3
Rollup merge of #113185 - jyn514:dist-channel, r=ozkanonur
Set `channel = nightly` in dist profile

This avoids some channel-specific defaults leaking into local installs. It also makes it easier to set options for compiler/library/codegen profiles in the future, since they can be gated off `channel` instead of being duplicated between all three files.

Here are the exact things `channel` controls today:
68d458bb40/src/bootstrap/llvm.rs (L466-L470)
85c4ea0138/src/bootstrap/config.rs (L1374-L1375)
85c4ea0138/src/bootstrap/config.rs (L1464-L1465)
``@cuviper`` i expect you don't want any of those to be set in distro builds, right?
2023-07-01 00:35:05 +02:00
Matthias Krüger
709f184593
Rollup merge of #113153 - tshepang:patch-6, r=cuviper
make HashMap::or_insert_with example more simple
2023-07-01 00:35:05 +02:00
Matthias Krüger
4e8f1357b8
Rollup merge of #113072 - tshepang:patch-1, r=cuviper
str docs: remove "Basic usage" text where not useful

Not "useful" in that there is only one example given
2023-07-01 00:35:04 +02:00
bors
f4b80cacf9 Auto merge of #113200 - ferrocene:pa-fix-mir-opt-bless, r=oli-obk
Fix loading target specs in compiletest not working with custom targets

In https://github.com/rust-lang/rust/pull/112454#issuecomment-1611351168 it was pointed out that the PR broke blessing mir-opt tests. Since #112418, blessing mir-opt tests generates "synthetic targets", which are custom target specs. Those specs are not included in `--print=all-target-specs-json`, and #112454 required that the current target was returned by that flag.

This PR fixes the breakage by loading the target spec for the current target explicitly, if a custom target is detected.

r? `@oli-obk`
2023-06-30 15:02:46 +00:00
Pietro Albini
00cc815e57
fix loading target specs in compiletest not working with custom targets 2023-06-30 14:36:14 +02:00
bors
56d507dc92 Auto merge of #109524 - bzEq:aix-embed-llvmbc, r=nagisa
Support embedding LLVM bitcode on AIX
2023-06-30 11:39:58 +00:00
Luca Barbato
528f11c24b Mark wrapped intrinsics as inline(always)
This should mitigate having the inliner decide not to inline when
the architecture is lacking an implementation of
TargetTransformInfo::areInlineCompatible aware of the target
features (e.g. PowerPC as today).
2023-06-30 12:07:21 +02:00
Guillaume Gomez
60c657f73a Improve search-result-display.goml test 2023-06-30 11:45:42 +02:00
Guillaume Gomez
f748aa5634 Update browser-ui-test version to 0.16.8 2023-06-30 11:45:37 +02:00
bors
af9df2fd91 Auto merge of #106619 - agausmann:avr-object-file, r=nagisa
Fix unset e_flags in ELF files generated for AVR targets

Closes #106576

~~Sort-of blocked by gimli-rs/object#500~~ (merged)

I'm not sure whether the list of AVR CPU names is okay here. Maybe it could be moved out-of-line to improve the readability of the function.
2023-06-30 08:55:56 +00:00
Zalathar
115cfda6c2 compiletest: Only trim the end of process output 2023-06-30 17:41:34 +10:00
yukang
cfa1a79009 User may want to skip tidy check sometimes 2023-06-30 15:37:10 +08:00
bors
b4591cb04c Auto merge of #113188 - matthiaskrgr:rollup-j3abaks, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #107624 (Stabilize `const_cstr_methods`)
 - #111403 (suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error)
 - #113071 (Account for late-bound vars from parent arg-position impl trait)
 - #113165 (Encode item bounds for `DefKind::ImplTraitPlaceholder`)
 - #113171 (Properly implement variances_of for RPITIT GAT)
 - #113177 (Use structured suggestion when telling user about `for<'a>`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-30 06:31:57 +00:00
Matthias Krüger
207b24413c
Rollup merge of #113177 - estebank:hrlt-sugg, r=compiler-errors
Use structured suggestion when telling user about `for<'a>`

```
error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> $DIR/E0637.rs:13:13
   |
LL |     T: Into<&u32>,
   |             ^ explicit lifetime name needed here
   |
help: consider introducing a higher-ranked lifetime here
   |
LL |     T: for<'a> Into<&'a u32>,
   |        +++++++       ++
```
2023-06-30 08:01:14 +02:00
Matthias Krüger
38e6bba9c1
Rollup merge of #113171 - spastorino:new-rpitit-25, r=compiler-errors
Properly implement variances_of for RPITIT GAT

This fixes some of the issues found by crater run in https://github.com/rust-lang/rust/pull/112988#issuecomment-1610019572

r? ``@compiler-errors``
2023-06-30 08:01:14 +02:00
Matthias Krüger
c8f50ee111
Rollup merge of #113165 - compiler-errors:rpitits-foreign-bounds, r=spastorino
Encode item bounds for `DefKind::ImplTraitPlaceholder`

This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃

Fixes #113155

r? ``@cjgillot``
2023-06-30 08:01:13 +02:00
Matthias Krüger
0b96b25bdf
Rollup merge of #113071 - compiler-errors:no-parent-non-lifetime-args-in-apit, r=eholk
Account for late-bound vars from parent arg-position impl trait

We should be reporting an error like we do for late-bound args coming from a parent APIT.

Fixes #113016
2023-06-30 08:01:13 +02:00
Matthias Krüger
6c22e0419f
Rollup merge of #111403 - y21:suggest-slice-swap, r=compiler-errors
suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error

Recently saw someone ask why this code (example slightly modified):
```rs
fn main() {
  let mut foo = [1, 2];
  std::mem::swap(&mut foo[0], &mut foo[1]);
}
```
triggers this error and how to fix it:
```
error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time
 --> src/main.rs:4:33
  |
4 |     std::mem::swap(&mut foo[0], &mut foo[1]);
  |     -------------- -----------  ^^^^^^^^^^^ second mutable borrow occurs here
  |     |              |
  |     |              first mutable borrow occurs here
  |     first borrow later used by call
  |
  = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
```
The current help message is nice and goes in the right direction, but I think we can do better for this specific instance and suggest `slice::swap`, which makes this compile
2023-06-30 08:01:12 +02:00
Matthias Krüger
016c306ce6
Rollup merge of #107624 - tgross35:const-cstr-methods, r=dtolnay
Stabilize `const_cstr_methods`

This PR seeks to stabilize `const_cstr_methods`. Fixes most of #101719

## New const stable API

```rust
impl CStr {
    // depends: memchr
    pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {...}
    // depends: const_slice_index
    pub const fn to_bytes(&self) -> &[u8] {}
    // depends: pointer casts
    pub const fn to_bytes_with_nul(&self) -> &[u8] {}
    // depends: str::from_utf8
    pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {}
}
```

I don't think any of these methods will have any issue when `CStr` becomes a thin pointer as long as `memchr` is const  (which also allows for const `strlen`) .

## Notes

- `from_bytes_until_nul` relies on `const_slice_index`, which relies on `const_trait_impls`, and generally this should be avoided. After talking with Oli, it should be OK in this case because we could replace the ranges with pointer tricks if needed (worst case being those feature gates disappear). https://github.com/rust-lang/rust/pull/107624#discussion_r1101468480
- Making `from_ptr` const is deferred because it depends on `const_eval_select`. I have moved this under the new flag `const_cstr_from_ptr` https://github.com/rust-lang/rust/pull/107624#discussion_r1101555239

cc ``@oli-obk`` I think you're the const expert

``@rustbot`` modify labels: +T-libs-api +needs-fcp
2023-06-30 08:01:12 +02:00
Michael Goulet
91bc3f0ff6 No need to distinguish LocalTy from Ty 2023-06-30 04:51:02 +00:00
jyn
53185459df document that the panic in collect_intra_doc_links is load-bearing 2023-06-29 23:48:56 -05:00
jyn
368f51743b Set channel = nightly in dist profile 2023-06-29 23:37:20 -05:00
bors
97279e91d8 Auto merge of #113162 - matthiaskrgr:rollup-fct3wj7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111322 (Support for native WASM exceptions)
 - #112086 (resolve: Remove artificial import ambiguity errors)
 - #112234 (refactor `tool_doc!`)
 - #112300 (Convert `run-make/coverage-reports` tests to use a custom compiletest mode)
 - #112795 (Migrate some rustc_builtin_macros to SessionDiagnostic)
 - #113144 (Make the `Elaboratable` trait take clauses)
 - #113161 (Fix type privacy lints error message)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-30 03:27:42 +00:00
Santiago Pastorino
a10406318e
Properly implement variances_of for RPITIT GAT 2023-06-29 23:08:32 -03:00
bors
8aed93d912 Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk
A mish-mash of micro-optimizations

These were aimed at speeding up LLVM codegen, but ended up affecting other places as well.

r? `@bjorn3`
2023-06-30 00:35:19 +00:00
Esteban Küber
7d33094d3a Use structured suggestion when telling user about for<'a>
```
error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> $DIR/E0637.rs:13:13
   |
LL |     T: Into<&u32>,
   |             ^ explicit lifetime name needed here
   |
help: consider introducing a higher-ranked lifetime here
   |
LL |     T: for<'a> Into<&'a u32>,
   |        +++++++       ++
```
2023-06-30 00:34:14 +00:00
bors
330727467b Auto merge of #112682 - spastorino:new-rpitit-21, r=compiler-errors
Add bidirectional where clauses on RPITIT synthesized GATs

Given the following:

```rust
struct MyStruct<'a, T>(&'a T);

trait MyTrait<'a, T> {
    fn my_fn<'b, 'c, 'd, V>(item: &'c String) -> impl Sized + 'a + 'b + 'c where V: 'b, V: 'd;
}

impl<'a, T> MyTrait<'a, T> for MyStruct<'a, T> {
    fn my_fn<'b, 'c, 'd, V>(_: &'c String) -> impl Sized + 'a + 'b + 'c
    where
        V: 'b,
        V: 'd,
    {
        unimplemented!();
    }
}
```

We need the desugaring to be:

```rust
trait MyTrait<'a, T> {
    type MyFn<'bf, 'df, Vf, 'a2, 'b2, 'c2>: Sized + 'a2 + 'b2 + 'c2 where Vf: 'b2, 'a2: 'a, 'a: 'a2, 'b2: 'bf, 'bf: 'b2;

    fn my_fn<'b, 'c, 'd, V>(item: &'c String) -> MyStruct<'a>::MyFn<'b, 'd, V, 'a, 'b, 'c> where V: 'b, V: 'd {
        type opaque<'a3, 'b3, 'c3>;
    };
}

impl<'a, T> MyIter<'a, T> for MyStruct<'a, T> {
    type MyFn<'bf, 'df, Vf, 'a2, 'b2, 'c2> = impl Sized + 'a2 + 'b2 + 'c2 where Vf: b2, 'a2: 'a, 'a: 'a2, 'b2: 'bf, 'bf: 'b2;

    fn my_fn<'b, 'c, 'd, V>(_: &'c String) -> MyStruct<'a>::MyFn<'a, 'b, 'c, V> where V: 'b, V: 'd {
        type opaque<'a3, 'b3, 'c3>;
        unimplemented!();
    }
}
```

This PR adds the where clauses for the `MyFn` generated GATs.

This is a draft with a very ugly solution so we can make comments over concrete code.

r? `@compiler-errors`
2023-06-29 21:24:51 +00:00
bors
b23a5add09 Auto merge of #113059 - Kobzol:ci-concurrency-fix, r=pietroalbini
CI: do not cancel concurrent builds on the same branch

Do not cancel concurrent builds on the same branch (outside of PRs).

Instead, only cancel them if the builds have the same commit SHA.

From the [documentation](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context):
> The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see "[Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)." For example, ffac537e6cbbf934b08745a378932722df287a53.

Fixes: https://github.com/rust-lang/rust/pull/112955#discussion_r1242273658

r? `@pietroalbini`
2023-06-29 18:18:52 +00:00
Santiago Pastorino
6f4a51e80e
Do not generate lifetime_mapping for RPIT no in_trait 2023-06-29 14:26:28 -03:00
Santiago Pastorino
4925b57782
Add bidirectional where clauses on RPITIT synthesized GATs 2023-06-29 14:26:26 -03:00
y21
679c5be405 add slice::swap suggestion 2023-06-29 19:19:59 +02:00
Santiago Pastorino
d70deac161
Intern OpaqueTy on ItemKind::OpaqueTy 2023-06-29 14:05:10 -03:00
Santiago Pastorino
72a32583d1
Reorganize opaque lowering code 2023-06-29 14:04:37 -03:00
Santiago Pastorino
33d21e62d0
Do not remove previously added predicates in param_env, extend them instead 2023-06-29 14:04:29 -03:00
Santiago Pastorino
373293c3ca
Extract compute_bidirectional_outlives_predicates fn 2023-06-29 14:04:26 -03:00
Michael Goulet
0506250f8c Encode item bounds for DefKind::ImplTraitPlaceholder 2023-06-29 16:37:13 +00:00
bors
a20a04e5d6 Auto merge of #113108 - compiler-errors:normalize-opaques-with-late-bound-vars-again, r=jackh726
Normalize opaques with late-bound vars again

We have a hack in the compiler where if an opaque has escaping late-bound vars, we skip revealing it even though we *could* reveal it from a technical perspective. First of all, this is weird, since we really should be revealing all opaques in `Reveal::All` mode. Second of all, it causes subtle bugs (linked below).

I attempted to fix this in #100980, which was unfortunately reverted due to perf regressions on codebases that used really deeply nested futures in some interesting ways. The worst of which was #103423, which caused the project to hang on build. Another one was #104842, which was just a slow-down, but not a hang. I took some time afterwards to investigate how to rework `normalize_erasing_regions` to take advantage of better caching, but that effort kinda fizzled out (#104133).

However, recently, I was made aware of more bugs whose root cause is not revealing opaques during codegen. That made me want to fix this again -- in the process, interestingly, I took the the minimized example from https://github.com/rust-lang/rust/issues/103423#issuecomment-1292947043, and it doesn't seem to hang any more...

Thinking about this harder, there have been some changes to the way we lower and typecheck async futures that may have reduced the pathologically large number of outlives obligations (see description of #103423) that we were encountering when normalizing opaques with bound vars the last time around:
* #104321 (lower `async { .. }` directly as a generator that implements `Future`, removing the `from_generator` shim)
* #104833 (removing an `identity_future` fn that was wrapping desugared future generators)

... so given that I can see:
* No significant regression on rust perf bot (https://github.com/rust-lang/rust/pull/107620#issuecomment-1600070317)
* No timeouts in crater run I did (https://github.com/rust-lang/rust/pull/107620#issuecomment-1605428952, rechecked failing crates in https://github.com/rust-lang/rust/pull/107620#issuecomment-1605973434)

... and given that this PR:
* Fixes #104601
* Fixes #107557
* Fixes #109464
* Allows us to remove a `DefiningAnchor::Bubble` from codegen (75a8f68183)

I'm inclined to give this another shot at landing this. Best case, it just works -- worst case, we get more examples to study how we need to improve the compiler to make this work.

r? types
2023-06-29 15:37:11 +00:00
Matthias Krüger
4338683b94
Rollup merge of #113161 - Bryanskiy:err_msg, r=petrochenkov
Fix type privacy lints error message

Type privacy lints diagnostic messages are not related to spans.

r? `@petrochenkov`
2023-06-29 16:36:33 +02:00
Matthias Krüger
5d74664a7e
Rollup merge of #113144 - compiler-errors:elaborate-clauses, r=oli-obk
Make the `Elaboratable` trait take clauses

We only ever elaborate clauses, so make this explicit in the trait's definition rather than having a bunch of `.expect_clause()` calls everywhere.
2023-06-29 16:36:32 +02:00
Matthias Krüger
f135815f9b
Rollup merge of #112795 - He1pa:translation_builtin_macros, r=davidtwco
Migrate some rustc_builtin_macros to SessionDiagnostic

Part of https://github.com/rust-lang/rust/issues/100717.

``@rustbot`` label +A-translation
2023-06-29 16:36:32 +02:00