Commit Graph

244244 Commits

Author SHA1 Message Date
bors
1828461982 Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472
`HashMap`/`HashSet`: forward `fold` implementations of iterators

Use [rust-lang/hasbrown#480](https://github.com/rust-lang/hashbrown/pull/480) in `std`

Note: this needs a version bump of hashbrown before merging
2024-01-20 17:53:26 +00:00
David Tolnay
f6b3bcc431
Capture the rationale for -Zallow-features= in bootstrap.py 2024-01-20 09:47:53 -08:00
Georgiy Komarov
270f1510be
rustc_mir_dataflow: Add exports for external tools
Added back previously available exports:

* Forward/Backward: used when implementing `AnalysisDomain`
* Engine: used in user's code to solve the dataflow problem
* SwitchIntEdgeEffects: used when implementing functions of the `Analysis` trait
* graphviz: potentially useful for debugging purposes

These exports are used when implementing external tools based on MIR
dataflow framework.

Closes #120130
2024-01-20 14:42:27 -03:00
bors
a911652360 Auto merge of #16406 - davidsemakula:editorconfig, r=lnicola
internal: add `max_line_length` to `.editorconfig`

This helps with setting proper visual guides/rulers for the right margin in some editors/IDEs (e.g. CLion)
2024-01-20 16:24:02 +00:00
bors
d4926c10b2 Auto merge of #16405 - dfireBird:guarded-return-for-loop, r=lnicola
fix: Include `for` construct in convert to guarded return conditions
2024-01-20 16:13:31 +00:00
bors
159bdc1e93 Auto merge of #108359 - Zoxc:side-effects-tweak, r=cjgillot
Avoid code generation for ThinVec<Diagnostic>'s destructor in the query system

This avoids 2 instances of the destructor of `ThinVec<Diagnostic>` from being included in `execute_job`. It also outlines the cold branch in `store_side_effects` / `store_side_effects_for_anon_node`.
2024-01-20 15:20:15 +00:00
Nadrieril
796cdc590c Remove Ty: Copy bound 2024-01-20 15:22:14 +01:00
Michal Nazarewicz
755cfbf236 core: introduce split_at{,_mut}_checked
Introduce split_at_checked and split_at_mut_checked methods to slices
types (including str) which are non-panicking versions of split_at and
split_at_mut  respectively.  This is analogous to get method being
non-panicking version of indexing.
2024-01-20 15:18:31 +01:00
davidsemakula
5aa7583a0d add max_line_length to .editorconfig 2024-01-20 17:14:00 +03:00
dfireBird
721e79035d
include for in convert to guarded return assist 2024-01-20 19:26:50 +05:30
bors
6745c6000a Auto merge of #116185 - Zoxc:rem-one-thread, r=cjgillot
Remove `OneThread`

This removes `OneThread` by switching `incr_comp_session` over to `RwLock`.
2024-01-20 13:18:33 +00:00
jyn
c3e4c457fe Track verbose and verbose_internals
bjorn3 says:
> On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik.
Otherwise we would have to replay the query in question, which we may not be able to do if the query
key is not reconstructible from the dep node fingerprint.

So we must track these flags to avoid replaying incorrect diagnostics.
2024-01-20 08:00:09 -05:00
John Kåre Alsaker
862011e1ca Avoid code generation for ThinVec<Diagnostic>'s destructor in the query system 2024-01-20 13:43:05 +01:00
Guillaume Gomez
0933f48ac0 Add regression test for #119015 and update tests 2024-01-20 13:21:03 +01:00
Guillaume Gomez
6237bebd34 Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias 2024-01-20 12:38:13 +01:00
bors
227abacaef Auto merge of #120003 - Mark-Simulacrum:opt-promoted, r=davidtwco
perf: Don't track specific live points for promoteds

We don't query this information out of the promoted (it's basically a single "unit" regardless of the complexity within it) and this saves on re-initializing the SparseIntervalMatrix's backing IndexVec with mostly empty rows for all of the leading regions in the function. Typical promoteds will only contain a few regions that need up be uplifted, while the parent function can have thousands.

