Commit Graph

232761 Commits

Author SHA1 Message Date
bors
1bd043098e Auto merge of #103836 - H4x5:extra-float-constants, r=thomcc
Add additional float constants

Initial implementation of this ACP: https://github.com/rust-lang/libs-team/issues/119. [Accepted]
Tracking issue: #103883

The values for the constants are copied from the [`libstdc++` source code](16e2427f50/libstdc%2B%2B-v3/include/std/numbers (L57-L120)).
2023-08-28 08:54:28 +00:00
bors
7e02fd8251 Auto merge of #115303 - matthiaskrgr:rollup-iohs8a5, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #109660 (Document that SystemTime does not count leap seconds)
 - #114238 (Fix implementation of `Duration::checked_div`)
 - #114512 (std/tests: disable ancillary tests on freebsd since the feature itsel…)
 - #114919 (style-guide: Add guidance for defining formatting for specific macros)
 - #115278 (tell people what to do when removing an error code)
 - #115280 (avoid triple-backtrace due to panic-during-cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-28 07:01:52 +00:00
Matthias Krüger
32053f7602
Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=Amanieu
avoid triple-backtrace due to panic-during-cleanup

Supersedes https://github.com/rust-lang/rust/pull/115020
Cc https://github.com/rust-lang/rust/issues/114954
r? ``@Amanieu``
2023-08-28 08:13:59 +02:00
Matthias Krüger
9fb586cb52
Rollup merge of #115278 - RalfJung:removed-error-codes, r=GuillaumeGomez
tell people what to do when removing an error code

Currently tidy and CI send developers on a wild goose chase:
- you edit the code
- CI/tidy tells you that an error code is gone, so you remove it from the list
- CI/tidy tells you that the markdown file is stale, so you remove that as well
- CI (but not tidy) tells you not to remove an error description and copy what E0001 does

Let's be nice to people and directly tell them what to do rather than making them follow misleading breadcrumbs.

r? ``@GuillaumeGomez``
2023-08-28 08:13:58 +02:00
Matthias Krüger
81408561e0
Rollup merge of #114919 - joshtriplett:style-guide-macros, r=calebcartwright
style-guide: Add guidance for defining formatting for specific macros
2023-08-28 08:13:58 +02:00
Matthias Krüger
eb569400e5
Rollup merge of #114512 - devnexen:fix_tests_fbsd, r=thomcc
std/tests: disable ancillary tests on freebsd since the feature itsel…

…f is.
2023-08-28 08:13:57 +02:00
Matthias Krüger
d2644d9fe9
Rollup merge of #114238 - jhpratt:fix-duration-div, r=thomcc
Fix implementation of `Duration::checked_div`

I ran across this while running some sanity checks on `time`. Quickcheck immediately found a bug, and as I'd modified the code from `std` I knew there was a bug here as well.

tl;dr this code fails ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1189a3efcdfc192c27d6d87815359353))

```rust
use std::time::Duration;

fn main() {
    assert_eq!(
        Duration::new(1, 1).checked_div(7),
        Some(Duration::new(0, 142_857_143)),
    );
}
```

The existing code determines that 1/7 = 0 (seconds), 1/7 = 0 (nanoseconds), 1 billion / 7 = 142,857,142 (extra nanoseconds). The billion comes from multiplying the remainder of the seconds (1) by the number of nanoseconds in a second. However, **this wrongly ignores any remaining nanoseconds**. This PR takes that into consideration, adds a test, and also changes the roundabout way of calculating the remainder into directly computing it.

Note: This is _not_ a rounding error. This result divides evenly.

`@rustbot` label +A-time +C-bug +S-waiting-on-reviewer +T-libs
2023-08-28 08:13:57 +02:00
Matthias Krüger
fb98f7adc3
Rollup merge of #109660 - ijackson:leap, r=thomcc
Document that SystemTime does not count leap seconds

Fixes #77994

This may not be entirely uncontroversial.  I know that `@Ekleog` is going to disagree.  However, in support of this docs change:

 This documents the current behaviour.  The alternative would be to plan to *change* the behaviour.

