Commit Graph

240440 Commits

Author SHA1 Message Date
bors
c263ccf185 Auto merge of #118461 - celinval:smir-switch-targets, r=ouz-a
Change `SwitchTarget` representation in StableMIR

The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly.

I encapsulated the structure for now in case we decide to change it back.

### Notes:

1. I had to change the `Successors` type, since there's a conflict on the iterator type. We could potentially implement an iterator here, but I would prefer keeping it simple for now, and add a `successors_iter()` method if needed.
2. I removed `CoroutineDrop` for now since it we never create it. We can add it when we add support to other MIR stages.
2023-12-01 02:08:51 +00:00
Yutaro Ohno
e076192dd8 Improve error handling for top-level let statements
This commit addresses the issue of excessive and unrelated errors
generated by top-level `let` statements. Now, only a single error is
produced, indicating that `let` statements are invalid at the top level.
2023-12-01 10:37:21 +09:00
bors
1d726a2be0 Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3
`rustc_session` cleanups

r? `@bjorn3`
2023-12-01 00:08:04 +00:00
Wesley Wiser
d9c645561d Wesley is on vacation 2023-11-30 16:55:24 -06:00
bors
f45631b10f Auto merge of #116892 - ojeda:rethunk, r=wesleywiser
Add `-Zfunction-return={keep,thunk-extern}` option

This is intended to be used for Linux kernel RETHUNK builds.

With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module.

Issue: https://github.com/rust-lang/rust/issues/116853.
2023-11-30 22:10:30 +00:00
Ralf Jung
dbea549d80 move exposed-provenance APIs into separate feature gate and explain the relationship of Exposed Provenance and Strict Provenance 2023-11-30 22:49:13 +01:00
Andreas Jonson
8870768552 Change prefetch to avoid deadlock 2023-11-30 22:17:57 +01:00
Nicholas Nethercote
275b793c33 Clarify the lockfile field in IncrCompSession. 2023-12-01 08:00:56 +11:00
Nicholas Nethercote
e065d96b08 Remove unused field from IncrCompSession. 2023-12-01 08:00:56 +11:00
Nicholas Nethercote
4b90b26fd8 Move WasiExecModel.
All the other option enums are defined in `config.rs`.
2023-12-01 08:00:56 +11:00
Nicholas Nethercote
5f11d19be5 Reduce pub exposure. 2023-12-01 08:00:53 +11:00
bors
87e1447aad Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkov
On Fn arg mismatch for a fn path, suggest a closure

When encountering a fn call that has a path to another fn being passed in, where an `Fn` impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments.

The last `help` is new:

```
error[E0631]: type mismatch in function arguments
  --> $DIR/E0631.rs:9:9
   |
LL |     fn f(_: u64) {}
   |     ------------ found signature defined here
...
LL |     foo(f);
   |     --- ^ expected due to this
   |     |
   |     required by a bound introduced by this call
   |
   = note: expected function signature `fn(usize) -> _`
              found function signature `fn(u64) -> _`
note: required by a bound in `foo`
  --> $DIR/E0631.rs:3:11
   |
LL | fn foo<F: Fn(usize)>(_: F) {}
   |           ^^^^^^^^^ required by this bound in `foo`
help: consider wrapping the function in a closure
   |
LL |     foo(|arg0: usize| f(/* u64 */));
   |         +++++++++++++  +++++++++++
```
2023-11-30 20:12:53 +00:00
Ralf Jung
1dbfe17f12 generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
Celina G. Val
9d2c92377d Fix SwitchTarget pretty print
We currently rely on the order of successors to be conditional branches
first, followed by the otherwise target.
2023-11-30 11:45:34 -08:00
Celina G. Val
3e0b2fac5d Change SwitchTarget representation
The new structure encodes its invariant, which reduces the likelihood
of having an inconsistent representation. It is also more intuitive and
user friendly.

I encapsulated the structure for now in case we decide to change it back.
2023-11-30 11:45:34 -08:00
bors
c9d189d137 Auto merge of #15993 - meowtec:fix/workspaces-debug-cwd, r=Veykril
Debug use cargo workspace root as `cwd`

fixes #13022
2023-11-30 19:31:15 +00:00
Miguel Ojeda
2d476222e8 Add -Zfunction-return={keep,thunk-extern} option
This is intended to be used for Linux kernel RETHUNK builds.

With this commit (optionally backported to Rust 1.73.0), plus a
patched Linux kernel to pass the flag, I get a RETHUNK build with
Rust enabled that is `objtool`-warning-free and is able to boot in
QEMU and load a sample Rust kernel module.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30 20:21:31 +01:00
bors
00796255c2 Auto merge of #118448 - ZetaNumbers:link_arg_attribute, r=petrochenkov
Enable `link-arg` link kind inside of `#[link]` attribute

https://github.com/rust-lang/rust/issues/99427#issuecomment-1234443468