For a simple function repeating println!("Hello world"); 50,000 times this reduces compile times from 90 to 15 seconds in debug mode. The previous implementations re-initialization led to an overall roughly n^2 runtime as each promoted initialized slots for ~n regions, now we scale closer to linearly (5000 hello worlds takes 1.1 seconds).

cc https://github.com/rust-lang/rust/issues/50994, https://github.com/rust-lang/rust/issues/86244
2024-01-20 11:21:28 +00:00
bors
314384b5fb Auto merge of #120157 - matthiaskrgr:rollup-f0p3wkk, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #103730 (Added NonZeroXxx::from_mut(_unchecked)?)
 - #113142 (optimize EscapeAscii's Display  and CStr's Debug)
 - #118799 (Stabilize single-field offset_of)
 - #119613 (Expose Obligations created during type inference.)
 - #119752 (Avoid ICEs in trait names without `dyn`)
 - #120132 (Teach tidy about line/col information for malformed features)
 - #120135 (SMIR: Make the remaining "private" fields actually private)
 - #120148 (`single_use_lifetimes`: Don't suggest deleting lifetimes with bounds)
 - #120150 (Stabilize `round_ties_even`)
 - #120155 (Don't use `ReErased` to detect type test promotion failed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-20 09:23:09 +00:00
Matthias Krüger
bb816e67b4
Rollup merge of #120155 - compiler-errors:no-erased-when-promoting, r=aliemjay
Don't use `ReErased` to detect type test promotion failed

Using `ReErased` here is convenient because it implicitly stores the state that we are explicitly recording with the `failed` variable now, but I also think it adds a tiny bit of complexity that is not worth it.

r? `@aliemjay`
2024-01-20 09:37:30 +01:00
Matthias Krüger
862d3fe769
Rollup merge of #120150 - Jules-Bertholet:stabilize-round-ties-even, r=cuviper
Stabilize `round_ties_even`

Closes  #96710

`@rustbot` label -T-libs T-libs-api
2024-01-20 09:37:29 +01:00
Matthias Krüger
b7c2ba71c8
Rollup merge of #120148 - trevyn:issue-117965, r=cjgillot
`single_use_lifetimes`: Don't suggest deleting lifetimes with bounds

Closes #117965

```
9 |     pub fn get<'b: 'a>(&'b self) -> &'a str {
  |                ^^       -- ...is used only here
  |                |
  |                this lifetime...
```

In this example, I think the `&'b self` can be replaced with the bound itself, yielding `&'a self`, but this would require a deeper refactor. Happy to do as a follow-on PR if desired.
2024-01-20 09:37:28 +01:00
Matthias Krüger
409949bc23
Rollup merge of #120135 - oli-obk:smir_private, r=celinval
SMIR: Make the remaining "private" fields actually private

Turns out we have already created a trait that allows us to make the fields private: https://doc.rust-lang.org/nightly/nightly-rustc/stable_mir/ty/trait.IndexedVal.html

fixes https://github.com/rust-lang/project-stable-mir/issues/56

r? `@celinval`
2024-01-20 09:37:28 +01:00
Matthias Krüger
836bc69bd1
Rollup merge of #120132 - oli-obk:helpful_tidy, r=Mark-Simulacrum
Teach tidy about line/col information for malformed features

This makes it significantly easier to find the specific feature, since you can now just click it in the command line of your IDE
2024-01-20 09:37:27 +01:00
Matthias Krüger
177d51372c
Rollup merge of #119752 - estebank:ice-ice, r=fmease
Avoid ICEs in trait names without `dyn`

Check diagnostic is error before downgrading. Fix #119633.

 Account for traits using self-trait by name without `dyn`. Fix #119652.
