Commit Graph

240440 Commits

Author SHA1 Message Date
bors
ec1f21cb04 Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116839 (Implement thread parking for xous)
 - #118265 (remove the memcpy-on-equal-ptrs assumption)
 - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`)
 - #118394 (Remove HIR opkinds)
 - #118398 (Add proper cfgs in std)
 - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context)
 - #118422 (Fix coroutine validation for mixed panic strategy)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 08:51:01 +00:00
bors
33e8232b82 Auto merge of #3196 - RalfJung:provenance-gc, r=RalfJung
explain tests that disable the provenance GC
2023-11-29 06:50:30 +00:00
Ralf Jung
1620865d78 explain tests that disable the provenance GC 2023-11-29 07:43:48 +01:00
bors
e9b7bf0114 Auto merge of #118434 - matthiaskrgr:rollup-k1upt8b, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #118342 (Dont suggest `!` for path in function call if it has generic args)
 - #118383 (Address unused tuple struct fields in the standard library)
 - #118401 (`rustc_ast_lowering` cleanups)
 - #118409 (format_foreign.rs: unwrap return Option value for `fn position`, as it always returns Some)
 - #118413 (Fix the issue of suggesting unwrap/expect for shorthand field)
 - #118425 (Update cargo)
 - #118429 (Fix a typo in a `format_args!` note)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 06:23:14 +00:00
Matthias Krüger
0687dcb056
Rollup merge of #118429 - cuviper:its-arguments, r=compiler-errors
Fix a typo in a `format_args!` note
2023-11-29 04:23:31 +01:00
Matthias Krüger
9c93effa77
Rollup merge of #118425 - weihanglo:update-cargo, r=weihanglo
Update cargo

7 commits in 9b13310ca596020a737aaa47daa4ed9ff8898a2f..26333c732095d207aa05932ce863d850fb309386
2023-11-24 16:20:51 +0000 to 2023-11-28 20:07:39 +0000
- docs: link to the packages lint table from the related workspace table (rust-lang/cargo#13057)
- Add more doc comments for gc changes. (rust-lang/cargo#13055)
- docs: Provide pointers for MSRV (rust-lang/cargo#13056)
- Fixed typo in SemVer Compatibility documentation page (rust-lang/cargo#13054)
- refactor: use custom error instead of anyhow (rust-lang/cargo#13050)
- review and remove ignored tests in rustfix (rust-lang/cargo#13047)
- docs: add doc comments for rustfix (rust-lang/cargo#13048)

r? ghost
2023-11-29 04:23:30 +01:00
Matthias Krüger
872753895f
Rollup merge of #118413 - chenyukang:yukang-fix-118145-unwrap-for-shorthand, r=compiler-errors
Fix the issue of suggesting unwrap/expect for shorthand field

Fixes #118145
2023-11-29 04:23:30 +01:00
Matthias Krüger
69e48d0f6e
Rollup merge of #118409 - klensy:position-opt, r=compiler-errors
format_foreign.rs: unwrap return Option value for `fn position`, as it always returns Some

Trivial cleanup.

It will be nice to have way to run exhaustiveness analysis on similar cases to see dead code.
2023-11-29 04:23:29 +01:00
Matthias Krüger
82eda5865a
Rollup merge of #118401 - nnethercote:rustc_ast_lowering, r=compiler-errors
`rustc_ast_lowering` cleanups

Just some cleanups I found while looking through this code.

r? `@spastorino`
2023-11-29 04:23:29 +01:00
Matthias Krüger
f8628a179d
Rollup merge of #118383 - shepmaster:unused-tuple-struct-field-cleanup-stdlib, r=m-ou-se
Address unused tuple struct fields in the standard library
2023-11-29 04:23:28 +01:00
Matthias Krüger
5e7f770a0d
Rollup merge of #118342 - compiler-errors:macro-generic-bang, r=estebank
Dont suggest `!` for path in function call if it has generic args

Fixes #118335
2023-11-29 04:23:28 +01:00
Matthias Krüger
e8d0c56331
Rollup merge of #118422 - tmiasko:mix, r=compiler-errors
Fix coroutine validation for mixed panic strategy

Validation introduced in #113124 allows `UnwindAction::Continue` and `TerminatorKind::Resume` to occur only in functions with ABI that can unwind. The function ABI depends on the panic strategy, which can vary across crates.

Usually MIR is built and validated in the same crate. The coroutine drop glue thus far was an exception. As a result validation could fail when mixing different panic strategies.

Avoid the problem by executing `AbortUnwindingCalls` along with the validation.

Fixes #116953.
2023-11-29 04:23:24 +01:00
Matthias Krüger
8cfdccf7c8
Rollup merge of #118419 - compiler-errors:await-span2, r=cjgillot
Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context

This PR does 2 things:
1. Refuses to lower `.await` or `yield` when we are outside of the right coroutine context for the operator. Instead, we lower to `hir::ExprKind::Err`, to silence subsequent redundant errors.
2. Reworks a bit of the span tracking in `LoweringContext` to fix a bad span when we have something like `let x = [0; async_fn().await]` where the `await` is inside of an anon const. The span for the "item" still kinda sucks, since it overlaps with the `await` span, but at least it's accurate.
2023-11-29 04:23:24 +01:00
Matthias Krüger
b7016ae205
Rollup merge of #118398 - mu001999:std/add_cfgs, r=thomcc
Add proper cfgs in std

Detected by #118257
2023-11-29 04:23:23 +01:00
Matthias Krüger
20473eba0b
Rollup merge of #118394 - nnethercote:rm-hir-Ops, r=cjgillot
Remove HIR opkinds

`hir::BinOp`, `hir::BinOpKind`, and `hir::UnOp` are identical to `ast::BinOp`, `ast::BinOpKind`, and `ast::UnOp`, respectively. This seems silly, so this PR removes the HIR ones. (A re-export lets the AST ones be referred to using a `hir::` qualifier, which avoids renaming churn.)

r? `@cjgillot`
2023-11-29 04:23:23 +01:00
Matthias Krüger
68d31b1906
Rollup merge of #118269 - compiler-errors:poly, r=wesleywiser
Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`

