Commit Graph

266214 Commits

Author SHA1 Message Date
Matthias Krüger
f6fd305282
Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay
Add new_cyclic_in for Rc and Arc

Currently, new_cyclic_in does not exist for Rc and Arc. This is an oversight according to https://github.com/rust-lang/wg-allocators/issues/132.

This PR adds new_cyclic_in for Rc and Arc. The implementation is almost the exact same as new_cyclic with some small differences to make it allocator-specific. new_cyclic's implementation has been replaced with a call to `new_cyclic_in(data_fn, Global)`.

Remaining questions:
* ~~Is requiring Allocator to be Clone OK? According to https://github.com/rust-lang/wg-allocators/issues/88, Allocators should be cheap to clone. I'm just hesitant to add unnecessary constraints, though I don't see an obvious workaround for this function since many called functions in new_cyclic_in expect an owned Allocator. I see Allocator.by_ref() as an option, but that doesn't work on when creating Weak { ptr: init_ptr, alloc: alloc.clone() }, because the type of Weak then becomes Weak<T, &A> which is incompatible.~~ Fixed, thank you `@zakarumych!` This PR no longer requires the allocator to be Clone.
* Currently, new_cyclic_in's documentation is almost entirely copy-pasted from new_cyclic, with minor tweaks to make it more accurate (e.g. Rc<T> -> Rc<T, A>). The example section is removed to mitigate redundancy and instead redirects to cyclic_in. Is this appropriate?
* ~~The comments in new_cyclic_in (and much of the implementation) are also copy-pasted from new_cyclic. Would it be better to make a helper method new_cyclic_in_internal that both functions call, with either Global or the custom allocator? I'm not sure if that's even possible, since the internal method would have to return Arc<T, Global> and I don't know if it's possible to "downcast" that to an Arc<T>. Maybe transmute would work here?~~ Done, thanks `@zakarumych`
* Arc::new_cyclic is #[inline], but Rc::new_cyclic is not. Which is preferred?
* nit: does it matter where in the impl block new_cyclic_in is defined?
2024-09-17 20:45:50 +02:00
Matthias Krüger
8b36ecba97
Rollup merge of #129477 - Xiretza:fix-fluent-diagnostics, r=compiler-errors
Fix fluent diagnostics

This line number calculation was both wrong and unnecessary.
2024-09-17 20:45:49 +02:00
Santiago Pastorino
65f8999026
Remove redundant test typeid equality by subtyping 2024-09-17 15:45:15 -03:00
bors
f609b7e058 Auto merge of #130473 - matthiaskrgr:rollup-lf29374, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128535 (Format `std::env::consts` docstrings with markdown backticks)
 - #128961 (Fix #128930: Print documentation of CLI options missing their arg)
 - #129988 (Use `Vec` in `rustc_interface::Config::locale_resources`)
 - #130201 (Encode `coroutine_by_move_body_def_id` in crate metadata)
 - #130275 (Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error)
 - #130314 (Use the same precedence for all macro-like exprs)
 - #130440 (Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body)
 - #130458 (`rustc_codegen_ssa` cleanups)
 - #130469 (Mark `where_clauses_object_safety` as removed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 16:48:36 +00:00
Mattias Wallin
b552eb9e3a Avoid an allocation in rewrite_int_lit 2024-09-17 12:42:33 -04:00
Mattias Wallin
008b3df97d Avoid allocating Vec in light_rewrite_comment 2024-09-17 12:42:33 -04:00
Chayim Refael Friedman
d0a2ca4867 Implement ACP 429: add Lazy{Cell,Lock}::get[_mut] and force_mut
In the implementation of `force_mut`, I chose performance over safety.
For `LazyLock` this isn't really a choice; the code has to be unsafe.
But for `LazyCell`, we can have a full-safe implementation, but it will
be a bit less performant, so I went with the unsafe approach.
2024-09-17 09:40:34 -07:00
Mattias Wallin
019578f924 Use usize::MAX instead of deprecated usize::max_value 2024-09-17 12:10:29 -04:00
Matthias Krüger
065690e186
Rollup merge of #130469 - compiler-errors:wc-obj-safety, r=jackh726
Mark `where_clauses_object_safety` as removed

