Commit Graph

207989 Commits

Author SHA1 Message Date
Yuki Okushi
166f664037
Rollup merge of #102023 - SUPERCILEX:maybeuninit-transpose, r=scottmcm
Add MaybeUninit array transpose From impls

See discussion in https://github.com/rust-lang/rust/pull/101179 and https://github.com/rust-lang/rust/issues/96097. I believe this solution offers the simplest implementation with minimal future API regret.

`@RalfJung` mind doing a correctness review?
2022-10-16 11:41:12 +09:00
Yuki Okushi
cbc0a73c95
Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu
Add documentation about the memory layout of `UnsafeCell<T>`

The documentation for `UnsafeCell<T>` currently does not make any promises about its memory layout. This PR adds this documentation, namely that the memory layout of `UnsafeCell<T>` is the same as the memory layout of its inner `T`.

# Use case
Without this layout promise, the following cast would not be legally possible:

```rust
fn example<T>(ptr: *mut T) -> *const UnsafeCell<T> {
  ptr as *const UnsafeCell<T>
}
```

A use case where this can come up involves FFI. If Rust receives a pointer over a FFI boundary which provides shared read-write access (with some form of custom synchronization), and this pointer is managed by some Rust struct with lifetime `'a`, then it would greatly simplify its (internal) API and safety contract if a `&'a UnsafeCell<T>` can be created from a raw FFI pointer `*mut T`. A lot of safety checks can be done when receiving the pointer for the first time through FFI (non-nullness, alignment, initialize uninit bytes, etc.) and these properties can then be encoded into the `&UnsafeCell<T>` type. Without this documentation guarantee, this is not legal today outside of the standard library.

# Caveats
Casting in the opposite direction is still not valid, even with this documentation change:

```rust
fn example2<T>(ptr: &UnsafeCell<T>) -> &mut T {
  let t = ptr as *const UnsafeCell<T> as *mut T;
  unsafe { &mut *t }
}
```

