Commit Graph

235386 Commits

Author SHA1 Message Date
bors
3b08930677 Auto merge of #3112 - RalfJung:rustup, r=RalfJung
Rustup

preparing for rustc-push
2023-10-06 16:25:15 +00:00
Ralf Jung
100ea2b499 Merge from rustc 2023-10-06 18:15:20 +02:00
ShE3py
3706e6f61a
Use io_error_more on WASI 2023-10-06 19:05:45 +02:00
Ralf Jung
ea56007362 Preparing for merge from rustc 2023-10-06 18:15:12 +02:00
bors
375ff3e5ce Auto merge of #3110 - eduardosm:rounding-without-host-floats, r=RalfJung
Do not use host floats in `simd_{ceil,floor,round,trunc}`
2023-10-06 15:44:37 +00:00
bors
3c511bb417 Auto merge of #3067 - Vanille-N:spurious-incremental, r=RalfJung
Continuation of #3054: enable spurious reads in TB

The last additions to the test suite of TB left some unresolved `#[should_panic]` that these new modifications solve.

## Problem

Recall that the issues were arising from the interleavings that follow.

### A. `Reserved -> Frozen` has visible effects after function exit

The transition `Reserved -> Frozen` irreversibly blocks write accesses to the tag, so in the interleaving below `y` initially `Reserved` becomes `Frozen` only in the target where a spurious read through `x` is inserted. This makes the later write through `y` UB only in the target and not in the source.
```
1: retag x (&, protect)
2: retag y (&mut, protect)
1: spurious read x
1: ret x
2: ret y
2: write y
```

### B. Protectors only announce their presence on retag

There is a read-on-reborrow for protected locations, but if the retag of `x` occurs before that of `y` and there is no explicit access through `x`, then `y` is unaware of the existence of `x`. This is problematic because a spurious read inserted through `x` between the retag of `y` and the return of the function protecting `x` is a noalias violation in the target without UB in the source.
```
1: retag x (&, protect)
2: retag y (&mut, protect)
1: spurious read x
1: ret x
2: write y
2: ret y
```

## Step 1: Finer behavior for `Reserved`

Since one problem is that `Reserved -> Frozen` has consequences beyond function exit, we decide to remove this transition entirely. To replace it we introduce a new subtype of `Reserved` with the extra boolean `aliased` set.
`Reserved { aliased: true }` forbids child accesses, but only temporarily: it has no effect on activation once the tag is no longer protected.
This makes the semantics of Tree Borrows slightly weaker in favor of being more similar to noalias.

This solves interleaving **A.**, but **B.** is still a problem and the exhaustive tests do not pass yet.

## Step 2: Read on function exit

Protected tags issue a "reminder" that they are protected until this instant inclusive, in the form of an implicit read (symmetrically to the implicit read on retag). This ensures that if the periods on which two tags `x` and `y` are protected overlap then no matter the interleaving of retags and returns, there is either a protector currently active or a read that has been emitted, both of which temporarily block activation.

This makes the exhaustive test designed previously pass, but it has an effect on the ability to return an activated pointer that I had not foreseen before implementing it.

## Step 2': Do not propagate to children

A naive implementation of **Step 2** makes the following code UB:
```rs
fn reborrow(x: &mut u8) -> &mut u8 {
    let y = &mut *x;
    *y = *y;
    y // callee returns `y: Active`...
}

let x = &mut 0u8;
let y = reborrow(x); // ... and caller receives `y: Frozen`
*y = 1; // UB
```
This is unacceptable, and a simple fix is to make this implicit read visible only to foreign tags.

We still lack hindsight on the ramifications of this decision, and the fact that the problematic pattern was only discovered because it occured in one completely unrelated test (with a cryptic error message) is worrying. We should be vigilant as to how this interacts with the rest of the model.

## TODO

