Commit Graph

226468 Commits

Author SHA1 Message Date
Michael Goulet
7a2cdf20e4 Move alias-relate to its own module 2023-06-06 18:44:22 +00:00
Michael Goulet
aabdeedc7c bless coherence test 2023-06-06 18:43:20 +00:00
Michael Goulet
3d4da98273 Make TraitEngine::new use the right solver, add compare mode 2023-06-06 18:43:20 +00:00
Michael Goulet
b637048a89 Add -Ztrait-solver=next-coherence 2023-06-06 18:43:20 +00:00
Michael Goulet
e0acff796a New trait solver is a property of inference context 2023-06-06 18:43:06 +00:00
bors
b2b34bd831 Auto merge of #112344 - matthiaskrgr:rollup-tswr83e, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #111058 (Correct fortanix LVI test print function)
 - #111369 (Added custom risc32-imac for esp-espidf target)
 - #111962 (Make GDB Python Pretty Printers loadable after spawning GDB, avoiding required `rust-gdb`)
 - #112019 (Don't suggest changing `&self` and `&mut self` in function signature to be mutable when taking `&mut self` in closure)
 - #112199 (Fix suggestion for matching struct with `..` on both ends)
 - #112220 (Cleanup some `EarlyBinder::skip_binder()` -> `EarlyBinder::subst_identity()`)
 - #112325 (diagnostics: do not suggest type name tweaks on type-inferred closure args)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-06 17:56:23 +00:00
bohan
c927743b7b fix(expand): prevent infinity loop in macro containing only "///" 2023-06-06 23:11:08 +08:00
Nikolay Arhipov
032857e7e4 Bumped libc version 2023-06-06 16:09:05 +03:00
Matthias Krüger
38c92cca65
Rollup merge of #112325 - notriddle:notriddle/issue-111932, r=compiler-errors
diagnostics: do not suggest type name tweaks on type-inferred closure args

Fixes #111932
2023-06-06 12:00:34 +02:00
Matthias Krüger
7c76f3b9d8
Rollup merge of #112220 - kylematsuda:earlybinder-fix, r=compiler-errors
Cleanup some `EarlyBinder::skip_binder()` -> `EarlyBinder::subst_identity()`

fix some incorrect `skip_binder()`'s as identified in https://github.com/rust-lang/rust/pull/112006#pullrequestreview-1448369203

r? ``@compiler-errors`` ``@lcnr`` ``@jackh726``

(hope it's alright to just tag everyone who commented 😅)
2023-06-06 12:00:34 +02:00
Matthias Krüger
71a72ee34a
Rollup merge of #112199 - jieyouxu:issue-112188, r=compiler-errors
Fix suggestion for matching struct with `..` on both ends

### Before This PR

```
error: expected `}`, found `,`
 --> src\main.rs:8:17
  |
8 |         Foo { .., x, .. } => (),
  |               --^
  |               | |
  |               | expected `}`
  |               `..` must be at the end and cannot have a trailing comma
  |
help: move the `..` to the end of the field list
  |
8 -         Foo { .., x, .. } => (),
8 +         Foo { .., x,  , .. } => (),
  |
```

### After This PR

```
error: expected `}`, found `,`
  --> tests/ui/parser/issue-112188.rs:11:17
   |
11 |     let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,`
   |               --^-
   |               | |
   |               | expected `}`
   |               `..` must be at the end and cannot have a trailing comma
   |               help: remove the starting `..`
```

Fixes #112188.
2023-06-06 12:00:33 +02:00
Matthias Krüger
21e7463bf8
Rollup merge of #112019 - jieyouxu:issue-111554, r=compiler-errors
Don't suggest changing `&self` and `&mut self` in function signature to be mutable when taking `&mut self` in closure

Current suggestion for when taking a mutable reference to `self` in a closure (as an upvar) will produce a machine-applicable suggestion to change the `self` in the function signature to `mut self`, but does not account for the specialness of implicit self in that it can already have `&` and `&mut` (see #111554). This causes the function signature to become `test(&mut mut self)` which does not seem desirable.

```
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
   --> src/sound_player.rs:870:11
    |
