Commit Graph

840 Commits

Author SHA1 Message Date
Taras Tsugrii
9ced089569 [rustc_data_structures] Use partition_point to find binary_search_slice end. 2023-07-29 19:42:22 -07:00
Taras Tsugrii
31fadf621b [rustc][data_structures] Simplify binary_search_slice. 2023-07-29 07:22:56 -07:00
Matthias Krüger
af2b370100 more clippy::style fixes:
get_first
single_char_add_str
unnecessary_mut_passed
manual_map
manual_is_ascii_check
2023-07-23 23:39:04 +02:00
Michael Woerister
457b787a52 Introduce ExtentUnord trait for collections that can safely consume UnordItems. 2023-07-14 10:10:15 +02:00
Michael Woerister
cfb310939b Enable potential_query_instability lint in rustc_hir_typeck.
Fix linting errors by using FxIndex(Map|Set) and Unord(Map|Set) as appropriate.
2023-07-14 10:10:14 +02:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Josh Stone
d9b1fa93c4 Upgrade to indexmap 2.0.0
The new version was already added to the tree as an indirect dependency
in #113046, but now our direct dependents are using it too.
2023-07-03 13:51:54 -07:00
Nicholas Nethercote
f2d863fa75 Remove SmallStr.
It no longer has any uses. If it's needed in the future, it can be
easily reinstated. Or a crate such as `smallstr` can be used, much like
we use `smallvec`.
2023-06-29 11:45:52 +10:00
Guillaume Gomez
a5561eb4d5
Rollup merge of #112538 - ndrewxie:issue-84447-partial-1, r=compiler-errors
Removed unnecessary &String -> &str, now that &String implements StableOrd as well

Applied a few nits suggested by lcnr to PR #110040 (nits can be found [here](https://github.com/rust-lang/rust/pull/110040#pullrequestreview-1469452191).)

Making a new PR because the old one was already merged, and given that this just applies changes that were already suggested, reviewing it should be fairly open-and-shut.
2023-06-21 20:00:49 +02:00
Camille GILLOT
7d5b2e4926 Make closure_saved_names_of_captured_variables a query. 2023-06-19 16:50:52 +00:00
Andrew Xie
0cac8455e6 Applied nits 2023-06-11 22:45:04 -04:00
Michael Goulet
80e9ca9398 Don't print Interned or PrivateZst 2023-06-09 00:20:37 +00:00
Andrew Xie
54d7b327e5 Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
Andrew Xie
f5f638c124 Fixed to_sorted => to_sorted_stable_ord 2023-06-05 00:16:20 -04:00
Andrew Xie
6f2d3dee17 Fixed unord mistake 2023-06-04 21:55:32 -04:00
Andrew Xie
96b577860d Fixed failing test + minor cleanup 2023-06-04 21:55:32 -04:00
Arlo Siemsen
4d9b476bb1 Update dependencies with reported vulnerabilities
bumpalo 3.12.1 (yanked)
  * updated to 3.13.0
tokio 1.8.4 - https://rustsec.org/advisories/RUSTSEC-2023-0001
  * updated to 1.28.2
remove_dir_all 0.5.3 - https://rustsec.org/advisories/RUSTSEC-2023-0018
  * removed by using the standard library function in `rust-installer` instead and updating to `tempfile@3.5.0` (which also removes the dependency).
2023-06-02 12:34:01 -05:00
bors
ad8304a0d5 Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot
diagnostics: exclude indirect private deps from trait impl suggest

Fixes #88696
2023-05-31 13:47:36 +00:00
John Kåre Alsaker
8abafd085a Add some comments 2023-05-28 15:54:52 +02:00
John Kåre Alsaker
5843858c01 Don't access self.mask with a single shard 2023-05-28 15:47:44 +02:00
John Kåre Alsaker
6620882089 Use only one shard with a single thread 2023-05-28 14:08:59 +02:00
Michael Howell
52bd82f522 rustc_data_structures: sync and atomic consistency
Co-authored-by: @lukas-code
2023-05-25 15:18:05 -07:00
Michael Howell
6a358960da rustc_metadata: specialize private_dep flag with fetch_and 2023-05-25 08:15:05 -07:00
Michael Howell
a12f50ddc4 rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
2023-05-25 08:15:04 -07:00
Matthias Krüger
a9743e108a
Rollup merge of #111875 - WaffleLapkin:defer_on_drop, r=Nilstrieb
Don't leak the function that is called on drop

It probably wasn't causing problems anyway, but still, a `// this leaks, please don't pass anything that owns memory` is not sustainable.

I could implement a version which does not require `Option`, but it would require `unsafe`, at which point it's probably not worth it.
2023-05-25 08:01:08 +02:00
Manish Goregaokar
d0b3ebee66
Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, r=petrochenkov
Use `Option::is_some_and` and `Result::is_ok_and` in the compiler

`.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable.

This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24 15:05:05 -07:00
bors
97d328012b Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiasko
Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of https://github.com/rust-lang/rust/pull/107157
cc `@tmiasko`
2023-05-24 16:18:21 +00:00
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
Maybe Waffle
e2b953063d Don't leak the function that is called on drop 2023-05-23 14:53:36 +00:00
bors
25f084d5e0 Auto merge of #111596 - cjgillot:dominator-bucket, r=Mark-Simulacrum
Process current bucket instead of parent's bucket when starting loop for dominators.

The linked paper by Georgiadis suggests in §2.2.3 to process `bucket[w]` when beginning the loop, instead of `bucket[parent[w]]` when finishing it.

In the test case, we correctly computed `idom[2] = 0` and `sdom[3] = 1`, but the algorithm returned `idom[3] = 1`, instead of the correct value 0, because of the path 0-7-2-3.

This provoked LLVM ICE in https://github.com/rust-lang/rust/pull/111061#issuecomment-1546912112. LLVM checks that SSA assignments dominate uses using its own implementation of Lengauer-Tarjan, and saw case where rustc was breaking the dominance property.

r? `@Mark-Simulacrum`
2023-05-20 07:41:15 +00:00
Camille GILLOT
7c8f29f02c Revert spurious changes. 2023-05-18 14:36:13 +00:00
Dylan DPC
ad214ac02b
Rollup merge of #111707 - nnethercote:rm-WorkerLocal-Vec, r=compiler-errors
Remove unused `impl<T> WorkerLocal<Vec<T>>`.