> ...
> This would help to make `link-arg` usable in `#[link]` attributes and e.g. wrap libc and libgcc into a group (*) in the libc crate like
>
> ```
> #[link(kind = "link-arg", name = "--start-group")]
> #[link(kind = "static", name = "c")]
> #[link(kind = "static", name = "gcc")]
> #[link(kind = "link-arg", name = "--end-group")]
> ```
>
> (*) to address cyclic dependencies between them
>
> This is an analogue of CMake's LINKER: prefix (https://cmake.org/cmake/help/git-stage/command/target_link_options.html#handling-compiler-driver-differences), and was discussed as a possible future extension in the link modifier RFC (https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#support-linkarg--string-in-addition-to-the-modifiers).
2023-11-30 18:09:45 +00:00
Michael Howell
7230f6c5c5 rustdoc: div.where instead of fmt-newline class
This is about equally readable, a lot more terse, and stops
special-casing functions and methods.

```console
$ du -hs doc-old/ doc-new/
671M    doc-old/
670M    doc-new/
```
2023-11-30 10:43:40 -07:00
zetanumbers
f7617c1cd4 Enable link-arg link kind inside of #[link] attribute
- Implement link-arg as an attribute
- Apply suggestions from review
  - Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
- Add unstable book entry
2023-11-30 08:26:13 -08:00
Ralf Jung
a1b03e3067 explain a good reason for why LocalValue does not store the type of the local 2023-11-30 17:01:28 +01:00
clubby789
2cda044f8c Allow allowing upper_case_acronyms on enum variants 2023-11-30 16:00:40 +00:00
bors
1c51e25a5a Auto merge of #15994 - ChayimFriedman2:err-comma-after-fus, r=Veykril
fix: Err for comma after functional update syntax

Error message copied from rustc, https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=20aeedb2db504c4e4ced54b665e761d6.

Fixes #15989.
2023-11-30 15:59:31 +00:00
bors
d368c4043c Auto merge of #3197 - RalfJung:rustup, r=RalfJung
Rustup

also move some fail tests into suitable subdirectories
2023-11-30 15:21:09 +00:00
bors
646b28f5f6 Auto merge of #11896 - samueltardieu:issue-11893, r=Alexendoo
`option_if_let_else`: do not trigger on expressions returning `()`

Fix #11893

Trigerring on expressions returning `()` uses the arguments of the `map_or_else()` rewrite only for their side effects. This does lead to code which is harder to read than the original.

changelog: [`option_if_let_else`]: do not trigger on unit expressions
2023-11-30 15:17:29 +00:00
bors
07921b50ba Auto merge of #118036 - DianQK:thinlto-tests, r=tmiasko
Add thinlto support to codegen, assembly and coverage tests

Using `--emit=llvm-ir` with thinlto usually result in multiple IR files.
Resolve test case failure issue reported in #113923.
2023-11-30 13:33:32 +00:00
Ralf Jung
cd12440933 give macOS some extra time, it needs that 2023-11-30 14:29:54 +01:00
Ralf Jung
a0c8b09cf8 move some validity-related tests into subdir 2023-11-30 13:11:17 +01:00
bors
56abc0a29c Auto merge of #15971 - Young-Flash:fix_match_arm, r=lnicola
fix: don't make `MissingMatchArms` diagnostic for empty match body

before
<img width="423" alt="before" src="https://github.com/rust-lang/rust-analyzer/assets/71162630/5c0e46fb-0c03-42f2-96ff-8e5245c25965">

after
<img width="423" alt="after" src="https://github.com/rust-lang/rust-analyzer/assets/71162630/e2479dc5-3634-479b-af29-0b0ec7dc4a4f">

close https://github.com/rust-lang/rust-analyzer/issues/15954
2023-11-30 12:10:45 +00:00
Ralf Jung
64fb96f17e move 'uninit' tests into common directory 2023-11-30 13:09:37 +01:00
Chayim Refael Friedman
2fd19ed598 Err for comma after functional update syntax 2023-11-30 14:04:36 +02:00
Young-Flash
b46f37854e update: filter out syntax error in test 2023-11-30 19:35:25 +08:00
Miguel Ojeda
d3c9964c20 rustc_codegen_llvm: remove outdated count in comment
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30 12:27:19 +01:00
meowtec
4ca86edac9 Debug use cargo workspace root as cwd. fixes #13022 2023-11-30 19:21:59 +08:00
DianQK
c41bf96039
Add thinlto support to codegen, assembly and coverage tests 2023-11-30 18:48:03 +08:00
bors
665fd5219a Auto merge of #11872 - llogiq:test-attr-in-doctest, r=xFrednet
add lint against unit tests in doctests

During RustLab, Alice Ryhl brought to my attention that the Andoid team stumbled over the fact that if one attempts to write a unit test within a doctest, it will be summarily ignored. So this lint should help people wondering why their tests won't run.