I did this recently with `FnSigs` and `PolyFnSigs` but didn't think to do it with `TraitRefs` and `PolyTraitRefs`.
2023-11-29 04:23:22 +01:00
Matthias Krüger
92a74e41b6
Rollup merge of #118265 - RalfJung:memcpy, r=cuviper
remove the memcpy-on-equal-ptrs assumption

One of the libc we support, musl, [defines `memcpy` with `restrict` pointers](https://git.musl-libc.org/cgit/musl/tree/src/string/memcpy.c#n5). This in fact matches the definition in the C standard. Calling that `memcpy` with overlapping pointers is clearly UB, who knows what the compiler did when optimizing this `memcpy` -- it certainly assumed source and destination to be disjoint.

Lucky enough, it does not seem like we actually need this assumption that `memcpy(p, p, n)` is always allowed. clang and GCC need it since they use `memcpy` to compile C assignments, but [we use memmove for similar code](https://godbolt.org/z/bcW85WYcM). There are no known cases where LLVM introduces calls to memcpy on equal pointers itself. (And if there were, that would be a soundness bug in rustc due to the musl issue mentioned above.)

This does mean we must make sure to never call the LLVM `memcpy` builtin on equal ranges even though the LangRef says that is allowed. Currently that is the case so we just need to make sure it remains the case. :) Cc `@rust-lang/opsem` `@rust-lang/wg-llvm`
2023-11-29 04:23:22 +01:00
Matthias Krüger
2eec51c27c
Rollup merge of #116839 - joboet:xous_thread_parking, r=m-ou-se
Implement thread parking for xous

This follows the pattern set by [the Windows parker](ddef56d5df/library/std/src/sys/windows/thread_parking.rs) when it uses keyed events. An atomic variable is used to track the state and optimize the fast path, while notifications are send via the ticktime server to block and unblock the thread.

ping `@xobs`
`@rustbot` label +T-libs +A-atomic
r? libs
2023-11-29 04:23:21 +01:00
Nadrieril
02e50f03bf Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
Nadrieril
a3838c8550 Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
bors
f440b5f0ea Auto merge of #118348 - Mark-Simulacrum:feature-code-size, r=compiler-errors
Cut code size for feature hashing

This locally cuts ~32 kB of .text instructions.

This isn't really a clear win in terms of readability. IMO the code size benefits are worth it (even if they're not necessarily present in the x86_64 hyperoptimized build, I expect them to translate similarly to other platforms). Ultimately there's lots of "small ish" low hanging fruit like this that I'm seeing that seems worth tackling to me, and could translate into larger wins in aggregate.
2023-11-29 02:45:36 +00:00
Josh Stone
b8cdd4338d Fix a typo in a format_args! note 2023-11-28 17:12:20 -08:00
Alona Enraght-Moony
69a79ce4de rustdoc: Move AssocItemRender and RenderMode to html::render.
They're only used for HTML, so it makes more sense for them to live
their.
2023-11-29 00:56:47 +00:00
bors
b1e56deada Auto merge of #114841 - bvanjoi:fix-114814, r=cuviper
add track_caller for arith ops

Fixes #114814

