Commit graph

929 commits

Author SHA1 Message Date
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Michael Goulet
00132141c7
Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, r=lcnr
Ensure that negative auto impls are always applicable

r? lcnr (or reassign if you dont want to review)

https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06 12:22:16 -05:00
bors
4559163ccb Auto merge of #138031 - workingjubilee:rollup-5bsotpz, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - #137829 (Stabilize [T]::split_off... methods)
 - #137850 (Stabilize `box_uninit_write`)
 - #137912 (Do not recover missing lifetime with random in-scope lifetime)
 - #137913 (Allow struct field default values to reference struct's generics)
 - #137923 (Simplify `<Postorder as Iterator>::size_hint`)
 - #137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK)
 - #137963 (Add ``dyn`` keyword to `E0373` examples)
 - #137975 (Remove unused `PpMode::needs_hir`)
 - #137981 (rustdoc search: increase strictness of typechecking)
 - #137986 (Fix some typos)
 - #137991 (Add `avr-none` to SUMMARY.md and platform-support.md)
 - #137993 (Remove obsolete comment from DeduceReadOnly)
 - #137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"")
 - #138019 (Pretty-print `#[deprecated]` attribute in HIR.)
 - #138026 (Make CrateItem::body() function return an option)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-05 06:59:11 +00:00
Michael Goulet
3d62b279dd Ensure that negative auto impls are always applicable 2025-03-04 17:45:18 +00:00
Askar Safin
c6c4ea40dc Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync""
This reverts commit 02406903b0.
2025-03-04 15:32:55 +03:00
Yotam Ofek
6e86aa17ec Adapt librustdoc to 2024 edition lifetieme capture rules
Get rid of the `Captures` hack
2025-03-04 12:35:23 +02:00
Zalathar
cfa27fbeef Tidy imports in rustc_data_structures::sync 2025-03-03 20:21:12 +11:00
Zalathar
32c5449d45 Remove some unnecessary aliases from rustc_data_structures::sync
With the removal of `cfg(parallel_compiler)`, these are always shared
references and `std::sync::OnceLock`.
2025-03-03 20:20:24 +11:00
Zalathar
5afd12239a Remove leading underscores from parameter names in Sharded
With the removal of `cfg(parallel_compiler)`, these parameters are never
considered unused.
2025-03-03 18:07:54 +11:00
bors
daf59857d6 Auto merge of #137704 - nnethercote:opt-empty-prov-range-checks, r=oli-obk
Optimize empty provenance range checks.

Currently it gets the pointers in the range and checks if the result is empty, but it can be done faster if you combine those two steps.

r? `@oli-obk`
2025-03-02 22:41:17 +00:00
Matthias Krüger
18c47ad639
Rollup merge of #136579 - bjorn3:fix_thinvec_ext_ub, r=BoxyUwU
Fix UB in ThinVec::flat_map_in_place

`thin_vec.as_ptr()` goes through the `Deref` impl of `ThinVec`, which will not allow access to any memory as we did call `set_len(0)` first.

Found in the process of investigating https://github.com/rust-lang/rust/issues/135870.
2025-02-27 08:56:36 +01:00
Nicholas Nethercote
a36d8acd83 Optimize empty provenance range checks.
Currently it gets the pointers in the range and checks if the result is
empty, but it can be done faster if you combine those two steps.
2025-02-27 18:10:17 +11:00
bjorn3
3477297c37 Fix UB in ThinVec::flat_map_in_place
thin_vec.as_ptr() goes through the Deref impl of ThinVec, which will
not allow access to any memory as we did call set_len(0) first.
2025-02-26 15:49:19 +00:00
bors
ac91805f31 Auto merge of #137354 - FractalFir:intern_with_cap, r=FractalFir
Change interners to start preallocated with an increased capacity

Inspired by https://github.com/rust-lang/rust/issues/137005.

Added a `with_capacity` function to `InternedSet`. Changed the `CtxtInterners` to start with `InternedSets` preallocated with a capacity.

This *does* increase memory usage at very slightly(by ~1 MB at the start), altough that increase quickly disaperars for larger crates(since they require such capacity anyway).