r? lcnr
2024-09-17 17:28:35 +02:00
Matthias Krüger
d5a081981d
Rollup merge of #130458 - nnethercote:rustc_codegen_ssa-cleanups, r=jieyouxu
`rustc_codegen_ssa` cleanups

Just some minor improvements I found while reading through this code.

r? ``@jieyouxu``
2024-09-17 17:28:35 +02:00
Matthias Krüger
02b1776cd3
Rollup merge of #130440 - compiler-errors:rpitit-opaque-hidden, r=jieyouxu
Don't ICE in `opaque_hidden_inferred_bound` lint for RPITIT in trait with no default method body

Inline comment should explain the fix.

Fixes #130422
2024-09-17 17:28:34 +02:00
Matthias Krüger
c896f06bdb
Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwco
Use the same precedence for all macro-like exprs

No need to make these have a different precedence since they're all written like `whatever!(expr)`, and it makes it simpler when adding new macro-based built-in operators in the future.
2024-09-17 17:28:33 +02:00
Matthias Krüger
62f2ec9b59
Rollup merge of #130275 - compiler-errors:extern-crate, r=lcnr
Don't call `extern_crate` when local crate name is the same as a dependency and we have a trait error

#124944 implemented logic to point out when a trait bound failure involves a *trait* and *type* who come from identically named but different crates. This logic calls the `extern_crate` query which is not valid on `LOCAL_CRATE` cnum, so let's filter that out eagerly.

Fixes #130272
Fixes #129184
2024-09-17 17:28:33 +02:00
Matthias Krüger
ddcb9c132a
Rollup merge of #130201 - compiler-errors:foreign-synthetic-body, r=lcnr
Encode `coroutine_by_move_body_def_id` in crate metadata

We synthesize the MIR for a by-move body for the `FnOnce` implementation of async closures. It can be accessed with the `coroutine_by_move_body_def_id` query. We weren't encoding this query in the metadata though, nor were we properly recording that synthetic MIR in `mir_keys`, so the `optimized_mir` wasn't getting encoded either!

Stacked on top is a fix to consider `DefKind::SyntheticCoroutineBody` to return true in several places I missed. Specifically, we should consider the def-kind in `fn DefKind::is_fn_like()`, since that's what we were using to make sure we ensure `query mir_inliner_callees` before the MIR gets stolen for the body. This led to some CI failures that were caught by miri but which I added a test for.
2024-09-17 17:28:32 +02:00
Matthias Krüger
732ad59779
Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwco
Use `Vec` in `rustc_interface::Config::locale_resources`

This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-17 17:28:32 +02:00
Matthias Krüger
fe3428d9ac
Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxu
Fix #128930: Print documentation of CLI options missing their arg

Fix #128930. Failing to give an argument to CLI options which require it now prints something like:
```
$ rustc --print
error: Argument to option 'print' missing
       Usage:
           --print [crate-name|file-names|sysroot|target-libdir|cfg|check-cfg|calling-conventions|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|all-target-specs-json|native-static-libs|stack-protector-strategies|link-args|deployment-target]
                               Compiler information to print on stdout
```
2024-09-17 17:28:31 +02:00
Matthias Krüger
11fe22c3fb
Rollup merge of #128535 - mmvanheusden:master, r=workingjubilee
Format `std::env::consts` docstrings with markdown backticks

This clarifies possible outputs the constants might be.

**Before:**
--
<img src="https://github.com/user-attachments/assets/8ee8772a-7562-42a2-89be-f8772b76dbd5" width="500px">