cc ``@SparrowLii`` ``@Zoxc``
2023-05-18 17:37:10 +05:30
Nicholas Nethercote
9bfb90b1be Remove unused impl<T> WorkerLocal<Vec<T>>. 2023-05-18 13:14:45 +10:00
Camille GILLOT
fa8598cb50 Merge DominatorTree and Dominators. 2023-05-17 10:37:29 +00:00
Camille GILLOT
4bbdb64016 Typo. 2023-05-17 10:29:12 +00:00
Camille GILLOT
ae318e3444 Remove outdated comment. 2023-05-17 10:26:04 +00:00
Tomasz Miąsko
aa1267f630 Preprocess dominator tree to answer queries in O(1) 2023-05-17 09:36:12 +00:00
Dylan DPC
2a5c4baf68
Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb
Share slice of bytes

r? `@Nilstrieb`
cc `@noamtashma`
2023-05-17 11:13:55 +05:30
Maybe Waffle
a6197a5dca Fixup comments 2023-05-16 12:09:24 +00:00
Maybe Waffle
e39d61cbf3 Remove MetadataRef type alias 2023-05-16 11:55:47 +00:00
Maybe Waffle
086c08d86a Switch OwnedSlice to use Lrc & remove Lrc from MetadataBlob 2023-05-16 11:43:27 +00:00
Maybe Waffle
2eef27a6c1 Merge MetadataRef type aliases 2023-05-16 11:43:25 +00:00
Camille GILLOT
84339a6f05 Process current bucket instead of parent's bucket when starting loop for dominators. 2023-05-15 16:16:34 +00:00
Tomasz Miąsko
f16d2b1629 Start node has no immediate dominator
Change the immediate_dominator return type to Option, and use None to
indicate that node has no immediate dominator.

Also fix the issue where the start node would be returned as its own
immediate dominator.
2023-05-14 16:09:58 +02:00
bors
dd8ec9c88d Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillot
Introduce `DynSend` and `DynSync` auto trait for parallel compiler

part of parallel-rustc #101566

This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency.

r? `@cjgillot`
2023-05-13 13:47:53 +00:00
Matthias Krüger
d075b6c16d
Rollup merge of #111393 - klensy:win-0.48, r=oli-obk
bump windows crate 0.46 -> 0.48

This drops duped version of crate(0.46), reduces `rustc_driver.dll` ~800kb and reduces exported functions number from 26k to 22k.

Also while here, added `tidy-alphabetical` sorting to lists in tidy allowed lists.
2023-05-12 07:11:12 +02:00
klensy
3c03cce341 bump windows crate 0.46 -> 0.48 in workspace 2023-05-09 18:20:13 +03:00
Dylan DPC
f748bb1402
Rollup merge of #111252 - matthewjasper:min-spec-improvements, r=compiler-errors
Min specialization improvements

- Don't allow specialization impls with no items, such implementations are probably not correct and only occur as mistakes in the compiler and standard library
- Fix a missing normalization call
- Adds spans for lifetime errors from overly general specializations

Closes #79457
Closes #109815
2023-05-09 12:33:46 +05:30
Nilstrieb
f2645776dc Use smaller ints for bitflags 2023-05-07 18:24:46 +02:00
SparrowLii
d7e3e5bede add DynSend / DynSync for CopyTaggedPtr 2023-05-06 10:23:51 +08:00
SparrowLii
bffccddac3 correct import of owned_slice 2023-05-06 09:34:55 +08:00
SparrowLii
089a38880b correct literals for dyn thread safe 2023-05-06 09:34:53 +08:00
SparrowLii
9f8ab2a8d3 rename relative names in sync 2023-05-06 09:34:24 +08:00
SparrowLii
f196e27d87 fix parallel! 2023-05-06 09:34:22 +08:00
SparrowLii
261b727d76 fix some nits 2023-05-06 09:34:21 +08:00
SparrowLii
b9746ce039 introduce DynSend and DynSync auto trait 2023-05-06 09:34:18 +08:00
Matthew Jasper
bd928a0b5e Disallow (min) specialization imps with no items
Such implementations are usually mistakes and are not used in the
compiler or standard library (after this commit) so forbid them with
`min_specialization`.
2023-05-05 16:19:18 +01:00
Ben Kimock
3c6d9ec77d Use the full Fingerprint when stringifying Svh 2023-04-30 14:28:30 -04:00
bors
c14882f74e Auto merge of #107782 - Zoxc:worker-local, r=cjgillot
Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures

This PR moves the definition of the `WorkerLocal` type from `rustc-rayon` into `rustc_data_structures`. This is enabled by the introduction of the `Registry` type which allows you to group up threads to be used by `WorkerLocal` which is basically just an array with an per thread index. The `Registry` type mirrors the one in Rayon and each Rayon worker thread is also registered with the new `Registry`. Safety for `WorkerLocal` is ensured by having it keep a reference to the registry and checking on each access that we're still on the group of threads associated with the registry used to construct it.

Accessing a `WorkerLocal` is micro-optimized due to it being hot since it's used for most arena allocations.

Performance is slightly improved for the parallel compiler:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.9992s</td><td align="right">1.9949s</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2977s</td><td align="right">0.2970s</td><td align="right"> -0.22%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.1335s</td><td align="right">1.1315s</td><td align="right"> -0.18%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.8235s</td><td align="right">1.8171s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.9047s</td><td align="right">6.8930s</td><td align="right"> -0.17%</td></tr><tr><td>Total</td><td align="right">12.1586s</td><td align="right">12.1336s</td><td align="right"> -0.21%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9977s</td><td align="right"> -0.23%</td></tr></table>

cc `@SparrowLii`
2023-04-27 17:43:09 +00:00
Matthias Krüger
b1ff6e3e10
Rollup merge of #110814 - WaffleLapkin:sprinkle_#inline, r=Nilstrieb
Sprinkle some `#[inline]` in `rustc_data_structures::tagged_ptr`

This is based on `nm --demangle (rustc +a --print sysroot)/lib/librustc_driver-*.so | rg CopyTaggedPtr` which shows many methods that should probably be inlined. May fix the regression in https://github.com/rust-lang/rust/pull/110795.