2024-01-20 09:37:27 +01:00
Matthias Krüger
2de5ca25d2
Rollup merge of #119613 - gavinleroy:expose-obligations, r=lcnr
Expose Obligations created during type inference.

This PR is a first pass at exposing the trait obligations generated and solved for during the type-check progress. Exposing these obligations allows for rustc plugins to use the public interface for proof trees (provided by the next gen trait solver).

The changes proposed track *all* obligations during the type-check process, this is desirable to not only look at the trees of failed obligations, but also those of successfully proved obligations. This feature is placed behind an unstable compiler option `track-trait-obligations` which should be used together with the `next-solver` option. I should note that the main interface is the function `inspect_typeck` made public in `rustc_hir_typeck/src/lib.rs` which allows the caller to provide a callback granting access to the `FnCtxt`.

r? `@lcnr`
2024-01-20 09:37:26 +01:00
Matthias Krüger
6f67208d72
Rollup merge of #118799 - GKFX:stabilize-simple-offsetof, r=wesleywiser
Stabilize single-field offset_of

This PR stabilizes offset_of for a single field. There has been some further discussion at https://github.com/rust-lang/rust/issues/106655 about whether this is advisable; I'm opening the PR anyway so that the code is available.
2024-01-20 09:37:26 +01:00
Matthias Krüger
17c95b6330
Rollup merge of #113142 - the8472:opt-cstr-display, r=Mark-Simulacrum
optimize EscapeAscii's Display  and CStr's Debug

```
old:
    ascii::bench_ascii_escape_display_mixed      17.97µs/iter +/- 204.00ns
    ascii::bench_ascii_escape_display_no_escape 545.00ns/iter   +/- 6.00ns
new:
    ascii::bench_ascii_escape_display_mixed      4.99µs/iter +/- 56.00ns
    ascii::bench_ascii_escape_display_no_escape 91.00ns/iter  +/- 1.00ns
```
2024-01-20 09:37:25 +01:00
Matthias Krüger
f1713b0447
Rollup merge of #103730 - SOF3:nonzero-from-mut, r=Mark-Simulacrum,dtolnay
Added NonZeroXxx::from_mut(_unchecked)?

ACP: rust-lang/libs-team#129
Tracking issue: #106290
2024-01-20 09:37:24 +01:00
bors
0c764216d5 Auto merge of #16396 - Young-Flash:fix_marco, r=Veykril
fix panic with reference in macro

it panic at `builder.make_mut(segment)`, where segment is from macro expand. And the usage reference in orginal macro call isn't a `PathSegment` so we can't update it in `apply_references`, I can't find a way to deal with it properly so here just filter out the reference in macro. LMK if there are better way to fix this

try to close https://github.com/rust-lang/rust-analyzer/issues/16328
2024-01-20 08:12:44 +00:00
AngelicosPhosphoros
60208a0517 Tweak the threshold for chunked swapping
Thanks to 98892 for the tests I brought in here, as it demonstrated that 3×usize is currently suboptimal.
2024-01-19 23:00:34 -08:00
Young-Flash
f9b5e0d219 minor: use reference.range to get original range 2024-01-20 14:43:42 +08:00
bors
5378c1cf07 Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnr
Always use RevealAll for const eval queries

implements what is described in https://github.com/rust-lang/rust/pull/116803#discussion_r1364089471

Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types.

New tests are copied from https://github.com/rust-lang/rust/pull/101478
2024-01-20 04:57:51 +00:00
Josh Stone
33e0422826 Pack the u128 in LitKind::Int 2024-01-19 20:10:39 -08:00
Josh Stone
167555f36a Pack the u128 in SwitchTargets 2024-01-19 20:10:39 -08:00
Josh Stone
cb7d863e74 Add Pu128 = #[repr(packed(8))] u128 2024-01-19 20:10:38 -08:00
bors
128148d4cf Auto merge of #120136 - matthiaskrgr:rollup-3zzb0z9, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #117561 (Stabilize `slice_first_last_chunk`)
 - #117662 ([rustdoc] Allows links in headings)
 - #119815 (Format sources into the error message when loading codegen backends)
 - #119835 (Exhaustiveness: simplify empty pattern logic)
 - #119984 (Change return type of unstable `Waker::noop()` from `Waker` to `&Waker`.)
 - #120009 (never_patterns: typecheck never patterns)
 - #120122 (Don't add needs-triage to A-diagnostics)
 - #120126 (Suggest `.swap()` when encountering conflicting borrows from `mem::swap` on a slice)
 - #120134 (Restrict access to the private field of newtype indexes)