`#[track_caller]` is works, r? `@scottmcm`
2023-11-29 00:47:25 +00:00
yukang
3a4edf0a7f More fix on mismatched type suggestion for shorthand fields 2023-11-29 08:25:16 +08:00
Alona Enraght-Moony
6e956c0a38 Rename and add another test 2023-11-28 23:17:28 +00:00
bors
eaaf7e7f62 Auto merge of #3194 - saethlin:remove-gc-heuristics, r=RalfJung
Remove Stacked Borrows GC heuristics

Removing these has no impact on our benchmarks. I think I initially added these because they have a significant impact on runtime at shorter GC intervals. But both these heuristics result in undesirable memory growth in real programs, especially `modified_since_last_gc`. I didn't realize at the time that required state becomes garbage as a result of changes to _other_ allocations.

I think this nets even primarily because we get better heap reuse. With this change I see almost all the mmap calls coming from our diagnostics infrastructure go away. Not that there were many to start with, but it's an indicator that our memory locality has improved.

Before:
```
Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml"
  Time (mean ± σ):      4.046 s ±  0.087 s    [User: 3.952 s, System: 0.085 s]
  Range (min … max):    3.952 s …  4.139 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/invalidate/Cargo.toml"
  Time (mean ± σ):      6.271 s ±  0.073 s    [User: 6.206 s, System: 0.054 s]
  Range (min … max):    6.195 s …  6.365 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/mse/Cargo.toml"
  Time (mean ± σ):     570.3 ms ±   6.7 ms    [User: 505.5 ms, System: 61.8 ms]
  Range (min … max):   559.6 ms … 576.0 ms    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/serde1/Cargo.toml"
  Time (mean ± σ):      2.013 s ±  0.012 s    [User: 1.938 s, System: 0.069 s]
  Range (min … max):    1.994 s …  2.024 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/serde2/Cargo.toml"
  Time (mean ± σ):      4.155 s ±  0.082 s    [User: 4.078 s, System: 0.067 s]
  Range (min … max):    4.011 s …  4.211 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml"
  Time (mean ± σ):     541.5 ms ±   3.9 ms    [User: 477.3 ms, System: 60.0 ms]
  Range (min … max):   536.1 ms … 545.1 ms    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/unicode/Cargo.toml"
  Time (mean ± σ):      1.496 s ±  0.002 s    [User: 1.442 s, System: 0.050 s]
  Range (min … max):    1.494 s …  1.500 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/zip-equal/Cargo.toml"
  Time (mean ± σ):      2.190 s ±  0.043 s    [User: 2.109 s, System: 0.075 s]
  Range (min … max):    2.114 s …  2.215 s    5 runs

```
After:
```
Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml"
  Time (mean ± σ):      3.954 s ±  0.057 s    [User: 3.871 s, System: 0.075 s]
  Range (min … max):    3.912 s …  4.052 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/invalidate/Cargo.toml"
  Time (mean ± σ):      6.200 s ±  0.108 s    [User: 6.129 s, System: 0.060 s]
  Range (min … max):    6.072 s …  6.295 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/mse/Cargo.toml"
  Time (mean ± σ):     575.3 ms ±   9.3 ms    [User: 511.5 ms, System: 60.2 ms]
  Range (min … max):   558.9 ms … 580.8 ms    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/serde1/Cargo.toml"
  Time (mean ± σ):      1.966 s ±  0.007 s    [User: 1.903 s, System: 0.058 s]
  Range (min … max):    1.959 s …  1.974 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/serde2/Cargo.toml"
  Time (mean ± σ):      4.138 s ±  0.040 s    [User: 4.057 s, System: 0.072 s]
  Range (min … max):    4.110 s …  4.207 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml"
  Time (mean ± σ):     541.8 ms ±   5.6 ms    [User: 470.7 ms, System: 66.9 ms]
  Range (min … max):   535.6 ms … 549.1 ms    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/unicode/Cargo.toml"
  Time (mean ± σ):      1.490 s ±  0.021 s    [User: 1.424 s, System: 0.060 s]
  Range (min … max):    1.454 s …  1.505 s    5 runs

Benchmark 1: cargo miri run  --manifest-path "/home/ben/miri/bench-cargo-miri/zip-equal/Cargo.toml"
  Time (mean ± σ):      2.215 s ±  0.048 s    [User: 2.113 s, System: 0.072 s]
  Range (min … max):    2.183 s …  2.299 s    5 runs
```
2023-11-28 22:43:04 +00:00
Ben Kimock
8344dae333 Remove Stacked Borrows GC heuristics 2023-11-28 17:41:12 -05:00
bors
bbefc9837f Auto merge of #118412 - matthiaskrgr:rollup-ghzhti2, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #118193 (Add missing period in `std::process::Command` docs)
 - #118222 (unify read_to_end and io::copy impls for reading into a Vec)
 - #118323 (give dev-friendly error message for incorrect config profiles)
 - #118378 (Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto)
 - #118399 (Clean dead codes in miri)
 - #118410 (update test for new LLVM 18 codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-28 22:28:34 +00:00