r? ```@Nilstrieb```
2023-04-27 15:10:53 +02:00
Matthias Krüger
8d00a8d11e
Rollup merge of #110615 - WaffleLapkin:impl_tag, r=cjgillot
Add `impl_tag!` macro to implement `Tag` for tagged pointer easily

r? `@Nilstrieb`

This should also lifts the need to think about safety from the callers (`impl_tag!` is robust (ish, see the macro issue)) and removes the possibility of making a "weird" `Tag` impl.
2023-04-25 21:06:33 +02:00
Maybe Waffle
bec7ce4824 Add #[inline] in impl_tag 2023-04-25 17:37:12 +00:00
Maybe Waffle
021a12c00d Sprinkle some #[inline] in rustc_data_structures::tagged_ptr 2023-04-25 17:30:05 +00:00
Yuki Okushi
a373623d55
Rollup merge of #110681 - klensy:cut-dep, r=lcnr
drop few unused crates, gate libc under unix for rustc_codegen_ssa

Small cleanup.
2023-04-25 02:33:29 +09:00
Maybe Waffle
2b8d27b402 Switch impl_tag! from explicit tags to ${index()} 2023-04-24 16:48:37 +00:00
Maybe Waffle
e496fbec92 Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
klensy
3338ee3ca7 drop unused deps, gate libc under unix for one crate 2023-04-22 15:22:21 +03:00
Maybe Waffle
ad8c7b6705 Simplify bits_for_tags impl 2023-04-20 19:54:10 +00:00
Maybe Waffle
7cfecf26f7 Remove confusing comment 2023-04-20 19:07:57 +00:00
Maybe Waffle
96905d568a Use impl Tag for $T syntax for impl_tag! 2023-04-20 18:49:40 +00:00
Maybe Waffle
77c83c0965 Add impl_tag! macro to implement Tag for tagged pointer easily 2023-04-20 17:14:32 +00:00
Maybe Waffle
f79df7d2a4 deny(unsafe_op_in_unsafe_fn) in rustc_data_structures 2023-04-19 18:00:48 +00:00
bors
b3f1379509 Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot
Encode hashes as bytes, not varint

In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash.

Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true`

Before:
```
(  1) 373418203 (53.7%, 53.7%): 1
(  2) 196240113 (28.2%, 81.9%): 3
(  3) 108157958 (15.6%, 97.5%): 2
(  4)  17213120 ( 2.5%, 99.9%): 4
(  5)    223614 ( 0.0%,100.0%): 9
(  6)    216262 ( 0.0%,100.0%): 10
(  7)     15447 ( 0.0%,100.0%): 5
(  8)      3633 ( 0.0%,100.0%): 19
(  9)      3030 ( 0.0%,100.0%): 8
( 10)      1167 ( 0.0%,100.0%): 18
( 11)      1032 ( 0.0%,100.0%): 7
( 12)      1003 ( 0.0%,100.0%): 6
( 13)        10 ( 0.0%,100.0%): 16
( 14)        10 ( 0.0%,100.0%): 17
( 15)         5 ( 0.0%,100.0%): 12
( 16)         4 ( 0.0%,100.0%): 14
```

After:
```
(  1) 372939136 (53.7%, 53.7%): 1
(  2) 196240140 (28.3%, 82.0%): 3
(  3) 108014969 (15.6%, 97.5%): 2
(  4)  17192375 ( 2.5%,100.0%): 4
(  5)       435 ( 0.0%,100.0%): 5
(  6)        83 ( 0.0%,100.0%): 18
(  7)        79 ( 0.0%,100.0%): 10
(  8)        50 ( 0.0%,100.0%): 9
(  9)         6 ( 0.0%,100.0%): 19
```

The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18 22:27:15 +00:00
Ben Kimock
073d99b25d
Add #[inline] to some new functions
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-04-18 14:13:19 -04:00
Ben Kimock
a04c09ade8 Document how the HashN types are different from Fingerprint 2023-04-18 10:52:47 -04:00
Ben Kimock
0445fbdd83 Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00
Guillaume Gomez
aa87addfb3
Rollup merge of #110417 - jsoref:spelling-compiler, r=Nilstrieb
Spelling compiler

This is per https://github.com/rust-lang/rust/pull/110392#issuecomment-1510193656

I'm going to delay performing a squash because I really don't expect people to be perfectly happy w/ my changes, I really am a human and I really do make mistakes.

r? Nilstrieb

I'm going to be flying this evening, but I should be able to squash / respond to reviews w/in a day or two.

I tried to be careful about dropping changes to `tests`, afaict only two files had changes that were likely related to the changes for a given commit (this is where not having eagerly squashed should have given me an advantage), but, that said, picking things apart can be error prone.
2023-04-18 14:50:51 +02:00
bors
74864fa496 Auto merge of #110481 - matthiaskrgr:rollup-phkkgm9, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109981 (Set commit information environment variables when building tools)
 - #110348 (Add list of supported disambiguators and suffixes for intra-doc links in the rustdoc book)
 - #110409 (Don't use `serde_json` to serialize a simple JSON object)
 - #110442 (Avoid including dry run steps in the build metrics)
 - #110450 (rustdoc: Fix invalid handling of nested items with `--document-private-items`)
 - #110461 (Use `Item::expect_*` and `ImplItem::expect_*` more)
 - #110465 (Assure everyone that `has_type_flags` is fast)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-18 05:28:44 +00:00
Matthias Krüger
41ae7fcf9b
Rollup merge of #110409 - Nilstrieb:some-manual-javascript-object-notationing, r=fee1-dead
Don't use `serde_json` to serialize a simple JSON object

This avoids `rustc_data_structures` depending on `serde_json` which allows it to be compiled much earlier, unlocking most of rustc.

This used to not matter, but after #110407 we're not blocked on fluent anymore, which means that it's now a blocking edge.
![image](https://user-images.githubusercontent.com/48135649/232313178-e0150420-3020-4eb6-98d3-fe5294a8f947.png)

This saves a few more seconds.

cc ````@Zoxc```` who added it recently
2023-04-18 06:44:46 +02:00
bors
386025117a Auto merge of #110410 - saethlin:hash-u128-as-u64s, r=oli-obk
Implement StableHasher::write_u128 via write_u64

In https://github.com/rust-lang/rust/pull/110367#issuecomment-1510114777 the cachegrind diffs indicate that nearly all the regression is from this:
```
22,892,558  ???:<rustc_data_structures::sip128::SipHasher128>::slice_write_process_buffer
-9,502,262  ???:<rustc_data_structures::sip128::SipHasher128>::short_write_process_buffer::<8>
```
Which happens because the diff for that perf run swaps a `Hash::hash` of a `u64` to a `u128`. But `slice_write_process_buffer` is a `#[cold]` function, and is for handling hashes of arbitrary-length byte arrays.