**After:**
--
<img src="https://github.com/user-attachments/assets/4632e5e2-db3e-4372-b13e-006cc1701eb1" width="500px">
2024-09-17 17:28:31 +02:00
Kyle Huey
930db09236 Add zlib to musl dist image so rust-lld will support zlib compression for debug info there.
Fixes #130063.
2024-09-17 08:10:44 -07:00
Xiretza
5b3bde953e fluent_macro: fix diagnostics for fluent parse failures
This line number calculation was both wrong and unnecessary.
2024-09-17 14:49:33 +00:00
Xiretza
0a253246f7 Add test for fluent diagnostics 2024-09-17 14:47:57 +00:00
Michael Goulet
1c3b03a170 Mark where_clauses_object_safety as removed 2024-09-17 09:44:27 -04:00
Michael Goulet
d9624ed16c Make sure that def id <=> lang item map is bidirectional 2024-09-17 09:41:12 -04:00
Ralf Jung
ba86cf8686 update lockfile 2024-09-17 15:20:50 +02:00
Augie Fackler
9692513b7e tests: allow trunc/select instructions to be missing
On LLVM 20, these instructions already get eliminated, which at least
partially satisfies a TODO. I'm not talented enough at using FileCheck
to try and constrain this further, but if we really want to we could
copy an LLVM 20 specific version of this test that would restore it to
being CHECK-NEXT: insertvalue ...

@rustbot label: +llvm-main
2024-09-17 08:55:26 -04:00
bors
e9e13a68d7 Auto merge of #129073 - compiler-errors:receiver-variance, r=lcnr
Relate receiver invariantly in method probe for `Mode::Path`

Effectively reverts part of #126128
Fixes #126227

This PR changes method probing to use equality for fully path-based method lookup, and subtyping for receiver `.` method lookup.

r? lcnr
2024-09-17 12:44:08 +00:00
David Wood
9a330742c9
tests: add repr/transparent test for aarch64
Moves `transparent-struct-ptr.rs` to `transparent-byval-struct-ptr.rs`
and then adds a new `transparent-opaque-ptr.rs` for aarch64.
2024-09-17 13:29:44 +01:00
bors
b880024f29 Auto merge of #3891 - tiif:tokiotest, r=RalfJung
Fix tokio test ICE

Fixes #3858