This is because the only legal way to obtain a mutable pointer to the contents of the shared reference is through [`UnsafeCell::get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get) and [`UnsafeCell::raw_get`](https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.raw_get). Although there might be a desire to also make this legal at some point in the future, that part is outside the scope of this PR. Also see this relevant [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/transmuting.20.26.20-.3E.20.26mut).

# Alternatives
Instead of adding a new documentation promise, it's also possible to add a new method to `UnsafeCell<T>` with signature `pub fn from_ptr_bikeshed(ptr: *mut T) -> *const UnsafeCell<T>` which indirectly only allows one-way casting to `*const UnsafeCell<T>`.
2022-10-16 11:41:12 +09:00
bors
75dbd5b8c3 Auto merge of #102931 - camsteffen:inline-overlapping-impls, r=cjgillot
Make `overlapping_impls` not generic

Trying to win back perf from #101632.
2022-10-16 02:05:30 +00:00
Alex Saveau
393434c29e
Add MaybeUninit array transpose impls
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-15 15:57:19 -07:00
bors
ddc7fd9837 Auto merge of #100579 - joboet:sync_mutex_everywhere, r=thomcc
std: use `sync::Mutex` for internal statics

Since `sync::Mutex` is now `const`-constructible, it can be used for internal statics, removing the need for `sys_common::StaticMutex`. This adds some extra allocations on platforms which need to box their mutexes (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740.

I changed the program argument implementation on Hermit, it does not need `Mutex` but can use atomics like some UNIX systems (ping `@mkroening` `@stlankes).`
2022-10-15 22:49:30 +00:00
Scott McMurray
5b9a02a87d More slice::partition_point examples 2022-10-15 14:03:56 -07:00
Vadim Petrochenkov
f767f2297d resolve: Shadow erroneous glob imports with erroneous single imports 2022-10-16 00:10:16 +04:00
Michael Howell
65f501e10f rustdoc: add test cases for links inside the help popover 2022-10-15 12:06:16 -07:00
Michael Howell
f0371d1238 rustdoc: update test cases for .sidebar-title -> .sidebar-elems h3 2022-10-15 11:53:53 -07:00
Michael Howell
6f59981a7a rustdoc: fix Ctrl-Click on help and settings links 2022-10-15 11:45:27 -07:00
Michael Howell
ae4ad9adb6 rustdoc: make the help button a link to a page
This allows you to open the help section in a new browser tab, which is a
pretty reasonable thing to want for a documentation page.
2022-10-15 11:38:42 -07:00
Michael Howell
e9b2922804 rustdoc: remove unused HTML class sidebar-title
Since 6a5f8b1aef, this class is no
longer styled.
2022-10-15 11:24:49 -07:00
Michael Goulet
4259f33305 typos 2022-10-15 17:49:32 +00:00
Michael Goulet
e994de803d Equate full fn signatures to infer all region variables 2022-10-15 17:46:05 +00:00
Michael Goulet
cb20758257 Add test 2022-10-15 17:46:04 +00:00
Michael Goulet
c1aa9bf849 Fix subst issues with RPITIT 2022-10-15 17:46:03 +00:00
Volkan Sagcan
dd4d3f0a09 fix #13105: Ignore auto-import assist on parameter names 2022-10-15 18:00:32 +02:00
philipp
4854e37dbc Documentation BTreeMap::append's behavior for already existing keys 2022-10-15 17:47:07 +02:00
Camille GILLOT
16e22e143d Mark derived StructuralEq as automatically derived. 2022-10-15 15:16:32 +00:00
Yutaro Ohno
7334526c38 pretty: fix to print some lifetimes on HIR pretty-print 2022-10-15 23:34:21 +09:00
Guillaume Gomez
11a40ec5ff Add more GUI tests for settings page 2022-10-15 15:59:11 +02:00
Guillaume Gomez
e14d2efba3 Fix display of settings page 2022-10-15 15:59:00 +02:00
bors
b8c35ca26b Auto merge of #102895 - Nilstrieb:query-cleanups, r=cjgillot
Get rid of `rustc_query_description!`

**I am not entirely sure whether this is an improvement and would like to get your feedback on it.**

Helps with #96524.

Queries can provide an arbitrary expression for their description and their caching behavior. Before, these expressions where stored in a `rustc_query_description` macro emitted by the `rustc_queries` macro, and then used in `rustc_query_impl` to fill out the methods for the `QueryDescription` trait.

Instead, we now emit two new modules from `rustc_queries` containing the functions with the expressions. `rustc_query_impl` calls these functions now instead of invoking the macro.

Since we are now defining some of the functions in `rustc_middle::query`, we now need all the imports for the key types mthere as well.

r? `@cjgillot`
2022-10-15 13:30:15 +00:00
bors
5174d3d030 Auto merge of #13419 - lnicola:bump-setup-node, r=lnicola
Bump `actions/setup-node`

Fixes more Node 12 deprecation warnings.
2022-10-15 11:48:14 +00:00
Laurențiu Nicola
7bf6f188de Bump actions/setup-node 2022-10-15 14:47:53 +03:00
bors
855cd5c280 Auto merge of #13418 - lnicola:bump-deps, r=lnicola
Bump deps
2022-10-15 11:27:12 +00:00
Laurențiu Nicola
342764d31a Add new license 2022-10-15 14:26:30 +03:00
bors
c93ef33700 Auto merge of #103083 - Dylan-DPC:rollup-97cvwdv, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #102773 (Use semaphores for thread parking on Apple platforms)
 - #102884 (resolve: Some cleanup, asserts and tests for lifetime ribs)
 - #102954 (Add missing checks for `doc(cfg_hide(...))`)
 - #102998 (Drop temporaries created in a condition, even if it's a let chain)
 - #103003 (Fix `suggest_floating_point_literal` ICE)
 - #103041 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-15 10:45:36 +00:00
Dylan DPC
ac23c9fde9
Rollup merge of #103041 - weihanglo:update-cargo, r=ehuss
Update cargo

12 commits in b8f30cb23c4e5f20854a4f683325782b7cff9837..b332991a57c9d055f1864de1eed93e2178d49440 2022-10-10 19:16:06 +0000 to 2022-10-13 22:05:28 +0000
- Differentiate the warning when an alias (built-in or user-defined) shadows an external subcommand (rust-lang/cargo#11170)
- chore: Update tests for latest clap (rust-lang/cargo#11235)
- feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout' (rust-lang/cargo#11230)
- Add missing edition (rust-lang/cargo#11231)
- doc(profiles): add module level doc (rust-lang/cargo#11219)
- refactor(publish): Clarify which SourceId is being used (rust-lang/cargo#11216)
- Add new SourceKind::SparseRegistry to differentiate sparse registries (rust-lang/cargo#11209)
- Fix deadlock when build scripts are waiting for input on stdin (rust-lang/cargo#11205)
- refactor: New variant `FeaturesFor::ArtifactDep` (rust-lang/cargo#11184)
- Fix rustdoc warning about unclosed HTML tag (rust-lang/cargo#11221)
- refactor(tests): Prepare for wait-for-publish test changes (rust-lang/cargo#11210)
- Add configuration option for controlling crates.io protocol (rust-lang/cargo#11215)
2022-10-15 15:45:33 +05:30
Dylan DPC
65dca11514
Rollup merge of #103003 - TaKO8Ki:fix-102989, r=compiler-errors
Fix `suggest_floating_point_literal` ICE

Fixes #102989
2022-10-15 15:45:33 +05:30
Dylan DPC
b79ad57ad7
Rollup merge of #102998 - nathanwhit:let-chains-drop-order, r=eholk
Drop temporaries created in a condition, even if it's a let chain

Fixes #100513.

During the lowering from AST to HIR we wrap expressions acting as conditions in a `DropTemps` expression so that any temporaries created in the condition are dropped after the condition is executed. Effectively this means we transform

```rust
if Some(1).is_some() { .. }
```

into (roughly)

```rust
if { let _t = Some(1).is_some(); _t } { .. }
```

so that if we create any temporaries, they're lifted into the new scope surrounding the condition, so for example something along the lines of

```rust
if { let temp = Some(1); let _t = temp.is_some(); _t }.
```

Before this PR, if the condition contained any let expressions we would not introduce that new scope, instead leaving the condition alone. This meant that in a let-chain like

```rust
if get_drop("first").is_some() && let None = get_drop("last") {
        println!("second");
} else { .. }
```

the temporary created for `get_drop("first")` would be lifted into the _surrounding block_, which caused it to be dropped after the execution of the entire `if` expression.

After this PR, we wrap everything but the `let` expression in terminating scopes. The upside to this solution is that it's minimally invasive, but the downside is that in the worst case, an expression with `let` exprs interspersed like

```rust
if get_drop("first").is_some()
    && let Some(_a) = get_drop("fifth")
    && get_drop("second").is_some()
    && let Some(_b) = get_drop("fourth") { .. }