Using the much more optimizer-friendly `u64` path twice to hash a `u128` provides a nice perf boost in some benchmarks.
2023-04-18 03:11:18 +00:00
bors
7908a1d654 Auto merge of #110243 - WaffleLapkin:bless_tagged_pointers🙏, r=Nilstrieb
Tagged pointers, now with strict provenance!

This is a big refactor of tagged pointers in rustc, with three main goals:
1. Porting the code to the strict provenance
2. Cleanup the code
3. Document the code (and safety invariants) better

This PR has grown quite a bit (almost a complete rewrite at this point...), so I'm not sure what's the best way to review this, but reviewing commit-by-commit should be fine.

r? `@Nilstrieb`
2023-04-17 21:50:13 +00:00
Josh Soref
e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
bors
e49122fb1c Auto merge of #110367 - saethlin:no-truncations, r=oli-obk
Remove some suspicious cast truncations

These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang/rust#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
2023-04-17 09:38:31 +00:00
Ben Kimock
84facac97a Remove some unnecessary hash truncations 2023-04-16 20:05:02 -04:00
Ben Kimock
ad8d304163 Implement StableHasher::write_u128 via write_u64 2023-04-16 09:44:03 -04:00
Nilstrieb
7859a8e9a5 Don't use serde_json to serialize a simple JSON object
This avoids `rustc_data_structures` depending on `serde_json` which
allows it to be compiled much earlier, unlocking most of rustc.
2023-04-16 15:00:06 +02:00
Matthias Krüger
543f8bc38c fix clippy::toplevel_ref_arg and ::manual_map 2023-04-16 13:28:13 +02:00
John Kåre Alsaker
64474a40b0 Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures 2023-04-16 05:50:57 +02:00
Maybe Waffle
5571dd061d fix broken intradoclinks 2023-04-14 13:04:58 +00:00
Maybe Waffle
014c6f208e Use ptr::Alignment for extra coolness points 2023-04-14 12:31:49 +00:00
Maybe Waffle
36f5918bf1 Test CopyTaggedPtr's HashStable impl 2023-04-14 11:59:53 +00:00
Maybe Waffle
251f662e4d Share Tag2 impl between CopyTaggedPtr and TaggedPtr tests 2023-04-14 11:24:22 +00:00
Maybe Waffle
8d49e948a8 Doc fixes from review 2023-04-14 11:24:22 +00:00
Maybe Waffle
c155d5149f Implement Send/Sync for CopyTaggedPtr 2023-04-13 16:51:04 +00:00
Maybe Waffle
dc19dc29c9 doc fixes 2023-04-12 19:00:27 +00:00
Maybe Waffle
838c5491a4 Document tagged pointers better 2023-04-12 16:22:20 +00:00
Maybe Waffle
6f9b15c40c Add tests for tagged pointers 2023-04-12 16:20:34 +00:00
Maybe Waffle
5e4577ec65 Add TaggedPtr::set_tag 2023-04-12 12:35:43 +00:00
Maybe Waffle
6f64ae3fbc Move code around 2023-04-12 11:50:45 +00:00
Maybe Waffle
3df9a7bde3 Shorten COMPARE_PACKED => CP where it is not important
why can't I _ it :'(
2023-04-12 11:44:52 +00:00
Maybe Waffle
8f408202c3 Remove pointer_{ref,mut} from tagged pointers
Just use `deref{,_mut}`!
2023-04-12 11:41:41 +00:00
Maybe Waffle
c7c0b85f67 Make tagged pointers debug impls print the pointer
Does not really matter, but may be nicer in case
the pointer has some specific debug impl.
2023-04-12 11:30:45 +00:00
Maybe Waffle
c6acd5c92f Remove Pointer::with_ref in favour implementing it on tagged pointers directly 2023-04-12 11:26:34 +00:00
Maybe Waffle
9051331dd7 Lift Pointer's requirement for the pointer to be thin
fat pointers rule!
2023-04-12 11:00:35 +00:00
Maybe Waffle
26232f1ff5 Remove useless parameter from ghost 2023-04-12 10:34:29 +00:00
Maybe Waffle
ad92677008 Fix doc test 2023-04-11 21:45:19 +00:00
Maybe Waffle
12fd610e01 Refactor tagged ptr packing into a function 2023-04-11 21:40:39 +00:00
Maybe Waffle
3c6f4c1260 Bless tagged pointers (comply to strict provenance) 2023-04-11 21:31:23 +00:00
Maybe Waffle
f028636b1a Sprinkle some whitespace & uses 2023-04-11 19:33:33 +00:00
Maybe Waffle
c738dcc284 Add bits_for helper for tagged pointers & fixup docs 2023-04-11 19:18:59 +00:00
Maybe Waffle
a32959263c Use SSO_ARRAY_SIZE instead of 8 in SsoHashMap impl 2023-04-11 11:02:01 +00:00
Maybe Waffle
0465201f77 Use itertools::Either instead of own EitherIter impl 2023-04-11 11:02:01 +00:00
Nilstrieb
73417b1e15
Inline format_args
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09 23:29:39 +02:00
Nilstrieb
81c320ea77 Fix some clippy::complexity 2023-04-09 23:22:14 +02:00
Nilstrieb
0a0968b207 Allow modulo_one on function using cfg consts 2023-04-09 22:30:24 +02:00
Nilstrieb
f058d05fc2 Some simple clippy::perf fixes 2023-04-09 21:59:28 +02:00
bors
0f0dc29264 Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb
Yeet `owning_ref`

Based on the discussions from https://github.com/rust-lang/rust/pull/109948

This replaces `owning_ref` with a far simpler & safer abstraction.

Fixes #109974
2023-04-08 01:08:26 +00:00
Maybe Waffle
fbe0591c68 Mark OwnedSlice::{deref, borrow} as #[inline] 2023-04-07 10:14:50 +00:00
Maybe Waffle
2733c29bb1 Support multithreaded mode in OwnedSlice tests 2023-04-06 18:13:07 +00:00
Maybe Waffle
e0e39caf84 Add basic tests for OwnedSlice 2023-04-06 17:33:55 +00:00
Maybe Waffle
b6970d0e26 Use FnOnce for slice_owned instead of Fn 2023-04-06 17:03:42 +00:00
Nilstrieb
504c4c40e9 Add context to phantom comment 2023-04-05 18:55:55 +02:00
Thom Chiovoloni
9d314627aa Fix a couple missed hash constants 2023-04-05 15:48:37 +00:00
Thom Chiovoloni
bb0969cae0 Use SipHash-1-3 instead of SipHash-2-4 for StableHasher 2023-04-05 15:48:37 +00:00
Maybe Waffle
9405f586f5 Fix typo 2023-04-05 13:49:48 +00:00
Maybe Waffle
d7056548f9 Yeet owning_ref
Turns out
- `owning_ref` is unsound due to `Box` aliasing stuff
- `rustc` doesn't need 99% of the `owning_ref` API
- `rustc` can use a far simpler abstraction that is `OwnedSlice`
2023-04-05 13:49:48 +00:00
Maybe Waffle
c0ceefdfaf Use OwnedSlice instead of owning_ref 2023-04-05 13:49:48 +00:00
Maybe Waffle
689beda166 Implement OwnedSlice 2023-04-05 13:49:48 +00:00
Oli Scherer
457a162d00 Use elsa =1.7.1 as 1.8.0 was an accidental copy of 1.7.0 2023-04-05 08:07:29 +00:00
Oli Scherer
54214c8d8d Use a simpler atomic operation than the compare_exchange hammer 2023-04-04 09:01:44 +00:00
Oli Scherer
a1d20cf7a2 Another AppendOnlyVec 2023-04-04 09:01:44 +00:00
Oli Scherer
7edd1d8799 Replace another lock with an append-only vec 2023-04-04 09:01:44 +00:00
Oli Scherer
4699632637 Remove a lock in favor of an AppendOnlyVec 2023-04-04 09:01:44 +00:00
Oli Scherer
daee746771 Add a usize-indexed append-only-vec 2023-04-04 09:01:44 +00:00
Oli Scherer
aad33198ff Remove a fishy Clone impl 2023-04-04 09:01:44 +00:00
Scott McMurray
a2ee7592d6 Use &IndexSlice instead of &IndexVec where possible
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-02 17:35:37 -07:00
Michael Goulet
249198c1f8
Rollup merge of #109758 - nnethercote:parallel-cleanups, r=cjgillot
Parallel compiler cleanups

A few small improvements I found while looking closely at this code.

r? `@cjgillot`

cc `@Zoxc,` `@SparrowLii`
2023-03-30 12:42:21 -07:00
Nicholas Nethercote
44bfb6538e CacheAligned and Sharded don't need to derive Clone. 2023-03-30 21:14:43 +11:00
Nicholas Nethercote
0ccb60096a Remove RwLock::clone_guard.
It's unused.
2023-03-30 21:14:43 +11:00
Nicholas Nethercote
eeb5b782a6 Improve the rustc_data_structures::sync module doc comment.
Also, `MTRef<'a, T>` is a typedef for a reference to a `T`, but in
practice it's only used (and useful) in combination with `MTLock`, i.e.
`MTRef<'a, MTLock<T>>`. So this commit changes it to be a typedef for a
reference to an `MTLock<T>`, and renames it as `MTLockRef`. I think this
clarifies things, because I found `MTRef` quite puzzling at first.
2023-03-30 21:14:37 +11:00
Trevor Gross
dc4ba57566 Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
John Kåre Alsaker
27c44d2e28 Update indexmap and rayon crates 2023-03-25 02:12:13 +01:00
Matthias Krüger
acd7f878ae
Rollup merge of #107718 - Zoxc:z-time, r=nnethercote
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes`

This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
2023-03-23 19:55:43 +01:00
Dylan DPC
70918ecf06
Rollup merge of #109280 - compiler-errors:no-vec-map, r=Mark-Simulacrum
Remove `VecMap`

Not sure what the use of this data structure is over just using `FxIndexMap` or a `Vec`.

r? ```@ghost```
2023-03-23 00:00:32 +05:30
John Kåre Alsaker
6c57dda44d Remove unique and move VerboseTimingGuard fields into a new struct 2023-03-21 18:41:45 +01:00
John Kåre Alsaker
f60d2eb6c1 Add -Z time-passes-format to allow specifying a JSON output for -Z time-passes 2023-03-21 18:18:25 +01:00
Andy Russell
bb7c373fdf
migrate compiler, bootstrap, and compiletest to windows-rs 2023-03-20 13:19:35 -04:00
Michael Goulet
6639538575 Remove VecMap 2023-03-17 20:49:28 +00:00
The 8472
7cce618d18 Fast path that skips over unchanged obligations in process_obligations
- only borrow the refcell once per loop
- avoid complex matches to reduce branch paths in the hot loop
- use a by-ref fast path that avoids mutations at the expense of having false negatives
2023-03-17 19:56:03 +01:00
Matthias Krüger
a95943b77d
Rollup merge of #108887 - nnethercote:rename-MapInPlace, r=lqd
Rename `MapInPlace` as `FlatMapInPlace`.

After removing the `map_in_place` method, which isn't much use because modifying every element in a collection such as a `Vec` can be done trivially with iteration.

r? ``@lqd``
2023-03-08 21:24:53 +01:00
bors
9b60e6c68f Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholk
Do not implement HashStable for HashSet (MCP 533)

This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order.

The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-08 06:07:11 +00:00
Nicholas Nethercote
be60bcb28a Rename MapInPlace as FlatMapInPlace.
After removing the `map_in_place` method, which isn't much use because
modifying every element in a collection such as a `Vec` can be done
trivially with iteration.
2023-03-08 15:53:56 +11:00
bors
70adb4e5b4 Auto merge of #108709 - matthiaskrgr:rollup-j2tjbyx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104549 (add -Zexport-executable-symbols to unstable book)
 - #108292 (Label opaque type for 'captures lifetime' error message)
 - #108540 (Add `Atomic*::from_ptr`)
 - #108634 (Add link to component dashboard)
 - #108647 (Remove dead pgo.sh file)
 - #108678 (Use `Option::as_slice` where applicable)
 - #108681 (Improve comments in `needs_process_obligation`.)
 - #108688 (Match unmatched backticks in library/)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-03 22:45:58 +00:00
Matthias Krüger
37bd50eddd
Rollup merge of #108681 - nnethercote:needs_process_obligation-comments, r=lqd
Improve comments in `needs_process_obligation`.

And a couple of other places.

r? `@lqd`
2023-03-03 20:45:02 +01:00
est31
ef658907a5 Match end user facing unmatched backticks in compiler/ 2023-03-03 08:39:36 +01:00
Nicholas Nethercote
3bcea5f979 Improve comments in needs_process_obligation.
And a couple of other places.
2023-03-03 09:59:33 +11:00
Michael Woerister
b79f0261f8 Do not implement HashStable for HashSet. 2023-03-01 10:20:45 +01:00
Michael Woerister
422208ae52 Use UnordSet instead of FxHashSet for names_imported_by_glob_use query. 2023-03-01 10:20:43 +01:00
Jesse Bakker
edf053036f Add contains_key to SortedIndexMultiMap 2023-02-28 17:15:00 +01:00
Nicholas Nethercote
d78ca52450 Upgrade ena to 0.14.1.
To get the small performance improvements from
https://github.com/rust-lang/ena/pull/43.
2023-02-24 08:53:27 +11:00
bors
bd4a96a12d Auto merge of #108300 - oli-obk:elsa, r=eholk
Use a lock-free datastructure for source_span

follow up to the perf regression in https://github.com/rust-lang/rust/pull/105462

The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
2023-02-22 08:44:30 +00:00
Matthias Krüger
314fe4d170
Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
Better debug logs for borrowck constraint graph

It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
2023-02-21 23:01:58 +01:00
b-naber
8252a6eddf address review 2023-02-21 21:54:53 +00:00
Oli Scherer
decfb4d123 Use a lock-free datastructure for source_span 2023-02-21 08:38:24 +00:00
Nicholas Nethercote
06228d6e93 Upgrade thin-vec from 0.2.9 to 0.2.12.
Because 0.2.10 added supports for `ThinVec::splice`, and 0.2.12 is the
latest release.
2023-02-21 11:51:55 +11:00
b-naber
e2bf960fe1 sccs info 2023-02-19 22:12:12 +00:00
Maybe Waffle
8751fa1a9a if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
Alan Egerton
26e3363c51
Refactor refcounted structural_impls via functors 2023-02-14 12:14:58 +00:00
Vadim Petrochenkov
b62b82aef4 Resolve documentation links in rustc and store the results in metadata
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584

It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-10 09:34:13 +04:00
John Kåre Alsaker
9539737008 Make an optimal cold path for query_cache_hit 2023-02-06 15:22:12 +01:00
John Kåre Alsaker
e60ccfc6a9 Don't inline query_cache_hit to reduce code size of the query hot path. 2023-02-06 13:52:17 +01:00
David Tolnay
9e1c600f74
Disallow impl autotrait for trait object 2023-02-03 08:33:40 -08:00
bors
dc1d9d50fb Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
Bump bootstrap compiler to 1.68

This also changes our stage0.json to include the rustc component for the rustfmt pinned nightly toolchain, which is currently necessary due to rustfmt dynamically linking to that toolchain's librustc_driver and libstd.

r? `@pietroalbini`
2023-01-31 19:24:29 +00:00
Mark Rousskov
652f79e835 Download rustc component for rustfmt toolchain as well 2023-01-31 10:29:33 -05:00
bors
3cdd0197e7 Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
Matthias Krüger
3c145ff283
Rollup merge of #107168 - Nilstrieb:if-a-tait-falls-in-the-forest,can-we-know-it-wasnt-revealed, r=oli-obk
Use a type-alias-impl-trait in `ObligationForest`
2023-01-26 15:02:21 +01:00
Bryan Garza
1bbd655888 Improve efficiency of has_back_edge(...) 2023-01-24 00:01:37 +00:00
Bryan Garza
f9982ea24a Add comment on cause of panic in dominators algorithm 2023-01-23 23:56:22 +00:00
Yuki Okushi
eae7f947b5
Rollup merge of #107153 - tmiasko:dominates, r=oli-obk
Consistently use dominates instead of is_dominated_by

There is a number of APIs that answer dominance queries. Previously they were named either "dominates" or "is_dominated_by". Consistently use the "dominates" form.

No functional changes.
2023-01-23 19:30:02 +09:00
Nilstrieb
f74ca88384 Use a type-alias-impl-trait in ObligationForest 2023-01-21 20:13:56 +01:00
bors
005fc0f00f Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obk
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc)

This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble.

The changes required are moderate but non-zero:
- In some places the collections are extracted into sorted vecs.
- There are a few instances where for-loops have been changed to extends.

~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~

Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)).

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

r? `@ghost`
2023-01-21 14:18:17 +00:00
Tomasz Miąsko
955e7fbb16 Consistently use dominates instead of is_dominated_by
There is a number of APIs that answer dominance queries. Previously they
were named either "dominates" or "is_dominated_by". Consistently use the
"dominates" form.

No functional changes.
2023-01-21 12:15:02 +01:00
bors
21f6839352 Auto merge of #106976 - tmiasko:borrowck-lazy-dominators, r=cjgillot
Lazy dominator tree construction in borrowck

Motivated by the observation that sometimes constructed dominator tree was never queried.
2023-01-21 11:02:29 +00:00
bors
56ee85274e Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb
Remove some `ref` patterns from the compiler

Previous PR: https://github.com/rust-lang/rust/pull/105368

r? `@Nilstrieb`
2023-01-20 04:52:28 +00:00
Michael Woerister
f219771961 Clean up and document unord collections a bit. 2023-01-19 17:37:59 +01:00
Guillaume Gomez
dee88e0fa2
Rollup merge of #107037 - tmiasko:rank, r=oli-obk
Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-19 11:19:36 +01:00
Michael Woerister
72ee14ce39 Allow for more efficient sorting when exporting Unord collections. 2023-01-19 10:40:54 +01:00
Michael Woerister
c3d2573120 Use UnordMap instead of FxHashMap in define_id_collections!(). 2023-01-19 10:40:47 +01:00
Michael Woerister
8a1de57a4a Use UnordSet instead of FxHashSet in define_id_collections!(). 2023-01-19 10:19:07 +01:00
Scott McMurray
7d57685682 Also remove #![feature(control_flow_enum)] where possible 2023-01-18 10:22:21 -08:00
Tomasz Miąsko
b8c5821ad8 Fix Dominators::rank_partial_cmp to match documentation
The only use site is also updated accordingly and there is no change in
end-to-end behaviour.
2023-01-18 17:11:43 +01:00
Scott McMurray
925dc37313 Stop using BREAK & CONTINUE in compiler
Switching them to `Break(())` and `Continue(())` instead.

libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17 23:17:51 -08:00
Tomasz Miąsko
7fe68571fa Lazy dominator tree construction in borrowck
Motivated by the observation that sometimes constructed dominator tree
was never queried.
2023-01-17 22:00:41 +01:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Maybe Waffle
fc6cda8603 rustc_data_structures: remove ref patterns and other artifacts of the past 2023-01-17 07:48:19 +00:00
Jakob Degen
f49126e3d6 Document wf constraints on control flow in cleanup blocks
Also fixes a bug in dominator computation
2023-01-16 14:51:33 -08:00
Oli Scherer
58782a8842 Harden the pre-tyctxt query system against accidental recomputation 2023-01-12 09:26:28 +00:00
nils
fd7a159710 Fix uninlined_format_args for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Nilstrieb
e1787f5572 Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with
the alternate (`#`) flag. This commit reduces the amount of noisy
newlines by forcing a few small key types to stay on one line, which
makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
2023-01-02 20:15:48 +01:00
KaDiWa
7b371d2ad9
fix some typos 2022-12-25 00:43:50 +01:00
Matthias Krüger
d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
Chris Denton
b859b8b62b
Bump cfg-if to 1.0 2022-12-20 13:03:45 +00:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Matthias Krüger
de59844c98 more clippy::complexity fixes 2022-12-15 00:09:10 +01:00
Matthias Krüger
2ea368e53c minor code cleanups 2022-12-12 19:49:53 +01:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Matthias Krüger
db416ea195
Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiser
Put all cached values into a central struct instead of just the stable hash

cc `@nnethercote`

this allows re-use of the type for Predicate without duplicating all the logic for the non-hash cached fields
2022-12-06 16:54:52 +01:00
bors
9db224fc90 Auto merge of #105175 - michaelwoerister:add-stable-ord-trait, r=nagisa
Add StableOrd trait as proposed in MCP 533.

The `StableOrd` trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.

See https://github.com/rust-lang/compiler-team/issues/533 for more information.
2022-12-06 09:21:49 +00:00
Michael Woerister
56aacb245c StableOrd: Address review comments. 2022-12-05 10:45:31 +01:00
bors
b8a52e3a4b Auto merge of #105218 - matthiaskrgr:rollup-8d3k08n, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104199 (Keep track of the start of the argument block of a closure)
 - #105050 (Remove useless borrows and derefs)
 - #105153 (Create a hacky fail-fast mode that stops tests at the first failure)
 - #105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`)
 - #105193 (Disable coverage instrumentation for naked functions)
 - #105200 (Remove useless filter in unused extern crate check.)
 - #105201 (Do not call fn_sig on non-functions.)
 - #105208 (Add AmbiguityError for inconsistent resolution for an import)
 - #105214 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-03 21:25:45 +00:00
Matthias Krüger
1a2f79b82c
Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514
Remove useless borrows and derefs

They are nothing more than noise.
<sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-03 17:37:42 +01:00
bors
cab4fd678c Auto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiser
Rewrite LLVM's archive writer in Rust

This allows it to be used by other codegen backends.

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1155
2022-12-03 15:07:39 +00:00
Michael Woerister
3a58309798 Add StableOrd trait as proposed in MCP 533.
The StableOrd trait can be used to mark types as having a stable
sort order across compilation sessions. Collections that sort their
items in a stable way can safely implement HashStable by
hashing items in sort order.
2022-12-02 15:19:30 +01:00
Maybe Waffle
083ef45458 rustc_data_structures deref in a more humane way 2022-12-01 17:34:45 +00:00
Maybe Waffle
f2b97a8bfe Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
Vadim Petrochenkov
1f259ae679 rustc_hir: Change representation of import paths to support multiple resolutions 2022-12-01 18:51:05 +03:00
Oli Scherer
87a04f51ba move WithCachedTypeInfo to rustc_type_ir 2022-11-30 12:17:13 +00:00
Oli Scherer
3d31e5c981 s/WithStableHash/WithCachedTypeInfo/ 2022-11-30 12:11:19 +00:00
Neutron3529
11525e506e
fix document
https://users.rust-lang.org/t/is-the-document-in-sortedmap-in-rustc-data-structures-sorted-map-correct/84939

SortedMap have `O(n)` insertions and removal rather than `O(log(n))`
2022-11-28 18:31:55 +08:00
bjorn3
be6708428f Rewrite LLVM's archive writer in Rust
This allows it to be used by other codegen backends
2022-11-26 19:35:32 +00:00
bors
becc24a23a Auto merge of #97870 - eggyal:inplace_fold_spec, r=wesleywiser
Use liballoc's specialised in-place vec collection

liballoc already specialises in-place vector collection, so manually
reimplementing it in `IdFunctor::try_map_id` was superfluous.
2022-11-19 02:28:47 +00:00
Camille GILLOT
9d86e6abaf Use the interned stable hash as plain hash. 2022-11-11 13:02:37 +00:00
Camille GILLOT
d47424b833 Hash spans when interning. 2022-11-11 13:02:37 +00:00
Mateusz Mikuła
d5899efbda Update several crates for improved support of the new targets
This helps with `*-windows-gnullvm` targets
2022-11-05 12:19:55 +01:00
Matthias Krüger
d976a29c30
Rollup merge of #103845 - camsteffen:data-structures-track-caller, r=compiler-errors
Add track_caller to some Lock methods

Would have helped to diagnose #103844.
2022-11-04 12:18:01 +01:00
Michael Howell
03968a802c rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
Cameron Steffen
10a5e75537 Add track_caller to some Lock methods 2022-11-01 12:28:14 -05:00
Michael Woerister
9117ea9758 Introduce UnordMap, UnordSet, and UnordBag (see MCP 533)
MCP 533: https://github.com/rust-lang/compiler-team/issues/533

Also, as an example, substitute UnordMap for FxHashMap in
used_trait_imports query result.
2022-10-27 13:23:26 +00:00
Rageking8
62a2a1d257 fix some typos 2022-10-21 18:04:00 +08:00
bors
4b8f431995 Auto merge of #103214 - Nilstrieb:set-theory, r=petrochenkov
Use Set instead of Vec in transitive_relation

Helps with #103195. It doesn't fix the underlying quadraticness but it makes it _a lot_ faster to an extent where even doubling the amount of nested references still takes less than two seconds (50s on nightly).

I want to see whether this causes regressions (because the vec was usually quite small) or improvements (as lookup for bigger sets is now much faster) in real code.
2022-10-19 13:53:06 +00:00
nils
d45f025c90
Use Set instead of Vec in transitive_relation 2022-10-19 12:50:28 +02:00
bors
98a5ac269c Auto merge of #102543 - daym:patch-1, r=joshtriplett
Remove "execute" bit from lock file permissions

Previously, flock would set the "execute" bit on Rust lock files. That makes no sense.

This patch clears the "execute" bit on Rust lock files.

See issue #102531.
2022-10-18 02:04:24 +00:00
Danny Milosavljevic
e07e5104fe Remove execute bit from lock file permissions 2022-10-17 21:10:46 +02:00
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Matthias Krüger
42df0a580f
Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwco
Remove `-Ztime`

Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups.

Best reviewed one commit at a time.

r? `@davidtwco`
2022-10-06 16:29:45 +02:00
Nicholas Nethercote
4e8faff3a1 Be consistent about deciding whether to print pass data.
`print_time_passes_entry` unconditionally prints data about a pass. The
most commonly used call site, in `VerboseTimingGuard::drop`, guards it
with a `should_print_passes` test. But there are a couple of other call
sites that don't do that test.

This commit moves the `should_print_passes` test within
`print_time_passes_entry` so that all passes are treated equally.
2022-10-06 15:50:10 +11:00
Nicholas Nethercote
9110d925d0 Remove -Ztime option.
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used
`-Ztime-passes` for years but only recently learned about `-Ztime`.

What's the difference? Let's look at the `-Zhelp` output:
```
  -Z        time=val -- measure time of rustc processes (default: no)
  -Z time-passes=val -- measure time of each rustc pass (default: no)
```
The `-Ztime-passes` description is clear, but the `-Ztime` one is less so.
Sounds like it measures the time for the entire process?

No. The real difference is that `-Ztime-passes` prints out info about passes,
and `-Ztime` does the same, but only for a subset of those passes. More
specifically, there is a distinction in the profiling code between a "verbose
generic activity" and an "extra verbose generic activity". `-Ztime-passes`
prints both kinds, while `-Ztime` only prints the first one. (It took me
a close reading of the source code to determine this difference.)

In practice this distinction has low value. Perhaps in the past the "extra
verbose" output was more voluminous, but now that we only print stats for a
pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also,
a lot of the "extra verbose" cases are for individual lint passes, and you need
to also use `-Zno-interleave-lints` to see those anyway.

Therefore, this commit removes `-Ztime` and the associated machinery. One thing
to note is that the existing "extra verbose" activities all have an extra
string argument, so the commit adds the ability to accept an extra argument to
the "verbose" activities.
2022-10-06 15:49:44 +11:00
Nicholas Nethercote
eea06de0c8 Fix some comments.
- It's `--print`, not `--prints`.
- `-Ztime` and `-Ztime-passes` print to stderr, not stdout.
2022-10-06 14:22:12 +11:00
bors
0152393048 Auto merge of #99324 - reez12g:issue-99144, r=jyn514
Enable doctests in compiler/ crates

Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
Camille GILLOT
9f2ab5b9ad Use a SortedMap instead of a VecMap. 2022-10-01 16:24:30 +02:00
Camille GILLOT
d08669c4fa Compute by owner instead of HirId. 2022-10-01 16:22:40 +02:00
reez12g
9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Dylan DPC
d5ae6737bf
Rollup merge of #102037 - jyn514:normalize-docs, r=lcnr
Make cycle errors recoverable

In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation.

In the past, ```@jackh726``` has said we need to be careful about overflow errors: https://github.com/rust-lang/rust/pull/91430#issuecomment-983997013

> Off the top of my head, we definitely should be careful about treating overflow errors the same as
"not implemented for some reason" errors. Otherwise, you could end up with behavior that is
different depending on recursion depth. But, that might be context-dependent.

But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered.

Helps with https://github.com/rust-lang/rust/issues/81091.

r? ```@lcnr``` cc ```@matthewjasper```
2022-09-22 18:25:53 +05:30
Joshua Nelson
1512ce5925 Make cycle errors recoverable
In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation.

In the past, `@jackh726` has said we need to be careful about overflow errors:

> Off the top of my head, we definitely should be careful about treating overflow errors the same as
"not implemented for some reason" errors. Otherwise, you could end up with behavior that is
different depending on recursion depth. But, that might be context-dependent.

But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered.
2022-09-19 22:14:40 -05:00
Joshua Nelson
749dec6451 Make OUT an associated type instead of a generic parameter
This avoids toil when changing other functions in `ObligationForest` to take an `OUT` parameter.
2022-09-19 22:14:39 -05:00
est31
173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
bors
52e003a6e9 Auto merge of #99334 - NiklasJonsson:84447/error-privacy, r=oli-obk
rustc_error, rustc_private: Switch to stable hash containers

Relates https://github.com/rust-lang/rust/issues/84447
2022-09-12 15:57:37 +00:00