Commit Graph

232831 Commits

Author SHA1 Message Date
Martin Nordholts
789451b43a Allow large_assignments for Box/Arc/Rc initialization
Does the `stop linting in box/arc initialization` task of 83518.
2023-09-03 08:15:25 +02:00
bors
bb90f81070 Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkov
Move tests

r? `@petrochenkov`
2023-08-29 13:53:34 +00:00
bors
6d32b298ed Auto merge of #114894 - Zoxc:sharded-cfg-cleanup2, r=cjgillot
Remove conditional use of `Sharded` from query state

`Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job.

r? `@cjgillot`
2023-08-29 12:04:37 +00:00
bors
0b84f18b24 Auto merge of #115277 - RalfJung:is_1zst, r=davidtwco
fix some issues around ZST handling

This fixes two bugs:
- We used to entirely skip enum variants like `B([u16; 0], !)`, even failing to properly align the enum!  Honoring the alignment of uninhabited variants is important for the same reason that we must reserve space for their fields -- see [here](https://github.com/rust-lang/rust/issues/49298#issuecomment-380615281) for why.
- ~~We uses to reject `repr(transparent)` on `struct MyType([u16; 0])`, which is weird because a one-field struct should always be allowed to be transparent around that field.~~ (moved to separate PR)

I also found two places in the layout code that did something special for ZST without explaining why, and removing those special cases doesn't seem to have any effect except for reordering some zero-sized fields which shouldn't be an issue... maybe PR CI will explain why those cases were needed, or maybe they became obsolete at some point.
2023-08-29 10:22:35 +00:00
bors
f6faef4475 Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay
make Cell::swap panic if the Cells partially overlap

The following function ought to be sound:
```rust
fn as_cell_of_array<T, const N: usize>(c: &[Cell<T>; N]) -> &Cell<[T; N]> {
    unsafe { transmute(c) }
}
```
However, due to `Cell::swap`, it currently is not -- safe code can [cause a use-after-free](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c9415799722d985ff7d2c2c997b724ca). This PR fixes that.

Fixes https://github.com/rust-lang/rust/issues/80778
2023-08-29 07:53:56 +00:00
Ralf Jung
b2ebf1c23f const_eval and codegen: audit uses of is_zst 2023-08-29 09:03:46 +02:00
Ralf Jung
bf91321e0f there seems to be no reason to treat ZST specially in these cases 2023-08-29 08:58:58 +02:00
Ralf Jung
0da9409e08 rustc_abi: audit uses of is_zst; fix a case of giving an enum insufficient alignment 2023-08-29 08:58:58 +02:00
Ralf Jung
0360b6740b add is_1zst helper method 2023-08-29 08:58:21 +02:00
bors
cedbe5c715 Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay
Add note that Vec::as_mut_ptr() does not materialize a reference to the internal buffer

See discussion on https://github.com/thomcc/rust-typed-arena/issues/62 and [t-opsem](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/is.20this.20typed_arena.20code.20sound.20under.20stacked.2Ftree.20borrows.3F)

This method already does the correct thing here, but it is worth guaranteeing that it does so it can be used more freely in unsafe code without having to worry about potential Stacked/Tree Borrows violations. This moves one more unsafe usage pattern from the "very likely sound but technically not fully defined" box into "definitely sound", and currently our surface area of the latter is woefully small.

I'm not sure how best to word this, opening this PR as a way to start discussion.
2023-08-29 06:04:55 +00:00
bors
a517049d8c Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc
fix(sys/hermit): add is_interrupted

https://github.com/rust-lang/rust/pull/115228 broke compilation for Hermit by not adding a Hermit implementation of is_interrupted.
2023-08-29 04:11:13 +00:00
bors
f3284dc3ad Auto merge of #115260 - scottmcm:not-quite-so-cold, r=WaffleLapkin
Use `preserve_mostcc` for `extern "rust-cold"`

As experimentation in #115242 has shown looks better than `coldcc`.  Notably, clang exposes `preserve_most` (https://clang.llvm.org/docs/AttributeReference.html#preserve-most) but not `cold`, so this change should put us on a better-supported path.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse. (See comment in the code.)

cc tracking issue #97544
2023-08-29 02:23:43 +00:00
bors
fef2f5907f Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper
fix(sys/hermit): remove obsolete network initialization

This function does not exist as of hermit-sys 0.4.1 ([`e38f246`]). Once std does not call this function, we can remove it entirely.

CC: `@stlankes`

[`e38f246`]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)
2023-08-29 00:37:48 +00:00
bors
191dc54dbf Auto merge of #115182 - RalfJung:abi-compat-sign, r=b-naber
miri ABI compatibility check: accept u32 and i32

If only the sign differs, then surely these types are compatible. (We do still check that `arg_ext` is the same, just in case.)

Also I made it so that the ABI check must *imply* that size and alignment are the same, but it doesn't actively check that itself. With how crazy ABI constraints get, having equal size and align really shouldn't be used as a signal for anything I think...
2023-08-28 22:56:10 +00:00
Caio
5a69151d7d Move tests 2023-08-28 17:47:37 -03:00
bors
4e78abb437 Auto merge of #115326 - matthiaskrgr:rollup-qsoa8ar, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115164 (MIR validation: reject in-place argument/return for packed fields)
 - #115240 (codegen_llvm/llvm_type: avoid matching on the Rust type)
 - #115294 (More precisely detect cycle errors from type_of on opaque)
 - #115310 (Document panic behavior across editions, and improve xrefs)
 - #115311 (Revert "Suggest using `Arc` on `!Send`/`!Sync` types")
 - #115317 (Devacationize oli-obk)
 - #115319 (don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead)
 - #115322 (Tweak output of `to_pretty_impl_header` involving only anon lifetimes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-28 19:57:32 +00:00
bors
93dd620241 Auto merge of #114489 - compiler-errors:rpitit-capture-all, r=oli-obk
Make RPITITs capture all in-scope lifetimes

Much like #114616, this implements the lang team decision from this T-lang meeting on [opaque captures strategy moving forward](https://hackmd.io/sFaSIMJOQcuwCdnUvCxtuQ?view). This will be RFC'd soon, but given that RPITITs are a nightly feature, this shouldn't necessarily be blocked on that.

We unconditionally capture all lifetimes in RPITITs -- impl is not as simple as #114616, since we still need to duplicate RPIT lifetimes to make sure we reify any late-bound lifetimes in scope.

Closes #112194
2023-08-28 18:05:16 +00:00
Matthias Krüger
07a32e2dbd
Rollup merge of #115322 - estebank:list-tweak, r=compiler-errors
Tweak output of `to_pretty_impl_header` involving only anon lifetimes

Do not print `impl<> Foo for &Bar`.
2023-08-28 19:53:59 +02:00
Matthias Krüger
de6b03b4f1
Rollup merge of #115319 - klensy:no-snapshot-in-graph, r=WaffleLapkin
don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead

`Graph` don't use `SnapshotVec` methods, so use simple `Vec` instead?
2023-08-28 19:53:58 +02:00
Matthias Krüger
7b6d2647c8
Rollup merge of #115317 - oli-obk:no_moar_vacation, r=oli-obk
Devacationize oli-obk

r? `@oli-obk`

`@bors` r+ rollup
2023-08-28 19:53:57 +02:00
Matthias Krüger
9b0abe3537
Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errors
Revert "Suggest using `Arc` on `!Send`/`!Sync` types"

Closes https://github.com/rust-lang/rust/issues/114687. This is a clean revert of https://github.com/rust-lang/rust/pull/88936 + https://github.com/rust-lang/rust/pull/115210. The suggestion to Arc\<{Self}\> when Self does not implement Send is *always* wrong.

https://github.com/rust-lang/rust/pull/114842 is considering a way to make a more refined suggestion.
2023-08-28 19:53:57 +02:00
Matthias Krüger
2eff0deca3
Rollup merge of #115310 - RalfJung:panic-and-format, r=scottmcm
Document panic behavior across editions, and improve xrefs

This revives (parts of) https://github.com/rust-lang/rust/pull/96518.
r? `@scottmcm`
Cc `@ijackson`
2023-08-28 19:53:56 +02:00
Matthias Krüger
b4c63f06e8
Rollup merge of #115294 - compiler-errors:cycle-err, r=oli-obk
More precisely detect cycle errors from type_of on opaque

Not sure if this still needs work. Just putting it up for initial impressions, since it seems that a few people are frustrated with the increased error verbosity due to #113320.

Essentially we introduce a new sub-query for `type_of` specifically for opaques which returns a value that is able to distinguish "has errors" from "due to cycle recovery".

Fixes #115188

r? `@oli-obk`
2023-08-28 19:53:56 +02:00
Matthias Krüger
a5b7504f41
Rollup merge of #115240 - RalfJung:llvm-no-type, r=bjorn3
codegen_llvm/llvm_type: avoid matching on the Rust type

This `match` is highly suspicious. Looking at `scalar_llvm_type_at` I think it makes no difference. But if it were to make a difference that would be a huge problem, since it doesn't look through `repr(transparent)`!

Cc `@eddyb` `@bjorn3`
2023-08-28 19:53:55 +02:00
Matthias Krüger
88b476c388
Rollup merge of #115164 - RalfJung:no-in-place-packed, r=b-naber
MIR validation: reject in-place argument/return for packed fields

As discussed [here](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Packed.20fields.20and.20in-place.20function.20argument.2Freturn.20passing).
2023-08-28 19:53:54 +02:00
Esteban Küber
ecf2f68e45 Tweak output of to_pretty_impl_header involving only anon lifetimes
Do not print `impl<> Foo for &Bar`.
2023-08-28 17:17:11 +00:00
Ralf Jung
9b9cb51a40 remove an unused argument
it was already unused before, but due to the recursion the compiler did not realize
2023-08-28 18:21:16 +02:00
klensy
3b26b3d1d2 don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead 2023-08-28 18:59:55 +03:00
Oli Scherer
5a4ba686e3 Devacationize oli-obk 2023-08-28 15:33:09 +00:00
bors
9f48a85447 Auto merge of #115050 - khei4:khei4/codegen-move-before-nocapture, r=nikic
add codegen test for the move before passing to nocapture, by shared-ref arg

This PR adds codegen test for https://github.com/rust-lang/rust/issues/107436#issuecomment-1685792517 (It seems like this works from llvm-16?)

Fixes #107436
2023-08-28 15:30:28 +00:00
Ralf Jung
99d76a4027 carry out the same changes in the gcc backend 2023-08-28 16:35:22 +02:00
Ralf Jung
dc70fb6528 also avoid matching on the type in scalar_pair_element_llvm_type 2023-08-28 16:35:00 +02:00
bors
c587fd4185 Auto merge of #114774 - Enselic:less-move-size-noise, r=oli-obk
Avoid duplicate `large_assignments` lints

By checking for overlapping spans.

This PR does the "reduce noisiness" task in #83518.

r? `@oli-obk` who added E-mentor and E-help-wanted and wrote the initial code.

(The fix itself is in dc82736677. The two commits before that are just small refactorings.)
2023-08-28 13:36:19 +00:00
bors
9847c6406d Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDenton
Add ability to spawn Windows process with Proc Thread Attributes | Take 2

This is the second attempt to merge pull request #88193 into the standard library.

This PR implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait.

`@TyPR124` and my main motivation behind adding this feature is to enable the support of pseudo terminals in the std library, but there are many more applications. A good starting point to get into this topic is to head over to the [`Win32 API documentation`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute).
2023-08-28 10:55:05 +00:00
Martin Kröning
eee27331ba
fix(sys/hermit): add is_interrupted
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28 12:42:12 +02:00
Martin Kröning
5853c2bdd3
fix(sys/hermit): remove obsolete network initialization
This function does not exist as of hermit-sys 0.4.1 [1].
Once std does not call this function, we can remove it entirely.

[1]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2023-08-28 12:37:42 +02:00
David Tolnay
823bacb6e3
Revert "Suggest using Arc on !Send/!Sync types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
David Tolnay
4120936f6d
Revert "Make rustc_on_unimplemented std-agnostic for alloc::rc"
This reverts commit 6ec570aca5.
2023-08-28 03:16:42 -07:00
Ralf Jung
5016695357 improve panic.md edition disucssion, and nits 2023-08-28 12:11:19 +02:00
Ian Jackson
39c642e3d2 format, format_args: Make xref to std::fmt much more prominent
That xref contains the actual documentation for what format! does.
It should be very prominent - particularly, more so than the other
links.
2023-08-28 11:54:40 +02:00
Ian Jackson
2ec8b6b50f panic macro: Link directly to format syntax, not to format! 2023-08-28 11:52:21 +02:00
Ian Jackson
55159e80ad print macros: add xrefs to format syntax documentation 2023-08-28 11:51:41 +02:00
Ian Jackson
11167071db panic macro: Document edition differences
Having a section for this inspired by the docs for array::IntoIterator
2023-08-28 11:50:38 +02:00
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