```

gets _multiple_ new scopes, roughly

```rust
if { let _t = get_drop("first").is_some(); _t }
    && let Some(_a) = get_drop("fifth")
    && { let _t = get_drop("second").is_some(); _t }
    && let Some(_b) = get_drop("fourth") { .. }
```

so instead of all of the temporaries being dropped at the end of the entire condition, they will be dropped right after they're evaluated (before the subsequent `let` expr). So while I'd say the drop behavior around let-chains is _less_ surprising after this PR, it still might not exactly match what people might expect.

For tests, I've just extended the drop order tests added in #100526. I'm not sure if that's the best way to go about it, though, so suggestions are welcome.
2022-10-15 15:45:32 +05:30
Dylan DPC
59e0af68ab
Rollup merge of #102954 - GuillaumeGomez:cfg-hide-attr-checks, r=Manishearth
Add missing checks for `doc(cfg_hide(...))`

Part of  #43781.

The `doc(cfg_hide(...))` attribute can only be used at the crate level and takes a list of attributes as argument.

r? ```@Manishearth```
2022-10-15 15:45:32 +05:30
Dylan DPC
39ff2a60d6
Rollup merge of #102884 - petrochenkov:liferib, r=cjgillot
resolve: Some cleanup, asserts and tests for lifetime ribs

Follow up to https://github.com/rust-lang/rust/pull/98279 and friends.
r? ``@cjgillot``
2022-10-15 15:45:31 +05:30
Dylan DPC
cbe5e7bc62
Rollup merge of #102773 - joboet:apple_parker, r=thomcc
Use semaphores for thread parking on Apple platforms

Currently we use a mutex-condvar pair for thread parking on Apple systems. Unfortunately, `pthread_cond_timedwait` uses the real-time clock for measuring time, which causes problems when the system time changes. The parking implementation in this PR uses a semaphore instead, which measures monotonic time by default, avoiding these issues. As a further benefit, this has the potential to improve performance a bit, since `unpark` does not need to wait for a lock to be released.

Since the Mach semaphores are poorly documented (I could not find availability or stability guarantees for instance), this uses a [dispatch semaphore](https://developer.apple.com/documentation/dispatch/dispatch_semaphore?language=objc) instead. While it adds a layer of indirection (it uses Mach semaphores internally), the overhead is probably negligible.

Tested on macOS 12.5.

r? ``````@thomcc``````
2022-10-15 15:45:30 +05:30
Laurențiu Nicola
b513111f3c Bump the rest of the deps 2022-10-15 13:06:10 +03:00
Laurențiu Nicola
119e1bafcc Bump notify 2022-10-15 13:03:39 +03:00
Laurențiu Nicola
f5bbf9a06a Bump proc-macro2 2022-10-15 13:02:10 +03:00
Laurențiu Nicola
792920f441 Bump pulldown-cmark-to-cmark 2022-10-15 13:00:41 +03:00
Laurențiu Nicola
275848803b Bump mimalloc 2022-10-15 12:59:56 +03:00
Laurențiu Nicola
39777bf941 Bump rowan 2022-10-15 12:58:57 +03:00
Gimgim
49f34bd814
Surround type with backticks 2022-10-15 15:28:29 +05:30
Laurențiu Nicola
97eebbfab6 Bump url 2022-10-15 12:57:30 +03:00
Laurențiu Nicola
e294640484 Bump libc 2022-10-15 12:55:56 +03:00
Laurențiu Nicola
3a5f6a705e Bump dashmap 2022-10-15 12:54:25 +03:00
Laurențiu Nicola
6e74a22918 Bump home 2022-10-15 12:53:26 +03:00
Laurențiu Nicola
bb6990c4c9 Bump tracing 2022-10-15 12:52:34 +03:00
Laurențiu Nicola
50f990c46f Bump smallvec 2022-10-15 12:52:34 +03:00
Laurențiu Nicola
cbce0cda08 Bump anyhow, arbitrary, itertools, semver, serde 2022-10-15 12:52:34 +03:00
Andy Fiddaman
f3deac2559 The illumos linker does not support --strip-debug 2022-10-15 08:21:52 +00:00
bors
b15e2c129e Auto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk
Make `dyn*` casts into a coercion, allow `dyn*` upcasting

I know that `dyn*` is likely not going to be a feature exposed to surface Rust, but this makes it slightly more ergonomic to write tests for these types anyways. ... and this was just fun to implement anyways.

1. Make `dyn*` into a coercion instead of a cast
2. Enable `dyn*` upcasting since we basically get it for free
3. Simplify some of the cast checking code since we're using the coercion path now

r? `@eholk` but feel free to reassign
cc `@nikomatsakis` and `@tmandry` who might care about making `dyn*` casts into a coercion
2022-10-15 07:36:38 +00:00