---

changelog: New lint: [`test_attr_in_doctest`]
[#11872](https://github.com/rust-lang/rust-clippy/pull/11872)
2023-11-30 10:24:16 +00:00
Ralf Jung
7a661d048c Merge from rustc 2023-11-30 11:02:40 +01:00
Ralf Jung
76ec47782a Preparing for merge from rustc 2023-11-30 11:02:08 +01:00
bors
1670ff64bf Auto merge of #118473 - matthiaskrgr:rollup-q96bm3u, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #118452 (rustdoc-search: allow spaces around `::` in path query)
 - #118453 (Tweak message on ADT with private fields building)
 - #118456 (rustc_span: Remove unused symbols.)
 - #118458 (rustdoc: remove small from  `small-section-header`)
 - #118464 (Dispose llvm::TargetMachines prior to llvm::Context being disposed)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-30 09:45:59 +00:00
Matthias Krüger
640a43178e
Rollup merge of #118464 - wesleywiser:fix_dispose_ordering, r=Nilstrieb
Dispose llvm::TargetMachines prior to llvm::Context being disposed

If the TargetMachine is disposed after the Context is disposed, it can lead to use after frees in some cases.

I've observed this happening occasionally on code compiled for aarch64-pc-windows-msvc using `-Zstack-protector=strong` but other users have reported AVs from host aarch64-pc-windows-msvc compilers as well.

I was not able to extract a self-contained test case yet so there is no accompanying test.

Fixes #118462
2023-11-30 09:28:27 +01:00
Matthias Krüger
49fadeef59
Rollup merge of #118458 - notriddle:notriddle/small-section-header, r=GuillaumeGomez
rustdoc: remove small from  `small-section-header`

There's no such thing as a big section header, so I don't know why the name was used.
2023-11-30 09:28:26 +01:00
Matthias Krüger
e31cd931f6
Rollup merge of #118456 - aDotInTheVoid:unused-symbols, r=WaffleLapkin
rustc_span: Remove unused symbols.

As noted  here, there is no guarantee that all pre-interned symbols are used.

b10cfcd65f/compiler/rustc_span/src/symbol.rs (L124-L125)

This was done starting with using ripgrep to search for `sym::whatever`. I removed anything that didn't show up. However this had a huge number of false positives, due to extensive macro use. Then there was a manual phase of adding back all the ones used my macros.

I don't think this was worth my time to do, but it's done now . ¯\_(ツ)_/¯
2023-11-30 09:28:26 +01:00
Matthias Krüger
13ded66513
Rollup merge of #118453 - estebank:priv-fields, r=compiler-errors
Tweak message on ADT with private fields building

When trying to create an inaccessible ADT due to private fields, handle the case when no fields were passed.

```
error: cannot construct `Foo` with struct literal syntax due to private fields
  --> $DIR/issue-76077.rs:8:5
   |
LL |     foo::Foo {};
   |     ^^^^^^^^
   |
   = note: private field `you_cant_use_this_field` that was not provided
```
2023-11-30 09:28:25 +01:00
Matthias Krüger
e9a870d5eb
Rollup merge of #118452 - notriddle:coloncolonspace, r=GuillaumeGomez,jsha
rustdoc-search: allow spaces around `::` in path query

This restriction made sense back when spaces separated function parameters, but now that they separate path components, there's no real ambiguity any more.

Additionally, the Rust language allows it.

The other two commits are misc code cleanup.
2023-11-30 09:28:25 +01:00
bors
c52b8763bf Auto merge of #118408 - RalfJung:aggregate-assign-uninit, r=saethlin
miri: add test checking that aggregate assignments reset memory to uninit

Also, `write_aggregate` is really just a helper for evaluating `Aggregate` rvalues, so it should be in `step.rs`, not `place.rs`. Also factor out `Repeat` rvalues into their own function while we are at it.

r? `@saethlin`
Fixes https://github.com/rust-lang/miri/issues/3195
2023-11-30 07:49:49 +00:00
Nicholas Nethercote
b6d0493388 Inline and remove select_debuginfo_compression.
It's trivial and has a single callsite.
2023-11-30 17:28:33 +11:00
Nicholas Nethercote
20046ceb40 Sort PRINT_KINDS.
Alphabetical order is nicer than random order.
2023-11-30 17:28:29 +11:00
Nicholas Nethercote
24d4fe4cd9 Improve integer interning in default_configuration.
We have `sym::integer` for interning integers. Using it lets us use
symbols directy, and not have to explicitly go through strings.
2023-11-30 17:05:56 +11:00
Nicholas Nethercote
dba94164e9 Move is_ascii_ident to where it's used. 2023-11-30 17:05:56 +11:00
Nicholas Nethercote
f8ce1864d3 Update a comment.
Save analysis was removed a while ago.
2023-11-30 17:05:56 +11:00