Commit Graph

240279 Commits

Author SHA1 Message Date
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
yukang
9386e14401 fix the issue of suggest unwrap/expect for shorthand field 2023-11-28 23:36:58 +08:00
Alona Enraght-Moony
b1a6cf4a0e Precommit test for https://github.com/rust-lang/rust/issues/118328. 2023-11-28 15:12:46 +00:00
Matthias Krüger
4ca038f048
Rollup merge of #118410 - krasimirgg:llvm-18-test, r=nikic
update test for new LLVM 18 codegen

LLVM at HEAD now emits `or disjoint`: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/24076#018c1596-8153-488e-b622-951266a02f6c/741-774
2023-11-28 16:09:56 +01:00
Matthias Krüger
71b29e8a38
Rollup merge of #118399 - mu001999:miri/cleanup, r=RalfJung
Clean dead codes in miri

Detected by #118257
2023-11-28 16:09:56 +01:00
Matthias Krüger
3e202ead60
Rollup merge of #118378 - cormacrelf:bugfix/linker-plugin-lto-wasm, r=petrochenkov
Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto

Fixes (partially) #60059. Technically, `--target wasm32-unknown-unknown -Clinker-plugin-lto` would complete without errors before, but it was not producing optimized code. At least, it may have been but it was probably not the opt-level people intended.

Similarly to #118377, this could benefit from a warning about using an explicit libLTO path with LLD, which will ignore it and use its internal LLVM. Especially given we always use lld on wasm targets. I left the code open to that possibility rather than making it perfectly neat.
2023-11-28 16:09:55 +01:00
Matthias Krüger
8f4ccc14c9
Rollup merge of #118323 - onur-ozkan:better-error-for-incorrect-profiles, r=clubby789
give dev-friendly error message for incorrect config profiles

before this change, an incorrect profile would result in the following error:

```sh
...
...
  File "/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/bootstrap.py", line 1088, in bootstrap
    with open(include_path) as included_toml:
         ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/defaults/config.aaaa.toml'
```

with this change, the error message is now:

```sh
...
...
  File "/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/bootstrap.py", line 1088, in bootstrap
    raise Exception("Unrecognized profile '{}'. Check src/bootstrap/defaults"
Exception: Unrecognized profile 'aaaa'. Check src/bootstrap/defaults for available options.
```
2023-11-28 16:09:55 +01:00
Matthias Krüger
97ef5a3b53
Rollup merge of #118222 - the8472:copy-use-vec-write, r=m-ou-se
unify read_to_end and io::copy impls for reading into a Vec

This ports over the initial probe (to avoid allocation) and the dynamic read sizing from the io::copy specialization to the `default_read_to_end` implementation which already had its own optimizations for different cases.

I think it should be a best-of-both now.

suggested by `@a1phyr` in https://github.com/rust-lang/rust/pull/117576#issuecomment-1803408492
2023-11-28 16:09:54 +01:00
Matthias Krüger
b8e1194ab2
Rollup merge of #118193 - max-heller:command-typo, r=m-ou-se
Add missing period in `std::process::Command` docs
2023-11-28 16:09:54 +01:00
bors
5facb422f8 Auto merge of #118188 - petrochenkov:defeed, r=cjgillot
resolve: Feed the `def_kind` query immediately on `DefId` creation

Before this PR the def kind query required building HIR for no good reason, with this PR def kinds are instead assigned immediately when `DefId`s are created.

Some PRs previously refactored things to make all def kinds to be available early enough - https://github.com/rust-lang/rust/pull/118250, https://github.com/rust-lang/rust/pull/118272, https://github.com/rust-lang/rust/pull/118311.
2023-11-28 14:54:11 +00:00
Vadim Petrochenkov
84de641484 def collector: Set correct namespace in DefPathData for foreign types 2023-11-28 16:17:52 +03:00
Vadim Petrochenkov
f0dc906319 resolve: Feed the def_kind query immediately on DefId creation 2023-11-28 15:39:31 +03:00
bors
df0295f071 Auto merge of #110353 - the8472:in-place-flatten-chunks, r=cuviper
Expand in-place iteration specialization to Flatten, FlatMap and ArrayChunks

This enables the following cases to collect in-place:

```rust
let v = vec![[0u8; 4]; 1024]
let v: Vec<_> = v.into_iter().flatten().collect();

let v: Vec<Option<NonZeroUsize>> = vec![NonZeroUsize::new(0); 1024];
let v: Vec<_> = v.into_iter().flatten().collect();

let v = vec![u8; 4096];
let v: Vec<_> = v.into_iter().array_chunks::<4>().collect();
```