Alona Enraght-Moony
9121a41450 ConstProp: Remove const when rvalue check fails. 2023-11-28 22:15:11 +00:00
Weihang Lo
9b85fc0d1c
Update cargo 2023-11-28 16:20:25 -05:00
Michael Goulet
d3404d2b98 Add with_opt_const_effect_param helper, simplify 2023-11-28 21:17:55 +00:00
Michael Goulet
89c2c85fe1 Add PartialEq<&B> for &A 2023-11-28 21:17:19 +00:00
Michael Goulet
82a9e872d8 Fix PartialEq args when #[const_trait] is enabled 2023-11-28 21:17:19 +00:00
Michael Goulet
dd5abb50cc Yeet E0744 2023-11-28 20:40:38 +00:00
Andre Bogus
0ba9bf9f9a add lint against unit tests in doctests 2023-11-28 21:29:08 +01:00
bors
57397a5190 Auto merge of #11363 - KisaragiEffective:fix_redundant_closure_call_on_closure_returns_async_block, r=llogiq
[`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block

close #11357

----

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block
2023-11-28 20:27:48 +00:00
Tomasz Miąsko
5161b22143 Fix coroutine validation for mixed panic strategy
Validation introduced in #113124 allows UnwindAction::Continue and
TerminatorKind::Resume to occur only in functions with ABI that can
unwind. The function ABI depends on the panic strategy, which can vary
across crates.

Usually MIR is built and validated in the same crate. The coroutine drop
glue thus far was an exception. As a result validation could fail when
mixing different panic strategies.

Avoid the problem by executing AbortUnwindingCalls along with the
validation.
2023-11-28 21:11:24 +01:00
Eduardo Sánchez Muñoz
6b066a9305 thir-unsafeck: print list of missing target features when calling a function with target features outside an unsafe block 2023-11-28 20:37:02 +01:00
Michael Goulet
f2c500bb43 Fix spans for bad await in inline const 2023-11-28 19:29:56 +00:00
Michael Goulet
a76d2e1fd1 Eagerly return ExprKind::Err on yield/await in wrong coroutine context 2023-11-28 19:29:56 +00:00
bors
91c5653a47 Auto merge of #11892 - y21:actually_rename_doc_for_real_this_time, r=Manishearth
rename `DocMarkdown` pass to `Documentation`

Followup of #11801

This was discussed in todays meeting: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202023-11-28/near/404667082

Decided to go with `Documentation`, because this would also make it consistent with how `Attributes` is named in `attrs.rs` (and it also sounds good).

changelog: none
2023-11-28 18:59:25 +00:00
y21
0565267f37 rename DocMarkdown to Documentation 2023-11-28 19:14:37 +01:00
Esteban Küber
55e4e3e393 Suggest let or == on typo'd let-chain
When encountering a bare assignment in a let-chain, suggest turning the
assignment into a `let` expression or an equality check.

```
error: expected expression, found `let` statement
  --> $DIR/bad-if-let-suggestion.rs:5:8
   |
LL |     if let x = 1 && i = 2 {}
   |        ^^^^^^^^^
   |
   = note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to continue the let-chain
   |
LL |     if let x = 1 && let i = 2 {}
   |                     +++
help: you might have meant to compare for equality
   |
LL |     if let x = 1 && i == 2 {}
   |                        +
```
2023-11-28 18:07:52 +00:00
Jake Goulding
115eac03bb Address unused tuple struct fields in the standard library 2023-11-28 12:00:54 -05:00
dfireBird
21c09eb544
update dot tests function with check_edit 2023-11-28 22:21:57 +05:30
dfireBird
5c0c8ceaf7
refactor complete_fn_fields function and correct branch checks 2023-11-28 22:21:57 +05:30
dfireBird
8296b16f38
fix the insertion of the surronding parens
Before it was inserting whenever function field is found but it should
happend only in the case of function call.
2023-11-28 22:21:57 +05:30
dfireBird
aa1cf8d357
add tests for tuple fields and expect fn type cases 2023-11-28 22:21:57 +05:30
dfireBird
eedeb58a4e
refactor obtaining receivers into idiomatic way
variable name change for clearer usage indication
2023-11-28 22:21:57 +05:30