869 |     pub fn test(&mut self) {
    |                      ---- help: consider changing this to be mutable: `mut self`
870 |     || test2(&mut self);
    |              ^^^^^^^^^ cannot borrow as mutable
```

This PR suppresses the "changing this to be mutable" suggestion if the implicit self is either `ImplicitSelfKind::ImmRef` or `ImplicitSelfKind::MutRef`.

Fixes #111554.
2023-06-06 12:00:33 +02:00
Matthias Krüger
29871d5480
Rollup merge of #111962 - theIDinside:better-gdb, r=Mark-Simulacrum
Make GDB Python Pretty Printers loadable after spawning GDB, avoiding required `rust-gdb`

Fixes #111961

Makes the Python pretty printer library source'able from within GDB after spawn, making the wrapper script `rust-gdb` become not the required approach to use the pretty printer library.

Allows for integration into GUI:s that wrap GDB extremely easy. The previous design complicates this feature.
2023-06-06 12:00:32 +02:00
Matthias Krüger
c4e11dc327
Rollup merge of #111369 - Nassiel:master, r=oli-obk
Added custom risc32-imac for esp-espidf target

ESP32-C6 and the upcoming ESP32-P4 are the first Espressif chips that support the "A" (atomic) extension of the RISCV specification.
As such, they do not work with the existing `riscv32imc-esp-espidf` target and instead need a new one (in this PR) called `riscv32imac-esp-espidf`.
2023-06-06 12:00:32 +02:00
Matthias Krüger
92327c05f1
Rollup merge of #111058 - fortanix:raoul/fix_lvi_mitigations, r=cuviper
Correct fortanix LVI test print function

A recent change resulted in a different machine code for the `print` function. This caused the LVI test for this function to fail. This PR:

- Fixes the test for the `print` function
- Simplified the test a bit so future modifications are more unlikely

cc: ``@jethrogb``
2023-06-06 12:00:31 +02:00
Guillaume Gomez
550fe634bf Add regression test for #112308 2023-06-06 11:50:24 +02:00
Guillaume Gomez
4711c3078a Prevent emitting missing_docs for pub extern crate 2023-06-06 11:50:04 +02:00
bors
3572d7451d Auto merge of #112312 - nikic:llvm-16.0.5, r=cuviper
Update to LLVM 16.0.5

Rebase to LLVM 16.0.5, plus one cherry-pick.

Fixes #111823.
Fixes #112061.
Fixes #112170.
2023-06-06 09:40:31 +00:00
lcnr
01aaad3f1f remove has_error_field helper method 2023-06-06 09:37:30 +02:00
Laurențiu Nicola
a3cc503876 Fix rust-analyzer proc macro server 2023-06-06 10:33:32 +03:00
Deadbeef
aaca1712db Add myself to highfive rotation 2023-06-06 03:15:52 +00:00
WANG Rui
bd32075934 Add new Tier-3 targets: loongarch64-unknown-none*
MCP: https://github.com/rust-lang/compiler-team/issues/628
2023-06-06 10:55:52 +08:00
John Kåre Alsaker
fd3d2d49f2 Don't hold the active queries lock while calling make_query 2023-06-06 04:51:34 +02:00
Michael Howell
467bc9ffd5 diagnostics: do not suggest type name tweaks on type-inferred closure args
Fixes #111932
2023-06-05 19:05:15 -07:00
bors
fd9bf59436 Auto merge of #111999 - scottmcm:codegen-less-memcpy, r=compiler-errors
Use `load`+`store` instead of `memcpy` for small integer arrays

I was inspired by #98892 to see whether, rather than making `mem::swap` do something smart in the library, we could update MIR assignments like `*_1 = *_2` to do something smarter than `memcpy` for sufficiently-small types that doing it inline is going to be better than a `memcpy` call in assembly anyway.  After all, special code may help `mem::swap`, but if the "obvious" MIR can just result in the correct thing that helps everything -- other code like `mem::replace`, people doing it manually, and just passing around by value in general -- as well as makes MIR inlining happier since it doesn't need to deal with all the complicated library code if it just sees a couple assignments.

LLVM will turn the short, known-length `memcpy`s into direct instructions in the backend, but that's too late for it to be able to remove `alloca`s.  In general, replacing `memcpy`s with typed instructions is hard in the middle-end -- even for `memcpy.inline` where it knows it won't be a function call -- is hard [due to poison propagation issues](https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/memcpy.20vs.20load-store.20for.20MIR.20assignments/near/360376712).  So because we know more about the type invariants -- these are typed copies -- rustc can emit something more specific, allowing LLVM to `mem2reg` away the `alloca`s in some situations.

#52051 previously did something like this in the library for `mem::swap`, but it ended up regressing during enabling mir inlining (cbbf06b0cd), so this has been suboptimal on stable for ≈5 releases now.

The code in this PR is narrowly targeted at just integer arrays in LLVM, but works via a new method on the [`LayoutTypeMethods`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/traits/trait.LayoutTypeMethods.html) trait, so specific backends based on cg_ssa can enable this for more situations over time, as we find them.  I don't want to try to bite off too much in this PR, though.  (Transparent newtypes and simple things like the 3×usize `String` would be obvious candidates for a follow-up.)

Codegen demonstrations: <https://llvm.godbolt.org/z/fK8hT9aqv>

Before:
```llvm
define void `@swap_rgb48_old(ptr` noalias nocapture noundef align 2 dereferenceable(6) %x, ptr noalias nocapture noundef align 2 dereferenceable(6) %y) unnamed_addr #1 {
  %a.i = alloca [3 x i16], align 2
  call void `@llvm.lifetime.start.p0(i64` 6, ptr nonnull %a.i)
  call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %a.i, ptr noundef nonnull align 2 dereferenceable(6) %x, i64 6, i1 false)
  tail call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %x, ptr noundef nonnull align 2 dereferenceable(6) %y, i64 6, i1 false)
  call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %y, ptr noundef nonnull align 2 dereferenceable(6) %a.i, i64 6, i1 false)
  call void `@llvm.lifetime.end.p0(i64` 6, ptr nonnull %a.i)
  ret void
}
```
Note it going to stack:
```nasm
swap_rgb48_old:                         # `@swap_rgb48_old`
        movzx   eax, word ptr [rdi + 4]
        mov     word ptr [rsp - 4], ax
        mov     eax, dword ptr [rdi]
        mov     dword ptr [rsp - 8], eax
        movzx   eax, word ptr [rsi + 4]
        mov     word ptr [rdi + 4], ax
        mov     eax, dword ptr [rsi]
        mov     dword ptr [rdi], eax
        movzx   eax, word ptr [rsp - 4]
        mov     word ptr [rsi + 4], ax
        mov     eax, dword ptr [rsp - 8]
        mov     dword ptr [rsi], eax
        ret