Failed merges:

 - #119968 (Remove unused/unnecessary features)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-20 02:58:08 +00:00
Michael Goulet
078a979229 Don't use ReErased to detect type test promotion failed 2024-01-20 02:35:08 +00:00
Mark Rousskov
c3364a23d2 perf: Don't track specific live points for promoteds
We don't query this information out of the promoted (it's basically a
single "unit" regardless of the complexity within it) and this saves on
re-initializing the SparseIntervalMatrix's backing IndexVec with mostly
empty rows for all of the leading regions in the function. Typical
promoteds will only contain a few regions that need up be uplifted,
while the parent function can have thousands.

For a simple function repeating println!("Hello world"); 50,000 times
this reduces compile times from 90 to 15 seconds in debug mode. The
previous implementations re-initialization led to an overall roughly n^2
runtime as each promoted initialized slots for ~n regions, now we scale
closer to linearly (5000 hello worlds takes 1.1 seconds).
2024-01-19 20:49:51 -05:00
bors
0547c41f90 Auto merge of #116672 - maurer:128-align, r=nikic
LLVM 18 x86 data layout update

With https://reviews.llvm.org/D86310 LLVM now has i128 aligned to 16-bytes on x86 based platforms. This will be in LLVM-18. This patch updates all our spec targets to be 16-byte aligned, and removes the alignment when speaking to older LLVM.

This results in Rust overaligning things relative to LLVM on older LLVMs.

This implements MCP https://github.com/rust-lang/compiler-team/issues/683.

See #54341
2024-01-20 00:56:53 +00:00
Esteban Küber
7edbc95c27 Update tests after rebase
Fix #119652.
2024-01-19 23:49:40 +00:00
Esteban Küber
6b7e6ea590 Account for traits using self-trait by name without dyn
Fix #119652.
2024-01-19 23:37:39 +00:00
Esteban Küber
b1688b48d2 Avoid ICE: Check diagnostic is error before downgrading
Fix #119633.
2024-01-19 23:36:20 +00:00
Jules Bertholet
b72af9fe9b
Stabilize round_ties_even 2024-01-19 18:05:53 -05:00
trevyn
de2575f35d Don't delete any lifetimes with bounds 2024-01-20 02:30:58 +04:00
The 8472
5796b3c167 fix: Drop guard was deallocating with the incorrect size
InPlaceDstBufDrop holds onto the allocation before the shrinking happens
which means it must deallocate the destination elements but the source
allocation.
2024-01-19 23:05:30 +01:00
SOFe
596410eb36
Assign tracking issue number for feature(nonzero_from_mut) 2024-01-19 13:53:13 -08:00
SOFe
3acb445f15
Added assert_unsafe_precondition! check for NonZeroXxx::from_mut_unchecked 2024-01-19 13:52:17 -08:00
SOFe
4459be7bd5
Added NonZeroXxx::from_mut(_unchecked)? 2024-01-19 13:50:24 -08:00
Michael Goulet
f2ef88ba06 Consolidate logic around resolving built-in coroutine trait impls 2024-01-19 21:28:37 +00:00
trevyn
0943a6b188 add test issue-117965 2024-01-20 01:22:52 +04:00
George Bateman
7924c9bcdf
Split remaining offset_of features into new tracking issues 2024-01-19 21:13:11 +00:00