It turned out that the issue mentioned [here](https://github.com/rust-lang/miri/issues/3858#issuecomment-2336726299) is the exact cause of ICE.
So in this PR, I changed the type of ``EpollEventInterest::epfd`` from ``i32`` to ``WeakFileDescriptionRef``.
2024-09-17 09:49:34 +00:00
tiif
143710ff45 Tokio ICE fix: Changed the type of EpollEventInterest::epfd from i32 to WeakFileDescriptionRef 2024-09-17 17:46:33 +08:00
bors
46b0f8bafc Auto merge of #130455 - compiler-errors:inline-ordering, r=saethlin
Remove semi-nondeterminism of `DefPathHash` ordering from inliner

Déjà vu or something because I kinda thought I had put this PR up before. I recall a discussion somewhere where I think it was `@saethlin` mentioning that this check was no longer needed since we have "proper" cycle detection. Putting that up as a PR now.

This may slighlty negatively affect inlining, since the cycle breaking here means that we still inlined some cycles when the def path hashes were ordered in certain ways, this leads to really bad nondeterminism that makes minimizing ICEs and putting up inliner bugfixes difficult.

r? `@cjgillot` or `@saethlin` or someone else idk
2024-09-17 09:35:10 +00:00
bors
d0f4a526cb Auto merge of #3894 - rust-lang:rustup-2024-09-17, r=RalfJung
Automatic Rustup
2024-09-17 07:26:48 +00:00
bors
9c3a392348 Auto merge of #3893 - rust-lang:autolabel, r=RalfJung
Automatically add/remove labels when github review (requests) are used
2024-09-17 07:00:09 +00:00
bors
f6ae3cb0fb Auto merge of #3866 - rust-lang:ui_test_26_1, r=oli-obk
Bump ui test to 0.26

lots of issues fixed and various improvements

🤞 that it works this time around
2024-09-17 06:32:19 +00:00
bors
2e367d94f0 Auto merge of #130145 - fee1-dead-contrib:repeatn, r=lcnr,workingjubilee
`RepeatN`: use MaybeUninit

Closes #130140. Closes #130141.

Use `MaybeUninit` instead of `ManuallyDrop` for soundness.
2024-09-17 06:29:37 +00:00
Nicholas Nethercote
c629538dad Merge some impl blocks. 2024-09-17 16:24:35 +10:00
Nicholas Nethercote
3ec2f121cc Rename some lifetimes.
`'mir` is not a good lifetime name in `LocalAnalyzer`, because it's used
on two unrelated fields. `'a` is more standard for a situation like this
(e.g. #130022).
2024-09-17 16:24:35 +10:00
Nicholas Nethercote
ae1f092307 Streamline coroutine_kind_label. 2024-09-17 16:24:35 +10:00
Nicholas Nethercote
b3b56d805f Remove unnecessary cx argument.
Because `bx` contains a `cx`.
2024-09-17 16:24:35 +10:00
Nicholas Nethercote
52c5de00dc Streamline bin_op_to_[if]cmp_predicate. 2024-09-17 16:24:35 +10:00
Nicholas Nethercote
cd3da000c0 Clean up formatting.
Reflow overly long comments, plus some minor whitespace improvements.
2024-09-17 16:24:35 +10:00
Nicholas Nethercote
bdacdfe95f Minimize visibilities.
This makes it much clearer which things are used outside the crate.
2024-09-17 16:24:33 +10:00
The Miri Cronjob Bot
c5f5cfcfbc fmt 2024-09-17 05:05:40 +00:00
The Miri Cronjob Bot
48440b1403 Merge from rustc 2024-09-17 05:04:34 +00:00
The Miri Cronjob Bot
540b4da0f1 Preparing for merge from rustc 2024-09-17 04:56:57 +00:00
bors
c8dff289a0 Auto merge of #130456 - matthiaskrgr:rollup-h2qvk1f, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #130380 (coverage: Clarify some parts of coverage counter creation)
 - #130427 (run_make_support: rectify symlink handling)
 - #130447 (rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…)
 - #130448 (fix: Remove duplicate `LazyLock` example.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 03:40:29 +00:00
Michael Goulet
4beb1cf9e5 Fix a couple more DefKind discrepancies between DefKind::Closure and DefKind::SyntheticCoroutineBody 2024-09-16 22:09:42 -04:00
Matthias Krüger
558b302af7
Rollup merge of #130448 - alilleybrinker:master, r=workingjubilee
fix: Remove duplicate `LazyLock` example.

The top-level docs for `LazyLock` included two lines of code, each with an accompanying comment, that were identical and with nearly- identical comments. This looks like an oversight from a past edit which was perhaps trying to rewrite an existing example but ended up duplicating rather than replacing, though I haven't gone back through the Git history to check.

This commit removes what I personally think is the less-clear of the two examples.
2024-09-17 03:58:47 +02:00
Matthias Krüger
264597d86c
Rollup merge of #130447 - durin42:llvm-20-fix-instrumentation-hdr, r=cuviper
rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…

…4c82dd0ed8b5

Just a simple header move.

`@rustbot` label: +llvm-main
2024-09-17 03:58:47 +02:00
Matthias Krüger
07ca905420
Rollup merge of #130427 - jieyouxu:rmake-symlink, r=Kobzol
run_make_support: rectify symlink handling

Avoid confusing Unix symlinks and Windows symlinks. Since their
semantics are quite different, we should avoid trying to make it
automagic in how symlinks are created and deleted. Notably, the tests
should reflect what type of symlinks are to be created to match what std
does to make it less surprising for test readers.
2024-09-17 03:58:46 +02:00
Matthias Krüger
1a7fdc7d5d
Rollup merge of #130380 - Zalathar:counters, r=jieyouxu
coverage: Clarify some parts of coverage counter creation

This is a series of semi-related changes that are trying to make the `counters` module easier to read, understand, and modify.

For example, the existing code happens to avoid ever using the count for a `TerminatorKind::Yield` node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures.

This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read.

There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.
2024-09-17 03:58:46 +02:00
Michael Goulet
8f97231d34 Remove semi-nondeterminism of DefPathHash ordering from inliner 2024-09-16 21:41:15 -04:00