```

Now:
```llvm
define void `@swap_rgb48(ptr` noalias nocapture noundef align 2 dereferenceable(6) %x, ptr noalias nocapture noundef align 2 dereferenceable(6) %y) unnamed_addr #0 {
start:
  %0 = load <3 x i16>, ptr %x, align 2
  %1 = load <3 x i16>, ptr %y, align 2
  store <3 x i16> %1, ptr %x, align 2
  store <3 x i16> %0, ptr %y, align 2
  ret void
}
```
still lowers to `dword`+`word` operations, but has no stack traffic:
```nasm
swap_rgb48:                             # `@swap_rgb48`
        mov     eax, dword ptr [rdi]
        movzx   ecx, word ptr [rdi + 4]
        movzx   edx, word ptr [rsi + 4]
        mov     r8d, dword ptr [rsi]
        mov     dword ptr [rdi], r8d
        mov     word ptr [rdi + 4], dx
        mov     word ptr [rsi + 4], cx
        mov     dword ptr [rsi], eax
        ret
```

And as a demonstration that this isn't just `mem::swap`, a `mem::replace` on a small array (since replace doesn't use swap since #83022), which used to be `memcpy`s in LLVM changes in IR
```llvm
define void `@replace_short_array(ptr` noalias nocapture noundef sret([3 x i32]) dereferenceable(12) %0, ptr noalias noundef align 4 dereferenceable(12) %r, ptr noalias nocapture noundef readonly dereferenceable(12) %v) unnamed_addr #0 {
start:
  %1 = load <3 x i32>, ptr %r, align 4
  store <3 x i32> %1, ptr %0, align 4
  %2 = load <3 x i32>, ptr %v, align 4
  store <3 x i32> %2, ptr %r, align 4
  ret void
}
```
but that lowers to reasonable `dword`+`qword` instructions still
```nasm
replace_short_array:                    # `@replace_short_array`
        mov     rax, rdi
        mov     rcx, qword ptr [rsi]
        mov     edi, dword ptr [rsi + 8]
        mov     dword ptr [rax + 8], edi
        mov     qword ptr [rax], rcx
        mov     rcx, qword ptr [rdx]
        mov     edx, dword ptr [rdx + 8]
        mov     dword ptr [rsi + 8], edx
        mov     qword ptr [rsi], rcx
        ret