As of commit #281c30, the data race model has not been fully updated.
We have removed the reborrow of mutable references counting as a write access, but we still need the implicit read of function exit to count as a read.
2023-10-06 14:58:31 +00:00
Eduardo Sánchez Muñoz
e1e880e9c6 Do not use host floats in simd_{ceil,floor,round,trunc} 2023-10-06 15:12:36 +02:00
bors
1bc0463b18 Auto merge of #116483 - GuillaumeGomez:rollup-z65pno1, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #115454 (Clarify example in docs of str::char_slice)
 - #115522 (Clarify ManuallyDrop bit validity)
 - #115588 (Fix a comment in std::iter::successors)
 - #116198 (Add more diagnostic items for clippy)
 - #116329 (update some comments around swap())
 - #116475 (rustdoc-search: fix bug with multi-item impl trait)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 13:07:15 +00:00
Neven Villani
bf1356efc3
Fix problems of Reserved -> Frozen
Reserved loses permissions too quickly.
Adding more fine-grained behavior of Reserved lets it lose
write permissions only temporarily.
Protected tags receive a read access on initialized locations.
2023-10-06 14:37:07 +02:00
Guillaume Gomez
5674092e76
Rollup merge of #116475 - notriddle:notriddle/impl-trait-null, r=GuillaumeGomez
rustdoc-search: fix bug with multi-item impl trait

Preview searches:

- https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=-%3E%20globalctxt

- https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=globalctxt
2023-10-06 13:18:35 +02:00
Guillaume Gomez
9e28a9349c
Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcm
update some comments around swap()

Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410).

And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-06 13:18:35 +02:00
Guillaume Gomez
3785fed021
Rollup merge of #116198 - Jarcho:diag_items, r=WaffleLapkin
Add more diagnostic items for clippy
2023-10-06 13:18:34 +02:00
Guillaume Gomez
382701e6b6
Rollup merge of #115588 - tifv:fix-comment-successors, r=scottmcm
Fix a comment in std::iter::successors