A local perf run indicates this improves compiletimes for small crates(like `ripgrep`), without a negative effect on larger ones.
2025-02-26 13:01:45 +00:00
Michał Kostrubiec
7d2cfcab9d Changed interners to start with preallocated capacity 2025-02-25 01:17:01 +01:00
Jacob Pratt
6aa015ae9d
Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb
Allow `IndexSlice` to be indexed by ranges.

This comes with some annoyances as the index type can no longer inferred from indexing expressions. The biggest offender for this is `IndexVec::from_fn_n(|idx| ..., n)` where the index type won't be inferred from the call site or any index expressions inside the closure.

My main use case for this is mapping a `Place` to `Range<Idx>` for value tracking where the range represents all the values the place contains.
2025-02-24 02:11:32 -05:00
bors
b880760977 Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrum
Master bootstrap update

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday

r? `@Mark-Simulacrum`
2025-02-23 11:12:56 +00:00
Michael Goulet
12e3911d81 Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
Michael Goulet
3d5438accd Fix binding mode problems 2025-02-22 00:13:19 +00:00
Michael Goulet
e1819a889a Fix overcapturing, unsafe extern blocks, and new unsafe ops 2025-02-22 00:01:48 +00:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Jason Newcomb
162fb713ac Allow SliceIndex to be indexed by ranges. 2025-02-21 16:10:31 -05:00
bjorn3
7b74920388 Stacker now handles miri using a noop impl itself 2025-02-21 13:54:45 +00:00
Josh Stone
3c45324e67 update cfg(bootstrap) 2025-02-18 09:32:44 -08:00
Mark Rousskov
9fc759099b Enforce T: Hash for Interned<...>
This adds panicking Hash impls for several resolver types that don't
actually satisfy this condition. It's not obvious to me that
rustc_resolve actually upholds the Interned guarantees but fixing that
seems pretty hard (the structures have at minimum some interior
mutability, so it's not really recursively hashable in place...).
2025-02-17 21:35:52 -05:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Ben Kimock
1d7cf0ff40 Replace some u64 hashes with Hash64 2025-02-15 13:59:09 -05:00
Askar Safin
02406903b0 compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync" 2025-02-11 10:21:17 +03:00
Askar Safin
d79f9ca257 compiler/rustc_data_structures/src/sync.rs: delete Sync and Send 2025-02-11 09:15:54 +03:00
Askar Safin
4a2c7f48b5 compiler/rustc_data_structures/src/sync.rs: remove atomics, but not AtomicU64! 2025-02-11 08:57:36 +03:00
Askar Safin
8f684c9db7 compiler/rustc_data_structures/src/sync.rs: delete Weak 2025-02-11 08:28:28 +03:00
Askar Safin
c9c7b44510 compiler/rustc_data_structures/src/sync.rs: delete MappedLockGuard
It seems it is left-over after some refactoring
2025-02-11 08:24:50 +03:00
Askar Safin
25b6761c9e compiler/rustc_data_structures/src/sync.rs: remove "impl Clone for RwLock"
parking_lot::RwLock doesn't have "impl Clone", so we should not have, either
2025-02-11 07:55:57 +03:00
Askar Safin
42ceb25679 compiler/rustc_data_structures/src/sync.rs: these RwLock methods are never called, so let's remove them 2025-02-11 07:55:57 +03:00
bjorn3
1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
Matthias Krüger
3eb1ef836e
Rollup merge of #136580 - bjorn3:miri_fixes, r=lqd
Couple of changes to run rustc in miri

This is not the full set of patches required to run rustc in miri, but it is the fast majority of the changes to rustc itself. There is also a change to the jobserver crate necessary and on arm64 a change to the memchr crate. Running rustc in miri has already found some UB: https://github.com/rust-lang/rust/pull/136579

cc https://github.com/rust-lang/rust/issues/135870#issuecomment-2612470540
2025-02-06 21:56:27 +01:00
bors
2f92f050e8 Auto merge of #136471 - safinaskar:parallel, r=SparrowLii
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`

tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`

This is continuation of https://github.com/rust-lang/rust/pull/132282 .

I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement.

There are other possibilities, through.

We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase.

So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge.

cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 )

r? SparrowLii

`@rustbot` label WG-compiler-parallel
2025-02-06 10:50:05 +00:00
bjorn3
e27495c015 Couple of changes to run rustc in miri 2025-02-05 13:52:22 +00:00
bors
820bfffc25 Auto merge of #136094 - davidv1992:upgrade-elsa, r=oli-obk
Upgrade elsa to the newest version.