There are many programs which need to get a POSIX time (a `time_t`).  Right now, `duration_since(UNIX_EPOCH)` is the only facility in std that does that.  So, that is what programs use.  Changing the behaviour would  break[1] all of those programs.  We would need to define a new API that can be used to get a POSIX time, and get everyone to use it.  This seems highly unpalatable.

And, even if we wanted to do that, time with leap seconds is a lot less easy to work with.  We would need to arrange to have a leap seconds table available to `std` somehow, and make sure that it was kept up to date.  Currently we don't offer to do that for timezone data, which has similar needs.  There are other complications.  So it seems it would be awkwarrd to *implement* a facility that provides time including leap seconds, and the resulting value would be hard for applications to work with.

Therefore, I think it's clear that we don't want to plan to ever change `SystemTime`.  We should plan to keep it the way it is.  Providing TAI (for example) should be left to external crates, or additional APIs we may add in the future.

For more discussion see #77994 and in particular `@fanf2's` https://github.com/rust-lang/rust/issues/77994#issuecomment-1409448174

[1]  Of course, by "break" we really only mean *future* breakage in the case where there is, in fact, ever another leap second.  There may well not be: they are in the process of being abolished (although this is of course being contested).  But if we decide that `SystemTime::now().duraton_since(UNIX_EPOCH)` counts leap seconds, it would start to return `Durations`s that are 27s different to the current answers.   That's clearly unacceptable.  And we can hardly change `UNIX_EPOCH` by 27s.
2023-08-28 08:13:56 +02:00
bors
41cb42a370 Auto merge of #115296 - saethlin:dont-duplicate-allocs, r=jackh726
Load include_bytes! directly into an Lrc

This PR deletes an innocent-looking `.into()` that was converting from a `Vec<u8>` to `Lrc<[u8]>`. This has significant runtime and memory overhead when using `include_bytes!` to pull in a large binary file.
2023-08-28 05:15:56 +00:00
bors
f7dd70c3c9 Auto merge of #115267 - nikic:revert-elf-relaxation, r=compiler-errors
Revert relax_elf_relocations default change

