Commit Graph

261854 Commits

Author SHA1 Message Date
Alona Enraght-Moony
16fc1bbfaf trans her gender
CC https://github.com/rust-lang/team/pull/1511
2024-07-27 23:36:23 +00:00
bors
fbccf50533 Auto merge of #128278 - tgross35:rollup-zv7q0h5, r=tgross35
Rollup of 8 pull requests

Successful merges:

 - #125897 (from_ref, from_mut: clarify documentation)
 - #128207 (improve error message when `global_asm!` uses `asm!` options)
 - #128241 (Remove logic to suggest clone of function output)
 - #128259 ([illumos/solaris] set MSG_NOSIGNAL while writing to sockets)
 - #128262 (Delete `SimplifyArmIdentity` and `SimplifyBranchSame` tests)
 - #128266 (update `rust.channel` default value documentation)
 - #128267 (Add rustdoc GUI test to check title with and without search)
 - #128271 (Disable jump threading of float equality)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-27 18:29:13 +00:00
Trevor Gross
f62ae7e120
Rollup merge of #128271 - Nilstrieb:jump-into-a-can-of-worms-called-float-equality, r=compiler-errors
Disable jump threading of float equality

Jump threading stores values as `u128` (`ScalarInt`) and does its comparisons for equality as integer comparisons.
This works great for integers. Sadly, not everything is an integer.

Floats famously have wonky equality semantcs, with `NaN!=NaN` and `0.0 == -0.0`. This does not match our beautiful integer bitpattern equality and therefore causes things to go horribly wrong.

While jump threading could be extended to support floats by remembering that they're floats in the value state and handling them properly, it's signficantly easier to just disable it for now.

fixes #128243
2024-07-27 13:33:00 -04:00
Trevor Gross
8dd94b870d
Rollup merge of #128267 - GuillaumeGomez:gui-test-title, r=notriddle
Add rustdoc GUI test to check title with and without search

Follow-up of https://github.com/rust-lang/rust/pull/128210.

r? `@notriddle`
2024-07-27 13:32:59 -04:00
Trevor Gross
5f3a6035e2
Rollup merge of #128266 - onur-ozkan:update-channel-doc, r=dtolnay
update `rust.channel` default value documentation

self-explanatory

Resolves #128258

r? dtolnay
2024-07-27 13:32:58 -04:00
Trevor Gross
356f190eed
Rollup merge of #128262 - DianQK:remove-unused-tests, r=saethlin
Delete `SimplifyArmIdentity` and `SimplifyBranchSame` tests

These two passes have already been deleted in #107256. I'm not sure why tidy didn't catch it.

As regression tests, I didn't delete `tests/ui/mir/issue-66851.rs` and `tests/ui/mir/simplify-branch-same.rs`.

r? compiler
2024-07-27 13:32:58 -04:00
Trevor Gross
2b58d8c08c
Rollup merge of #128259 - sunshowers:msg-nosignal, r=Mark-Simulacrum
[illumos/solaris] set MSG_NOSIGNAL while writing to sockets

Both these platforms have MSG_NOSIGNAL available, and we should set it for socket writes in the event that the SIGPIPE handler has been reset to SIG_DFL (i.e. terminate the process).

I've verified via a quick program at
https://github.com/sunshowers/msg-nosignal-test/ that even when the SIGPIPE handler is reset to SIG_DFL, writes to closed TCP sockets now error out with EPIPE. (Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.)

However, I couldn't find any existing tests which verified the MSG_NOSIGNAL behavior.
2024-07-27 13:32:57 -04:00
Trevor Gross
ee25d99299
Rollup merge of #128241 - compiler-errors:clone-sugg, r=jieyouxu
Remove logic to suggest clone of function output

I can't exactly tell, but I believe that this suggestion is operating off of a heuristic that the lifetime of a function's input is correlated with the lifetime of a function's output in such a way that cloning would fix an error. I don't think that actually manages to hit the bar of "actually provides useful suggestions" most of the time.

Specifically, I've hit false-positives due to this suggestion *twice* when fixing ICEs in the compiler, so I don't think it's worthwhile having this logic around. Neither of the two affected UI tests are actually fixed by the suggestion.
2024-07-27 13:32:57 -04:00
Trevor Gross
9164dbd48c
Rollup merge of #128207 - folkertdev:asm-parser-generalize, r=Amanieu
improve error message when `global_asm!` uses `asm!` options