```
2023-06-06 01:50:28 +00:00
Kyle Matsuda
57cbe25006 cleanup some skip_binder -> subst_identity 2023-06-05 18:40:36 -06:00
bors
adc719d714 Auto merge of #112324 - matthiaskrgr:rollup-qscmi3c, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #112081 (Avoid ICE on `#![doc(test(...)]` with literal parameter)
 - #112196 (Resolve vars in result from `scrape_region_constraints`)
 - #112303 (Normalize in infcx instead of globally for `Option::as_deref` suggestion)
 - #112316 (Ensure space is inserted after keyword in `unused_delims`)
 - #112318 (Merge method, type and const object safety checks)
 - #112322 (Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error)

Failed merges:

 - #112251 (rustdoc: convert `if let Some()` that always matches to variable)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-05 22:44:59 +00:00
Matthias Krüger
dcdd867a52
Rollup merge of #112322 - compiler-errors:no-IMPLIED_BOUNDS_ENTAILMENT-if-errs, r=eholk
Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error

Fixes #112321
2023-06-05 23:48:00 +02:00
Matthias Krüger
44acf796c7
Rollup merge of #112318 - oli-obk:assoc_ty_sized_bound_for_object_safety, r=compiler-errors
Merge method, type and const object safety checks

cc `@spastorino` and `@compiler-errors` on the first commit. I believe it to be correct, as the field is only `Some` for assoc types, so just checking the field without checking the assoc kind to be `Type` is fine.

The second commit avoids going through all associated items thrice and just goes over all of them once, running the object safety checks per assoc item kind.
2023-06-05 23:48:00 +02:00
Matthias Krüger
0ff5a6ee57
Rollup merge of #112316 - clubby789:unused-parens-space, r=compiler-errors
Ensure space is inserted after keyword in `unused_delims`

Fixes #112276
2023-06-05 23:47:59 +02:00
Matthias Krüger
ff43249b0e
Rollup merge of #112303 - Nilstrieb:as-deref, r=compiler-errors
Normalize in infcx instead of globally for `Option::as_deref` suggestion

fixes #112293

The projection may contain inference variables. These inference variables are local to the local inference context. Using `tcx.normalize_erasing_regions` doesn't work here because this method is global and does not have access to the inference context. It's therefore unable to deal with the inference variables. We normalize in the local inference context instead, which knowns about the inference variables.

The test looks a little different than the issue example, I made it more minimal and verified that it still ICEs on nightly.

Also contains a drive-by fix to properly compare the types.

r? `@compiler-errors`
2023-06-05 23:47:59 +02:00
Matthias Krüger
9ce0c7951c
Rollup merge of #112196 - compiler-errors:new-solver-resolv, r=lcnr
Resolve vars in result from `scrape_region_constraints`

Since we perform `type_op::Normalize` in the local infcx when the new solver is enabled, vars aren't necessarily resolved, which triggers this ICE:

f85ab544df/compiler/rustc_infer/src/infer/nll_relate/mod.rs (L481)

There are more tests that go from ICE -> pass due to this change, but I just added revisions to a few for CI.