This reverts commit 4410868798 (#106511).

The change caused linker failures with the binutils version used by cross (#115239), as well as miscompilations when using the mold linker (https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/SIGILL.20in.20build-script-build.20with.20nightly-2023-08-25/near/387506479).
2023-08-28 03:30:37 +00:00
bors
3f8c8f51f7 Auto merge of #115287 - saethlin:more-specialer, r=cjgillot
Add a specialization for encoding byte arrays in rmeta

This specialization already exists for FileEncoder, but since EncodeContext is implemented by forwarding down to FileEncoder, using EncodeContext used to bypass the specialization.
2023-08-28 01:44:41 +00:00
Ben Kimock
f26293dca4 Load include_bytes! directly into an Lrc 2023-08-27 20:16:19 -04:00
bors
1baf77aad0 Auto merge of #115254 - cuviper:aligned_alloc-size, r=thomcc
wasi: round up the size for `aligned_alloc`

C11 `aligned_alloc` requires that the size be a multiple of the
alignment. This is enforced in the wasi-libc emmalloc implementation,
which always returns NULL if the size is not a multiple.
(The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-28 00:02:42 +00:00
Ben Kimock
b233263309 Add a specialization for encoding byte arrays in rmeta 2023-08-27 16:33:33 -04:00
bors
8550f15e14 Auto merge of #115281 - GuillaumeGomez:rollup-yr05a54, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #114974 (Add an (perma-)unstable option to disable vtable vptr)
 - #115261 (replace outdated github username 'ozkanonur')
 - #115266 (Unify CSS color formats a bit more)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-27 19:37:21 +00:00
Ralf Jung
776466d6b7 also ignore doctests 2023-08-27 20:28:29 +02:00
Guillaume Gomez
84891c229c
Rollup merge of #115266 - GuillaumeGomez:unify-css-color-formats, r=notriddle
Unify CSS color formats a bit more

When `rgb` format doesn't have an `rgba` equivalent, I turned it into hex format. I also "decapitalized" hex formats.

r? `@notriddle`
2023-08-27 20:12:49 +02:00
Guillaume Gomez
1095175b51
Rollup merge of #115261 - onur-ozkan:replace-old-username, r=Mark-Simulacrum
replace outdated github username 'ozkanonur'
2023-08-27 20:12:48 +02:00
Guillaume Gomez
8dfbc76f34
Rollup merge of #114974 - nbdd0121:vtable, r=b-naber
Add an (perma-)unstable option to disable vtable vptr

This flag is intended for evaluation of trait upcasting space cost for embedded use cases.

Compared to the approach in #112355, this option provides a way to evaluate end-to-end cost of trait upcasting. Rationale: https://github.com/rust-lang/rust/issues/112355#issuecomment-1658207769

## How this flag should be used (after merge)

Build your project with and without `-Zno-trait-vptr` flag. If you are using cargo, set `RUSTFLAGS="-Zno-trait-vptr"` in the environment variable. You probably also want to use `-Zbuild-std` or the binary built may be broken. Save both binaries somewhere.

### Evaluate the space cost

The option has a direct and indirect impact on vtable space usage. Directly, it gets rid of the trait vptr entry needed to store a pointer to a vtable of a supertrait. (IMO) this is a small saving usually. The larger saving usually comes with the indirect saving by eliminating the vtable of the supertrait (and its parent).

Both impacts only affects vtables (notably the number of functions monomorphized should , however where vtable reside can depend on your relocation model. If the relocation model is static, then vtable is rodata (usually stored in Flash/ROM together with text in embedded scenario). If the binary is relocatable, however, the vtable will live in `.data` (more specifically, `.data.rel.ro`), and this will need to reside in RAM (which may be a more scarce resource in some cases), together with dynamic relocation info living in readonly segment.

For evaluation, you should run `size` on both binaries, with and without the flag. `size` would output three columns, `text`, `data`, `bss` and the sum `dec` (and it's hex version). As explained above, both `text` and `data` may change. `bss` shouldn't usually change. It'll be useful to see:
* Percentage change in text + data (indicating required flash/ROM size)
* Percentage change in data + bss (indicating required RAM size)
2023-08-27 20:12:47 +02:00
Ralf Jung
1087e90a2e avoid triple-backtrace due to panic-during-cleanup 2023-08-27 20:02:46 +02:00
bors
668bf8c593 Auto merge of #115231 - saethlin:dont-ignore-wasm, r=Mark-Simulacrum
Remove some wasm/emscripten ignores

I'm planning on landing a few PRs like this that remove ignores that aren't required. This just covers mir-opt and codegen tests.
2023-08-27 17:51:50 +00:00
Ralf Jung
d7c8950838 tell people what to do when removing an error code 2023-08-27 19:12:42 +02:00
bors
0fe46eed7a Auto merge of #115226 - RalfJung:debug-abi, r=compiler-errors
add rustc_abi debugging attribute

This is the call ABI equivalent of `rustc_layout(debug)`.

Fixes https://github.com/rust-lang/rust/issues/115168
r? `@bjorn3`
2023-08-27 16:06:17 +00:00
bors
f0727758d1 Auto merge of #115139 - cjgillot:llvm-fragment, r=nikic
Do not forget to pass DWARF fragment information to LLVM.

Fixes https://github.com/rust-lang/rust/issues/115113 for the rustc part
2023-08-27 14:06:57 +00:00
bors
9558cdaf2e Auto merge of #115263 - matthiaskrgr:rollup-taqu2h0, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #114924 (coverage: Tidy up `run-coverage` tests in several small ways)
 - #114927 (CI: add more debug logging to Docker caching)
 - #114957 (tests: Fix tests for LoongArch64)
 - #115007 (Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`.)
 - #115098 (rust-gdbgui: remove excessive quotes)
 - #115111 (compile rust-anaylzer with `x check` if it's enabled)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-27 12:19:15 +00:00
bors
d1fb1755aa Auto merge of #115079 - cuviper:unused-mcinfo, r=Mark-Simulacrum
Move a local to the `#if` block where it is used

For other cases (LLVM < 17), this was complaining under `-Wall`:

```
warning: llvm-wrapper/PassWrapper.cpp: In function ‘void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef, const char*)’:
warning: llvm-wrapper/PassWrapper.cpp:311:26: warning: unused variable ‘MCInfo’ [-Wunused-variable]
warning:   311 |   const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
warning:       |                          ^~~~~~
```
2023-08-27 10:32:24 +00:00
Ralf Jung
abe2148aee add rustc_abi debugging attribute 2023-08-27 11:55:49 +02:00
Nikita Popov
1b7cf24d80 Revert "Auto merge of #106511 - MaskRay:gotpcrelx, r=nikic"
This reverts commit 4410868798, reversing
changes made to 249595b752.

This causes linker failures with the binutils version used by
cross (#115239), as well as miscompilations when using the mold
linker.
2023-08-27 11:22:20 +02:00
Guillaume Gomez
fde47b6293 Unify CSS color formats a bit more 2023-08-27 11:02:53 +02:00
Matthias Krüger
ab1123b697
Rollup merge of #115111 - ozkanonur:check-rust-analyzer-if-enabled, r=Mark-Simulacrum
compile rust-anaylzer with `x check` if it's enabled

By default, `x check` doesn't compile the rust-analyzer. But when it's enabled in the config's tools section, there's no reason not to do it. This change allows `x check` to compile rust-analyzer if it's enabled in config's tools section.

Helps to #115031
2023-08-27 09:45:19 +02:00
Matthias Krüger
fd5a8e1261
Rollup merge of #115098 - real-eren:rust-gdbgui-gdbargs-syntax-fix, r=Mark-Simulacrum
rust-gdbgui: remove excessive quotes

Removes the extra quotes introduced in commit 8dd0ec6de7.
Modified script tested and now works on Ubuntu w/ `dash`.

Fixes https://github.com/rust-lang/rust/issues/115097
2023-08-27 09:45:19 +02:00
Matthias Krüger
922b827b8c
Rollup merge of #115007 - kpreid:alloc, r=Mark-Simulacrum
Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`.

The primary goal of this change is to remove the false claim that `handle_alloc_error` always aborts; instead, code should be prepared for `handle_alloc_error` to possibly unwind, and be sound under that condition.

I saw other opportunities for improvement, so I have added all the following information:

* `handle_alloc_error` may panic instead of aborting. (Fixes #114898)
* What happens if a hook returns rather than diverging.
* A hook may panic. (This was already demonstrated in an example, but not stated in prose.)
* A hook must be sound to call — it cannot assume that it is only called by the runtime, since its function pointer can be retrieved by safe code.

I've checked these statements against the source code of `alloc` and `std`, but there may be nuances I haven't caught, so a careful review is welcome.
2023-08-27 09:45:18 +02:00
Matthias Krüger
ce7993670b
Rollup merge of #114957 - loongarch-rs:fix-tests, r=Mark-Simulacrum
tests: Fix tests for LoongArch64

This PR fixes `lp64d abi` tests for LoongArch64.
2023-08-27 09:45:18 +02:00
Matthias Krüger
50dec94121
Rollup merge of #114927 - Kobzol:ci-docker-caching-log, r=Mark-Simulacrum
CI: add more debug logging to Docker caching

Seems like the trouble with the Docker update continues, and rustup has some problems with downloading cached Docker layers from S3 (https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/rustup.20CI.20fails.20to.20install.20Docker.20images.20for.20armv7-linux). This PR adds more logging to Docker caching and busts the cache to rebuild all images.
2023-08-27 09:45:17 +02:00
Matthias Krüger
be416b99ed
Rollup merge of #114924 - Zalathar:tidy-tests, r=Mark-Simulacrum
coverage: Tidy up `run-coverage` tests in several small ways

Prior to #114875 (anonymized line numbers), these tests were very sensitive to lines being added/removed, since doing so would change the line numbers in every subsequent line of output. Therefore they ended up with a few small style issues that weren't worth the hassle of fixing.

Now that we can freely rearrange lines without needing to re-bless the entire output, we can tidy up the tests in various trivial ways.
2023-08-27 09:45:17 +02:00
bors
f320f42c59 Auto merge of #114969 - kpreid:dropdoc, r=Mark-Simulacrum
Go into more detail about panicking in drop.

This patch was sitting around in my drafts. I don't recall the motivation, but I think it was someone expressing confusion over “will likely abort” (since, in fact, a panicking drop _not_ caused by dropping while panicking will predictably _not_ abort).

I hope that the new text will leave people well-informed about why not to panic and when it is reasonable to panic.
2023-08-27 06:12:00 +00:00
ozkanonur
879e106460 replace outdated github username 'ozkanonur'
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-08-27 06:26:02 +03:00
Camille GILLOT
5529e2f893 Restrict test to x86_64. 2023-08-26 22:55:52 +00:00
bors
e877e2a2c9 Auto merge of #115219 - estebank:issue-105306, r=compiler-errors
Point at type parameter that introduced unmet bound instead of full HIR node

```
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
  --> $DIR/issue-87199.rs:18:15
   |
LL |     ref_arg::<[i32]>(&[5]);
   |               ^^^^^ doesn't have a size known at compile-time
```
instead of
```
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
  --> $DIR/issue-87199.rs:18:22
   |
LL |     ref_arg::<[i32]>(&[5]);
   |     ---------------- ^^^^ doesn't have a size known at compile-time
   |     |
   |     required by a bound introduced by this call
```

------

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:24
   |
LL |     let _: <S as D>::P<String>;
   |                        ^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
instead of
```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:12
   |
LL |     let _: <S as D>::P<String>;
   |            ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
Fix #105306.
2023-08-26 22:31:53 +00:00
bors
69e97df5ce Auto merge of #115224 - spastorino:remove-lub_empty, r=lcnr
Remove lub_empty from lexical region resolve

As of my understanding this method made sense when we had `ReEmpty`.
Removed `lub_empty` and made the calling site code equivalent.

r? `@lcnr` `@compiler-errors`
2023-08-26 20:45:46 +00:00
Esteban Küber
7411e25abe Account for Weak alias kinds when adding more targetted obligation 2023-08-26 20:10:19 +00:00
Esteban Küber
ef11db803c Remove unnecessary select_obligations_where_possible and redundant errors 2023-08-26 19:35:54 +00:00
Esteban Küber
b6494a7bb4 More accurately point at arguments 2023-08-26 19:25:46 +00:00
Josh Stone
1c6d867d78 wasi: round up the size for aligned_alloc
C11 `aligned_alloc` requires that the size be a multiple of the
alignment. This is enforced in the wasi-libc emmalloc implementation,
which always returns NULL if the size is not a multiple.
(The default `MALLOC_IMPL=dlmalloc` does not currently check this.)
2023-08-26 11:50:16 -07:00
Camille GILLOT
930b2e72ee Do not produce fragment for ZST. 2023-08-26 16:54:28 +00:00
Santiago Pastorino
b92840accf
Merge if and match expressions that don't make sense to have separated 2023-08-26 13:37:43 -03:00
Camille GILLOT
f49494ecce Add test with non-ZST. 2023-08-26 14:21:10 +00:00
Camille GILLOT
b3bbc22cb7 Do not forget to pass DWARF fragment information to LLVM. 2023-08-26 14:21:10 +00:00
bors
22d41ae90f Auto merge of #115198 - Zoxc:query-panic-wait, r=cjgillot
Fix waiting on a query that panicked

This fixes waiting on a query that panicked. The code now looks for `QueryResult::Poisoned` in the query state in addition to the query cache. This fixes https://github.com/rust-lang/rust/issues/111528.

r? `@cjgillot`
2023-08-26 14:15:14 +00:00
bors
7646ece988 Auto merge of #115246 - matthiaskrgr:rollup-zdiw9gt, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #115197 (Remove special cases that are no longer needed due to #112606)
 - #115210 (Make `rustc_on_unimplemented` std-agnostic for `alloc::rc`)
 - #115237 (Fixup sparc-unknown-none-elf table spacing)
 - #115244 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-26 11:19:48 +00:00