This was locked to 1.7.1 because of an error in the elsa release process that has since been fixed. Upgrading has the advantage that the elsa code runs properly in miri, at least with tree borrows.

This was spawned from https://github.com/rust-lang/rust/issues/135870#issuecomment-2612470540
2025-02-05 10:15:02 +00:00
Zalathar
623d6e8ca4 Notes on types/traits used for in-memory query caching
When the word "cache" appears in the context of the query system, it often
isn't obvious whether that is referring to the in-memory query cache or the
on-disk incremental cache.

For these types, we can assure the reader that they are for in-memory caching.
2025-02-03 22:36:01 +11:00
Askar Safin
0a21f1d0a2 tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
Nicholas Nethercote
0c47091006 Overhaul to_readable_str.
It's a function that prints numbers with underscores inserted for
readability (e.g. "1_234_567"), used by `-Zmeta-stats` and
`-Zinput-stats`. It's the only thing in `rustc_middle::util::common`,
which is a bizarre location for it.

This commit:
- moves it to `rustc_data_structures`, a more logical crate for it;
- puts it in a module `thousands`, like the similar crates.io crate;
- renames it `format_with_underscores`, which is a clearer name;
- rewrites it to be more concise;
- slightly improves the testing.
2025-01-31 16:04:13 +11:00
David Venhoek
1b8a792b96 Upgrade elsa to the newest version. 2025-01-29 21:51:28 +01:00
Matthias Krüger
995eb5c929
Rollup merge of #136149 - cuviper:rustc-rayon-indexmap, r=compiler-errors
Flip the `rustc-rayon`/`indexmap` dependency order

[`rustc-rayon v0.5.1`](https://github.com/rust-lang/rustc-rayon/pull/14) added `indexmap` implementations that will allow `indexmap` to drop its own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
2025-01-28 18:17:29 +01:00
Josh Stone
314238f92e Flip the rustc-rayon/indexmap dependency order
[`rustc-rayon v0.5.1`](https://github.com/rust-lang/rustc-rayon/pull/14)
added `indexmap` implementations that will allow `indexmap` to drop its
own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
2025-01-27 10:14:37 -08:00
Zalathar
d36e2b88d6 Incorporate iter_nodes into graph::DirectedGraph
This assumes that the set of valid node IDs is exactly `0..num_nodes`.

In practice, we have a lot of graph-algorithm code that already assumes that
nodes are densely numbered, by using `num_nodes` to allocate per-node indexed
data structures.
2025-01-26 14:08:42 +11:00
klensy
84ce2e129a bumpt compiler and tools to windows 0.59 2025-01-21 16:48:44 +03:00
bors
76a030a6c2 Auto merge of #135592 - matthiaskrgr:rollup-4t69l7i, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #134754 (Implement `use` associated items of traits)
 - #135481 (coverage: Completely overhaul counter assignment, using node-flow graphs)
 - #135504 (Allow coercing safe-to-call target_feature functions to safe fn pointers)
 - #135561 (Update docs for `-Clink-dead-code` to discourage its use)
 - #135574 (ci: mirror ubuntu:22.04 to ghcr.io)
 - #135585 (resolve symlinks of LLVM tool binaries before copying them)
 - #135588 (Add license-metadata.json to rustc-src tarball.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-16 21:31:19 +00:00
Matthias Krüger
fca148185e
Rollup merge of #133720 - c410-f3r:cfg-match-foo-bar-baz, r=joshtriplett
[cfg_match] Adjust syntax

A year has passed since the creation of #115585 and the feature, as expected, is not moving forward. Let's change that.

This PR proposes changing the arm's syntax from  `cfg(SOME_CONDITION) => { ... }` to `SOME_CODITION => {}`.

```rust
match_cfg! {
   unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}
```

Why? Because after several manual migrations in https://github.com/rust-lang/rust/pull/116342 it became clear,  at least for me, that `cfg` prefixes are unnecessary, verbose and redundant.

Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.
2025-01-16 17:00:44 +01:00
Zalathar
f1300c860e coverage: Completely overhaul counter assignment, using node-flow graphs 2025-01-16 22:07:18 +11:00