r? `@lcnr`
2023-06-05 23:47:58 +02:00
Matthias Krüger
129a57a9f6
Rollup merge of #112081 - obeis:doc-test-literal, r=compiler-errors
Avoid ICE on `#![doc(test(...)]` with literal parameter

Close #109066

r? `@compiler-errors`
2023-06-05 23:47:57 +02:00
Michael Goulet
0e9e91a95a Don't mention IMPLIED_BOUNDS_ENTAILMENT if signatures reference error 2023-06-05 21:20:51 +00:00
Michael Goulet
140c011ca6 Don't mention already set fields 2023-06-05 21:00:08 +00:00
Michael Goulet
b0eaaca314 Remove redundant InferCtxtExt::fresh_item_substs 2023-06-05 20:05:08 +00:00
Jakub Beránek
c91a3a4d0c
Test the PGO/BOLT/LTO optimized x64 Linux compiler on CI 2023-06-05 21:54:52 +02:00
Michael Goulet
bbc536d3ac Emit an error when RTN is used with ty/ct params 2023-06-05 19:52:04 +00:00
Michael Goulet
979379aff7 Resolve vars in result from scrape_region_constraints 2023-06-05 19:40:30 +00:00
bors
e6d4725c76 Auto merge of #112071 - WaffleLapkin:group-rfcs-tests, r=oli-obk
Group rfcs tests

This moves all RFC tests to `tests/ui/rfcs/rfc-NNNN-title-title-title/...`

I had to rename some tests due to conflicts, but otherwise this is just a move.
2023-06-05 19:36:17 +00:00
bors
408bbd0406 Auto merge of #112317 - GuillaumeGomez:rollup-toh0gpo, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #112243 (Remove unneeded `Buffer` allocations when `&mut fmt::Write` can be used directly)
 - #112263 (Remove ExtendElement, ExtendWith, extend_with)
 - #112291 (Disable RustAnalyzer check by default, run Rustfmt check before)
 - #112299 (Don't double-print status messages in GHA)
 - #112311 (Ignore fluent message reordering in `git blame`)
 - #112315 (fix spelling error)

Failed merges:

 - #112251 (rustdoc: convert `if let Some()` that always matches to variable)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-05 16:50:32 +00:00
Oli Scherer
58972d19e7 Merge method, type and const object safety checks 2023-06-05 16:39:16 +00:00
Nikolay Arhipov
ac48d49ff8 Simplified bool to int conversion 2023-06-05 19:26:04 +03:00
Nikolay Arhipov
50117af409 Std support improvement for ps vita target 2023-06-05 19:14:09 +03:00
Maybe Waffle
18e016f7e0 Bless tidy root entry limit 2023-06-05 16:10:46 +00:00
Maybe Waffle
9d3482c403 Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
Raoul Strackx
b35f243c89 Verify that (almost) all ret instructions have been replaced 2023-06-05 17:33:26 +02:00
Guillaume Gomez
7c363c22a2
Rollup merge of #112315 - lucascherzer:master, r=Nilstrieb
fix spelling error

"rexport" is not valid spelling: https://www.merriam-webster.com/dictionary/re-export
2023-06-05 17:02:53 +02:00
Guillaume Gomez
714ab6dc37
Rollup merge of #112311 - clubby789:blame-ignore-fluent-reorder, r=Nilstrieb
Ignore fluent message reordering in `git blame`

This commit reordered most of our Fluent message files. Since `git blame` can be useful in tracking mistakes made while adapting to translatable diagnostics, ignore this commit in `blame`.
r? `@jyn514`
2023-06-05 17:02:52 +02:00
Guillaume Gomez
154949dacd
Rollup merge of #112299 - jyn514:gha-progress, r=oli-obk
Don't double-print status messages in GHA

Before:

```
Building stage0 tool jsondocck (x86_64-unknown-linux-gnu)
  Building stage0 tool jsondocck (x86_64-unknown-linux-gnu)
   Downloading crates ...
```

After:

```
Building stage0 tool jsondocck (x86_64-unknown-linux-gnu)
   Downloading crates ...
```

r? `@oli-obk`
2023-06-05 17:02:52 +02:00