Especially the nicheful-option-flattening should be useful in real code.
2023-11-28 12:22:16 +00:00
Krasimir Georgiev
81cd7c5b11 update test for new LLVM 18 codegen
LLVM at HEAD now emits `or disjoint`: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/24076#018c1596-8153-488e-b622-951266a02f6c/741-774
2023-11-28 12:10:59 +00:00
klensy
de13a3871d unwrap return Option value, as it always returns Some for some fns 2023-11-28 14:52:21 +03:00
Ralf Jung
53eb910515 add test checking that aggregate assignments reset memory to uninit first 2023-11-28 11:40:17 +01:00
Ralf Jung
cabfe8f5dc move write_aggregate into step file, and also extract write_repeat into separate function 2023-11-28 11:40:17 +01:00
George Wort
e0bfb615da Name explicit registers in conflict register errors for inline assembly 2023-11-28 10:37:19 +00:00
bors
46a24ed2f4 Auto merge of #118405 - matthiaskrgr:rollup-3a2eevc, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #115331 (optimize str::iter::Chars::advance_by)
 - #118236 (Update mod comment)
 - #118299 (Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.)
 - #118314 (Rename `{collections=>alloc}{tests,benches}`)
 - #118341 (Simplify indenting in THIR printing)
 - #118366 (Detect and reject malformed `repr(Rust)` hints)
 - #118397 (Fix comments for unsigned non-zero `checked_add`, `saturating_add`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-28 10:21:41 +00:00
Matthias Krüger
4f3ee302b7
Rollup merge of #118397 - Zalathar:nonzero, r=WaffleLapkin
Fix comments for unsigned non-zero `checked_add`, `saturating_add`

While looking at #118313, I happened to notice that two of the expanded comments appear to be slightly inaccurate.

For these two methods, `other` is an ordinary unsigned integer, so it can be zero.

Since the sum of non-zero and zero is always non-zero, the safety argument holds even when `other` is zero.
2023-11-28 09:28:39 +01:00
Matthias Krüger
903789d606
Rollup merge of #118366 - fmease:detect-reject-malformed-rust-repr, r=compiler-errors
Detect and reject malformed `repr(Rust)` hints

Fixes #118334.
2023-11-28 09:28:38 +01:00
Matthias Krüger
4475a1220a
Rollup merge of #118341 - Mark-Simulacrum:shrink-thir-print, r=compiler-errors
Simplify indenting in THIR printing

This cuts >100kb from a local librustc_driver.so build, and seems just obviously simpler.
2023-11-28 09:28:38 +01:00
Matthias Krüger
7dbbffdc67
Rollup merge of #118314 - WaffleLapkin:rename_collectionstests, r=cuviper
Rename `{collections=>alloc}{tests,benches}`

The crate is named `alloc` so this makes more sense. Ig this is fallout from #42648?
2023-11-28 09:28:37 +01:00
Matthias Krüger
787f1a65df
Rollup merge of #118299 - frewsxcv:patch-2, r=cuviper
Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.
2023-11-28 09:28:37 +01:00
Matthias Krüger
4704d49629
Rollup merge of #118236 - ksw2000:update_mod_comment, r=cuviper
Update mod comment

The comment of `ASCII_CASE_MASK` on line 477  is `If 6th bit is set ascii is lower case.` but the original comment of `*self ^ ((self.is_ascii_lowercase() as u8) * ASCII_CASE_MASK)` was `Toggle the fifth bit if this is a lowercase letter`
2023-11-28 09:28:36 +01:00
Matthias Krüger
4af1f99740
Rollup merge of #115331 - the8472:chars_advance, r=cuviper
optimize str::iter::Chars::advance_by

```
OLD:
    str::iter::chars_advance_by_0001  0.00ns/iter  +/- 0.00ns
    str::iter::chars_advance_by_0010 13.00ns/iter  +/- 1.00ns
    str::iter::chars_advance_by_1000  1.20µs/iter +/- 15.00ns

NEW:
    str::iter::chars_advance_by_0001  0.00ns/iter +/- 0.00ns
    str::iter::chars_advance_by_0010  6.00ns/iter +/- 0.00ns
    str::iter::chars_advance_by_1000 75.00ns/iter +/- 1.00ns
```
2023-11-28 09:28:36 +01:00
bors
e06c94d6cb Auto merge of #118282 - fee1-dead-contrib:enforce-more, r=compiler-errors
effects: Run `enforce_context_effects` for all method calls

So that we also perform checks when overloaded `PartialEq`s are called.

r? `@compiler-errors`
2023-11-28 08:23:47 +00:00
Nicholas Nethercote
5c680e1bcb Remove unnecessary Option from LoweringContext::allow_{try_trait,gen_future}.
Also remove some unnecessary slicing.
2023-11-28 14:32:40 +11:00
Nicholas Nethercote
3bae9276fa Add LoweringContext::new. 2023-11-28 14:32:40 +11:00
Nicholas Nethercote
ed2868eb9d Create LoweringContext::lower_assoc_item.
By moving most of `ItemLowerer::lower_assoc_item` into it. This is
similar to `LoweringContext::lower_foreign_item`.
2023-11-28 14:32:40 +11:00