specifically, what was

    error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags`
      --> $DIR/bad-options.rs:45:25
       |
    LL | global_asm!("", options(preserves_flags));
       |                         ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw`

is now

    error: the `preserves_flags` option cannot be used with `global_asm!`
      --> $DIR/bad-options.rs:45:25
       |
    LL | global_asm!("", options(preserves_flags));
       |                         ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly

mirroring the phrasing of the [reference](https://doc.rust-lang.org/reference/inline-assembly.html#options).

This is also a bit of a refactor for a future `naked_asm!` macro (for use in `#[naked]` functions). Currently this sort of error can come up when switching from inline to global asm, or when a user just isn't that experienced with assembly. With  `naked_asm!` added to the mix hitting this error is more likely.
2024-07-27 13:32:56 -04:00
Trevor Gross
51734a8a6d
Rollup merge of #125897 - RalfJung:from-ref, r=Amanieu
from_ref, from_mut: clarify documentation

This was brought up [here](https://github.com/rust-lang/rust/issues/56604#issuecomment-2143193486). The domain of quantification is generally always constrained by the type in the type signature, and I am not sure it's always worth spelling that out explicitly as that makes things exceedingly verbose. But since this was explicitly brought up, let's clarify.
2024-07-27 13:32:56 -04:00
Folkert
33b5ca99b7
add needs-asm-support to tests/ui/asm/unsupported-option.rs 2024-07-27 19:27:20 +02:00
Folkert
3e4ddc39b8
update aarch64 asm tests 2024-07-27 19:08:59 +02:00
bors
d9e1dea75e Auto merge of #128091 - heiher:xz-only, r=Mark-Simulacrum
build-manifest: Allow building manifests for formats that only have xz compression
2024-07-27 16:05:22 +00:00
Nilstrieb
f305e18804 Disable jump threading of float equality
Jump threading stores values as `u128` (`ScalarInt`) and does its
comparisons for equality as integer comparisons.
This works great for integers. Sadly, not everything is an integer.

Floats famously have wonky equality semantcs, with `NaN!=NaN` and
`0.0 == -0.0`. This does not match our beautiful integer bitpattern
equality and therefore causes things to go horribly wrong.

While jump threading could be extended to support floats by remembering
that they're floats in the value state and handling them properly,
it's signficantly easier to just disable it for now.
2024-07-27 15:11:59 +02:00
bors
8fe0c753f2 Auto merge of #128006 - tgross35:missing-fragment-specifier-e2024, r=petrochenkov
Make `missing_fragment_specifier` an error in edition 2024

`missing_fragment_specifier` has been a future compatibility warning since 2017. Uplifting it to an unconditional hard error was attempted in 2020, but eventually reverted due to fallout.

Make it an error only in edition >= 2024, leaving the lint for older editions. This change will make it easier to support more macro syntax that relies on usage of `$`.

Fixes <https://github.com/rust-lang/rust/issues/40107>

---

It is rather late for the edition but since this change is relatively small, it seems worth at least bringing up. This follows a brief [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition/topic/.60.20DBD.20-.3E.20hard.20error) (cc `@tmandry).`

Making this an edition-dependent lint has come up before but there was not a strong motivation. I am proposing it at this time because this would simplify the [named macro capture groups](https://github.com/rust-lang/rfcs/pull/3649) RFC, which has had mildly positive response, and makes use of new `$` syntax in the matcher. The proposed syntax currently parses as metavariables without a fragment specifier; this warning is raised, but there are no errors.

It is obviously not known that this specific RFC will eventually be accepted, but forbidding `missing_fragment_specifier` should make it easier to support any new syntax in the future that makes use of `$` in different ways. The syntax conflict is also not impossible to overcome, but making it clear that unnamed metavariables are rejected makes things more straightforward and should allow for better diagnostics.

`@Mark-Simulacrum` suggested making this forbid-by-default instead of an error at https://github.com/rust-lang/rust/issues/40107#issuecomment-761727885, but I don't think this would allow the same level of syntax flexibility.

It is also possible to reconsider making this an unconditional error since four years have elapsed since the previous attempt, but this seems likely to hit the same pitfalls. (Possibly worth a crater run?)

Tracking:

- https://github.com/rust-lang/rust/issues/128143
2024-07-27 12:35:18 +00:00
Guillaume Gomez
015f5d6f76 Add rustdoc GUI test to check title with and without search 2024-07-27 12:12:16 +02:00
bors
3942254d00 Auto merge of #124905 - reitermarkus:u32-from-char-opt, r=scottmcm
Allow optimizing `u32::from::<char>`.

Extracted from https://github.com/rust-lang/rust/pull/124307.

This allows optimizing the panicking branch in the `escape_unicode` function, see https://rust.godbolt.org/z/61YhKrhvP.
2024-07-27 09:34:26 +00:00
Trevor Gross
8c402f125c Make missing_fragment_specifier an error in edition 2024
`missing_fragment_specifier` has been a future compatibility warning
since 2017. Uplifting it to an unconditional hard error was attempted in
2020, but eventually reverted due to fallout.

Make it an error only in edition >= 2024, leaving the lint for older
editions. This change will make it easier to support more macro syntax
that relies on usage of `$`.

Fixes <https://github.com/rust-lang/rust/issues/40107>
2024-07-27 05:33:24 -04:00
onur-ozkan
139a713dc0 add change entry for rust.channel defaults
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-27 11:08:37 +03:00
onur-ozkan
1140750f6e update rust.channel documentation
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-07-27 11:08:29 +03:00
bors
ad3c5a3301 Auto merge of #128255 - stepancheg:doc-shl, r=scottmcm
Document 0x10.checked_shl(BITS - 1) does not overflow

Not obvious.
2024-07-27 07:11:32 +00:00
DianQK
9aed3843f2
Delete SimplifyArmIdentity and SimplifyBranchSame tests 2024-07-27 14:10:09 +08:00
bors
a526d7ce45 Auto merge of #127946 - tgross35:fmt-builders-set-result, r=cuviper
Always set `result` during `finish()` in debug builders

Most functions for format builders set `self.result` after writing strings. This ensures that any further writing fails immediately rather than trying to write again.

A few `.finish()` methods and the `.finish_non_exhaustive` did have this same behavior, so update the remaining `.finish()` methods to make it consistent here.
2024-07-27 02:26:30 +00:00
Rain
50d127e6ec [illumos/solaris] set MSG_NOSIGNAL while writing to sockets
Both these platforms have MSG_NOSIGNAL available, and we should set it for
socket writes in the event that the SIGPIPE handler has been reset to SIG_DFL
(i.e. terminate the process).

I've verified via a quick program at
https://github.com/sunshowers/msg-nosignal-test/ that even when the SIGPIPE
handler is reset to SIG_DFL, writes to closed sockets now error out with EPIPE.
(Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.)
2024-07-27 02:10:24 +00:00
bors
8b6b8574f6 Auto merge of #128253 - tgross35:rollup-rpmoebz, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - #124941 (Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str`)
 - #128201 (Implement `Copy`/`Clone` for async closures)
 - #128210 (rustdoc: change title of search results)
 - #128223 (Refactor complex conditions in `collect_tokens_trailing_token`)
 - #128224 (Remove unnecessary range replacements)
 - #128226 (Remove redundant option that was just encoding that a slice was empty)
 - #128227 (CI: do not respect custom try jobs for unrolled perf builds)
 - #128229 (Improve `extern "<abi>" unsafe fn()` error message)
 - #128235 (Fix `Iterator::filter` docs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-27 00:01:28 +00:00
Stepan Koltsov
723336d835 Document int.checked_shl(BITS - 1)
Not obvious.
2024-07-27 00:23:05 +01:00
Trevor Gross
8385f3b7ee
Rollup merge of #128235 - harryscholes:fix-iterator-filter-docs, r=tgross35
Fix `Iterator::filter` docs

Small fix to add code formatting around `Iterator::filter` `true` return type
2024-07-26 19:03:08 -04:00
Trevor Gross
7eaf74743b
Rollup merge of #128229 - tdittr:unsafe-extern-abi-error, r=compiler-errors
Improve `extern "<abi>" unsafe fn()` error message

These errors were already reported in #87217, and fixed by #87235 but missed the case of an explicit ABI.

This PR does not cover multiple keywords like `extern "C" pub const unsafe fn()`, but I don't know what a good way to cover this  would be. It also seems rarer than `extern "C" unsafe` which I saw happen a few times in workshops.
2024-07-26 19:03:08 -04:00
Trevor Gross
f9209ae8c5
Rollup merge of #128227 - Kobzol:ci-unrolled-perf-build-matrix, r=tgross35
CI: do not respect custom try jobs for unrolled perf builds

Before this PR, if a pull request merged in a rollup had some `try-job` annotations, the unrolled perf builds were running the custom try jobs instead of the default job, which was wrong.

Found out [here](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/try-perf.20jobs.20respect.20try-job.20annotations).
2024-07-26 19:03:07 -04:00
Trevor Gross
f1cf2f526a
Rollup merge of #128226 - oli-obk:option_vs_empty_slice, r=petrochenkov
Remove redundant option that was just encoding that a slice was empty

There is already a sanity check ensuring we don't put empty attribute lists into the HIR:

6ef11b81c2/compiler/rustc_ast_lowering/src/lib.rs (L661-L667)
2024-07-26 19:03:07 -04:00
Trevor Gross
af52be2cea
Rollup merge of #128224 - nnethercote:fewer-replace_ranges, r=petrochenkov
Remove unnecessary range replacements

This PR removes an unnecessary range replacement in `collect_tokens_trailing_token`, and does a couple of other small cleanups.

r? ````@petrochenkov````
2024-07-26 19:03:06 -04:00
Trevor Gross
553a64f412
Rollup merge of #128223 - nnethercote:refactor-collect_tokens, r=petrochenkov
Refactor complex conditions in `collect_tokens_trailing_token`

More readability improvements for this complicated function.

r? ````@petrochenkov````
2024-07-26 19:03:06 -04:00
Trevor Gross
7195b80453
Rollup merge of #128210 - lolbinarycat:rustdoc-search-title, r=notriddle,GuillaumeGomez
rustdoc: change title of search results

the current title is too similar to that of the page for std::result::Result, which is a problem both for
navigating to the Result docs via browser autocomplete, and for being able to tell which tab is which when the width of tabs is small.
2024-07-26 19:03:05 -04:00
Trevor Gross
bd18f88dab
Rollup merge of #128201 - compiler-errors:closure-clone, r=oli-obk
Implement `Copy`/`Clone` for async closures

We can do so in the same cases that regular closures do.

For the purposes of cloning, coroutine-closures are actually precisely the same as regular closures, specifically in the aspect that `Clone` impls care about which is the upvars. The only difference b/w coroutine-closures and regular closures is the type that they *return*, but this type has not been *created* yet, so we don't really have a problem.

IDK why I didn't add this impl initially -- I went back and forth a bit on the internal representation for coroutine-closures before settling on a design which largely models regular closures. Previous (not published) iterations of coroutine-closures used to be represented as a special (read: cursed) kind of coroutine, which would probably suffer from the pitfalls that coroutines have that oli mentioned below in https://github.com/rust-lang/rust/pull/128201#issuecomment-2251230274.

r? oli-obk
2024-07-26 19:03:05 -04:00
Trevor Gross
86721a4c90
Rollup merge of #124941 - Skgland:stabilize-const-int-from-str, r=dtolnay
Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str`

This PR stabilizes the feature `const_int_from_str`.

- ACP Issue: rust-lang/libs-team#74
- Implementation PR: rust-lang/rust#99322
- Part of Tracking Issue: rust-lang/rust#59133

API Change Diff:

```diff
impl {integer} {
- pub       fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
+ pub const fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
}

impl ParseIntError {
- pub       fn kind(&self) -> &IntErrorKind;
+ pub const fn kind(&self) -> &IntErrorKind;
}
```
This makes it easier to parse integers at compile-time, e.g.
the example from the Tracking Issue:

```rust
env!("SOMETHING").parse::<usize>().unwrap()
```

could now be achived  with

```rust
match usize::from_str_radix(env!("SOMETHING"), 10) {
  Ok(val) => val,
  Err(err) => panic!("Invalid value for SOMETHING environment variable."),
}
```

rather than having to depend on a library that implements or manually implement the parsing at compile-time.

---

Checklist based on [Libs Stabilization Guide - When there's const involved](https://std-dev-guide.rust-lang.org/development/stabilization.html#when-theres-const-involved)

I am treating this as a [partial stabilization](https://std-dev-guide.rust-lang.org/development/stabilization.html#partial-stabilizations) as it shares a tracking issue (and is rather small), so directly opening the partial stabilization PR for the subset (feature `const_int_from_str`) being stabilized.

- [x] ping Constant Evaluation WG
- [x] no unsafe involved
- [x] no `#[allow_internal_unstable]`
- [ ] usage of `intrinsic::const_eval_select` rust-lang/rust#124625 in `from_str_radix_assert` to change the error message between compile-time and run-time
- [ ] [rust-labg/libs-api FCP](https://github.com/rust-lang/rust/pull/124941#issuecomment-2207021921)
2024-07-26 19:03:04 -04:00
bors
7c2012d0ec Auto merge of #121676 - Bryanskiy:polarity, r=petrochenkov
Support ?Trait bounds in supertraits and dyn Trait under a feature gate

This patch allows `maybe` polarity bounds under a feature gate. The only language change here is that corresponding hard errors are replaced by feature gates. Example:
```rust
#![feature(allow_maybe_polarity)]
...
trait Trait1 : ?Trait { ... } // ok
fn foo(_: Box<(dyn Trait2 + ?Trait)>) {} // ok
fn bar<T: ?Sized + ?Trait>(_: &T) {} // ok
```
Maybe bounds still don't do anything (except for `Sized` trait), however this patch will allow us to [experiment with default auto traits](https://github.com/rust-lang/rust/pull/120706#issuecomment-1934006762).

This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727)
2024-07-26 20:14:16 +00:00
Michael Goulet
e7eae5370e Remove logic to suggest clone of function output 2024-07-26 13:56:06 -04:00
Trevor Gross
cc9da0b2ce Always set result during finish() in debug builders
Most functions for format builders set `self.result` after writing
strings. This ensures that any further writing fails immediately rather
than trying to write again.

A few `.finish()` methods did have this same behavior, so make it
consistent here.
2024-07-26 13:37:20 -04:00
Michael Goulet
5a9959fd9d Suppress useless clone suggestion 2024-07-26 12:53:55 -04:00
Michael Goulet
d5656059a1 Make coroutine-closures possible to be cloned 2024-07-26 12:53:53 -04:00
bors
47243b335e Auto merge of #128065 - Oneirical:great-testilence, r=jieyouxu
Migrate `c-unwind-abi-catch-lib-panic`, `foreign-rust-exceptions` and `export-executable-symbols` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: aarch64-apple
try-job: i686-mingw
2024-07-26 16:21:41 +00:00
harryscholes
130ce490f5 Fix docs 2024-07-26 16:09:17 +01:00
Oneirical
3cc1056ff7 rewrite export-executable-symbols to rmake 2024-07-26 10:17:39 -04:00
Oneirical
2a3e4c547b rewrite foreign-rust-exceptions to rmake 2024-07-26 10:17:04 -04:00
Oneirical
e2dbba8d4d rewrite c-unwind-abi-catch-lib-panic to rmake 2024-07-26 10:17:03 -04:00
Bryanskiy
fd9d0bfbac Forbid ?Trait bounds repetitions 2024-07-26 16:35:05 +03:00
Tamme Dittrich
3fdc99193e Improve error message for extern "C" unsafe fn()
This was handled correctly already for `extern unsafe fn()`.

Co-authored-by: Folkert <folkert@folkertdev.nl>
2024-07-26 15:14:05 +02:00
bors
2d5a628a1d Auto merge of #128165 - saethlin:optimize-clone-shims, r=compiler-errors
Let InstCombine remove Clone shims inside Clone shims

The Clone shims that we generate tend to recurse into other Clone shims, which gets very silly very quickly. Here's our current state: https://godbolt.org/z/E69YeY8eq

So I've added InstSimplify to the shims optimization passes, and improved `is_trivially_pure_clone_copy` so that it can delete those calls inside the shim. This makes the shim way smaller because most of its size is the required ceremony for unwinding.

This change also completely breaks the UI test added for https://github.com/rust-lang/rust/issues/104870. With this PR, that program ICEs in MIR type checking because `is_trivially_pure_clone_copy` and the trait solver disagree on whether `*mut u8` is `Copy`. And adding the requisite `Copy` impl to make them agree makes the test not generate any diagnostics. Considering that I spent most of my time on this PR fixing `#![no_core]` tests, I would prefer to just delete this one. The maintenance burden of `#![no_core]` is uniquely high because when they break they tend to break in very confusing ways.

try-job: x86_64-mingw
2024-07-26 13:13:04 +00:00
Tamme Dittrich
33dd288ef1 Add a test case for extern "C" unsafe to the ui tests 2024-07-26 14:04:40 +02:00
Jakub Beránek
114e0dcf25
CI: do not respect custom try jobs for unrolled perf builds 2024-07-26 13:30:52 +02:00