The `unfold` function have since #58062 been renamed to `from_fn`.
(I'm not sure if this whole comment is still useful—it's not like there are many iterators that *can't* be based on `from_fn`. Anyway, in its current form this comment is not correct, and it sent me into a half-hour research of what happened to `unfold` function, so I want to do *something* with it 🙃 deleting these three lines is a perfectly fine alternative, in my opinion.)
2023-10-06 13:18:34 +02:00
Guillaume Gomez
525c661842
Rollup merge of #115522 - joshlf:patch-8, r=scottmcm
Clarify ManuallyDrop bit validity

Clarify that `ManuallyDrop<T>` has the same bit validity as `T`.
2023-10-06 13:18:33 +02:00
Guillaume Gomez
4e818f6b72
Rollup merge of #115454 - vwkd:patch-1, r=scottmcm
Clarify example in docs of str::char_slice

Just a one word improvement.

“Last” can be misread as meaning the last (third) instead of the previous (first).
2023-10-06 13:18:33 +02:00
bors
6683f13fa1 Auto merge of #111595 - fortanix:raoul/waitqueue_clarifications, r=workingjubilee
`waitqueue` clarifications for SGX platform

The documentation of `waitqueue` functions on the `x86_64-fortanix-unknown-sgx` platform is incorrect at some places and on others missing. This PR improves upon this.

cc: `@jethrogb`
2023-10-06 11:12:13 +00:00
bors
4587c7c1c0 Auto merge of #3109 - RalfJung:dlsym, r=RalfJung
add a direct dlsym test
2023-10-06 09:11:14 +00:00
Ralf Jung
03a03e2ef6 add a direct dlsym test 2023-10-06 11:09:58 +02:00
bors
d4ba2b4c7c Auto merge of #116018 - DianQK:simd-wide-sum-test, r=scottmcm
Increasing the SIMD size improves the vectorization possibilities

Change the `simd-wide-sum.rs` to pass tests based on the LLVM main branch.

For smaller lengths, we cannot expect to always get vectorized.

A related discussion at https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.3A.20codegen.2Fsimd.2Fsimd-wide-sum.2Ers.20newly.20failing.

r? scottmcm
2023-10-06 08:04:53 +00:00
bors
413540837b Auto merge of #3108 - RalfJung:dlsym, r=RalfJung
refactor dlsym: dispatch symbols via the normal shim mechanism

This avoids having to adjust Miri when switching between invoking the function via a linked symbol vs via dlsym.
2023-10-06 07:40:47 +00:00
Ralf Jung
16cde069fc allow dyn_sym in the files where they are defined; remove unreachable android code 2023-10-06 09:38:50 +02:00
Ralf Jung
099311ba5a make some things on foreign_items private 2023-10-06 09:23:56 +02:00
Ralf Jung
bc8d4dfa95 refactor dlsym: dispatch symbols via the normal shim mechanism 2023-10-06 09:23:35 +02:00
scottmcm
e300847864
Add a wishlist FIXME 2023-10-06 07:05:09 +00:00
bors
f9003c08ab Auto merge of #3098 - BlackHoleFox:apple-entropy, r=RalfJung
Support getentropy on macOS as a foreign item

Prior this was always assumed to be accessed via `dlsym` shim, but in `std` I'm attempting to start [unconditionally linking](https://github.com/rust-lang/rust/pull/116319) to `getentropy` on macOS now that Rust's platform version support allows it.

This just moves the main logic of the previous `dlsym` handler into an eval context extension so it can be used via both call paths. The `dlsym` handler is still needed as `getrandom` uses it.
2023-10-06 05:52:07 +00:00
BlackHoleFox
dff7d5aa2f Move getentropy handling to a shared location for foreign item implementation 2023-10-06 00:37:42 -05:00
bors
ff057893b8 Auto merge of #116472 - matthiaskrgr:rollup-1mz0qrp, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #116421 (Clarify `invalid_reference_casting` lint around interior mutable types)
 - #116469 (Fix typo in README.md)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-06 05:34:36 +00:00
Michael Howell
1eb2a76641 rustdoc-search: fix bug with multi-item impl trait 2023-10-05 22:32:37 -07:00
Matthias Krüger
b29777a186
Rollup merge of #116469 - prakashAditya639:master, r=workingjubilee
Fix typo in README.md

 the word "programatically" should be corrected to "programmatically."
2023-10-06 06:23:48 +02:00
Matthias Krüger
7d7004d3e6
Rollup merge of #116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obk
Clarify `invalid_reference_casting` lint around interior mutable types

This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`.

So for this code:
```rust
let cell = &std::cell::UnsafeCell::new(0);
let _num = &mut *(cell as *const _ as *mut i32);
```

the following note will be added to the lint output:

```diff
 error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused,  consider instead using an `UnsafeCell`
   --> $DIR/reference_casting.rs:68:16
    |
 LL |     let _num = &mut *(cell as *const _ as *mut i32);
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+   = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
```

Suggestion are welcome around the note contents.

Fixes https://github.com/rust-lang/rust/issues/116410
cc `@RalfJung`
2023-10-06 06:23:48 +02:00
bors
fd80c02c16 Auto merge of #116463 - ChrisDenton:nlibc, r=workingjubilee
Remove libc

We don't use much libc on Windows and it seemed silly to keep if for the sake of [two well documented constants](https://learn.microsoft.com/en-us/cpp/c-runtime-library/exit-success-exit-failure?view=msvc-170).
2023-10-06 03:39:22 +00:00
AdityaPrakash
6ff3c3a421
typo in README.md 2023-10-06 09:05:38 +05:30
bors
579be69de9 Auto merge of #101150 - jethrogb:jb/cleanup-sgx-user-memory-copies, r=workingjubilee
Clean up SGX user memory copies

Follow-up on #98126 and #100383

r? `@cuviper`
cc `@raoulstrackx`
2023-10-06 01:50:10 +00:00
bors
2c9b0de8ea Auto merge of #116269 - Veykril:rustc-abi, r=WaffleLapkin
Bring back generic parameters for indices in rustc_abi and make it compile on stable

This effectively reverses https://github.com/rust-lang/rust/pull/107163, allowing rust-analyzer to depend on this crate again,

It also moves some glob imports / expands them in the first commit because they made it more difficult for me to reason about things.
2023-10-06 00:03:56 +00:00
Chris Denton
c8f3aa451a
Remove libc
We don't use much libc on Windows.
2023-10-06 00:35:00 +01:00
Jason Newcomb
d464b72970 Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
bors
1a6ab015d0 Auto merge of #3107 - eduardosm:update-deps, r=RalfJung
Update dependencies
2023-10-05 22:07:09 +00:00
bors
cae0791da4 Auto merge of #116417 - ouz-a:trait_type_detective, r=compiler-errors
Remove is global hack

In attempt to fix https://github.com/rust-lang/rust/issues/114057 we found several issues with how compiler computes layouts, this change removes `is_global` from `and` to stop impl from being shadowed.

In depth conversation can be read here https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Getting.20different.20types.20from.20almost.20same.20inputs

This is a fix candidate opened for performance run.

r? `@lcnr`
2023-10-05 19:42:05 +00:00
Oğuz Ağcayazı
e30d27be00 remove is global hack 2023-10-05 21:38:12 +03:00
bors
cdca82c2c8 Auto merge of #116455 - matthiaskrgr:rollup-p226a5u, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #116220 (stabilize `Option::as_`(`mut_`)`slice`)
 - #116288 (Add Span to various smir types)
 - #116415 (Move subtyper below reveal_all and change reveal_all)
 - #116428 (Add a note to duplicate diagnostics)
 - #116452 (Do not assert that hidden types don't have erased regions.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-05 17:50:50 +00:00
Eduardo Sánchez Muñoz
11afb99b4f Update test dependencies 2023-10-05 19:30:31 +02:00
Eduardo Sánchez Muñoz
bbebfa7186 Update miri-script dependencies 2023-10-05 19:29:27 +02:00
Eduardo Sánchez Muñoz
f49d325f9d Update cargo-miri dependencies 2023-10-05 19:29:02 +02:00
Eduardo Sánchez Muñoz
95c4590988 Update miri dependencies 2023-10-05 19:28:26 +02:00
Matthias Krüger
76d0b794cb
Rollup merge of #116452 - cjgillot:noassert-erased, r=oli-obk
Do not assert that hidden types don't have erased regions.

cc https://github.com/rust-lang/rust/issues/116306

`args` can have erased regions.
In the linked issue, this is reached by computing whether a large type is `Freeze` to compute its ABI.

I do not have a minimized test to include.
2023-10-05 19:24:35 +02:00
Matthias Krüger
c1c5ab717e
Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, r=compiler-errors,estebank
Add a note to duplicate diagnostics

Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into

For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
2023-10-05 19:24:35 +02:00
Matthias Krüger
08cc7428d9
Rollup merge of #116415 - ouz-a:move_subtyper, r=oli-obk
Move subtyper below reveal_all and change reveal_all

In previous attempt https://github.com/rust-lang/rust/pull/116378 we tried to handle `Opaque` in few different places, but this isn't necessary, after moving subtyper below reveal_all and calling `super_place` on reveal_all, issues cease to exist.

r? ``@oli-obk``

Fixes https://github.com/rust-lang/rust/issues/116332
Fixes https://github.com/rust-lang/rust/issues/116265
Fixes https://github.com/rust-lang/rust/issues/116383
Fixes https://github.com/rust-lang/rust/issues/116333
2023-10-05 19:24:34 +02:00
Matthias Krüger
b301bd4220
Rollup merge of #116288 - ouz-a:smir_spans, r=spastorino
Add Span to various smir types

Had to make few extra changes to few structs to attach spans to them.

r? ``@oli-obk``
2023-10-05 19:24:34 +02:00
Matthias Krüger
864e5d8d94
Rollup merge of #116220 - llogiq:stabilize-option-as-slice, r=BurntSushi
stabilize `Option::as_`(`mut_`)`slice`

This is the stabilization to #108545. Thanks to everyone who helped getting this into Rust proper.
2023-10-05 19:24:33 +02:00
ouz-a
3088c4b046 move subtyper change reveal_all 2023-10-05 18:56:30 +03:00