Commit Graph

5840 Commits

Author SHA1 Message Date
Gray Olson
252a83b63f add section on manual owning ptr managed solution via @kpreid 2024-01-07 08:56:07 -08:00
Gray Olson
7c9c71260e improve structural Unpin + formatting 2024-01-07 08:56:06 -08:00
Gray Olson
e2e8746bb6 reword unpin auto impl section 2024-01-07 08:56:06 -08:00
Gray Olson
82a68171d3 fix link in footnote 2024-01-07 08:56:06 -08:00
Gray Olson
bebbe24a63 improve Pin struct docs and add examples 2024-01-07 08:56:05 -08:00
Gray Olson
6818d9278b improve intro and discussion of pinning as library contract 2024-01-07 08:56:05 -08:00
Gray Olson
db5b19e472 improve intro and Unpin-related discussion 2024-01-07 08:56:05 -08:00
Gray Olson
46f9d77bd1 update doubly linked list commentary and fix links 2024-01-07 08:56:04 -08:00
Gray Olson
ec8a01a479 fix one more broken link 2024-01-07 08:56:04 -08:00
Gray Olson
584f0986fc fix broken links 2024-01-07 08:56:04 -08:00
Gray Olson
ba3b9342cc Fix examples, finish polishing 2024-01-07 08:56:04 -08:00
Gray Olson
8241ca6056 mostly done 2024-01-07 08:56:03 -08:00
Miguel Young de la Sota
bfd63b20c8 Rewrite Pin<P> docs to clarify guarantees and uses
The documentation today does not give a complete treatment of pinning
from first principles, which appropriately describes how to design types
that use it, nor does it provide formal statements of the guarantees
users need to be aware of.

This rewrite attempts to address these in a way that makes the concept
more approachable while also making the documentation more normative.
2024-01-07 08:56:03 -08:00
Matthias Krüger
1d6ab69ab1
Rollup merge of #119624 - petrochenkov:dialoc4, r=compiler-errors
rustc_span: More consistent span combination operations

Also add more tests for using `tt` in addition to `ident`, and some other minor tweaks, see individual commits.

This is a part of https://github.com/rust-lang/rust/pull/119412 that doesn't yet add side tables for metavariable spans.
2024-01-06 16:07:48 +01:00
Matthias Krüger
cda0d08388
Rollup merge of #119595 - mbbill:patch-1, r=Mark-Simulacrum
Fixed ambiguity in hint.rs

Needle and haystack are actually not the same, they remain constant.
2024-01-06 16:07:48 +01:00
Matthias Krüger
923578e6f9
Rollup merge of #118781 - RalfJung:core-panic-feature, r=the8472
merge core_panic feature into panic_internals

I don't know why those are two separate features, but it does not seem intentional. This merge is useful because with https://github.com/rust-lang/rust/pull/118123, panic_internals is recognized as an internal feature, but core_panic is not -- but core_panic definitely should be internal.
2024-01-06 16:07:46 +01:00
Michael Goulet
d90c702566
Rollup merge of #119216 - weiznich:use_diagnostic_namespace_in_stdlib, r=compiler-errors
Use diagnostic namespace in stdlib

This required a minor fix to have the diagnostics shown in third party crates when the `diagnostic_namespace` feature is not enabled. See 5d63f5d8d1 for details. I've opted for having a single PR for both changes as it's really not that much code. If it is required it should be easy to split up the change into several PR's.

r? `@compiler-errors`
2024-01-05 23:41:41 -05:00
Vadim Petrochenkov
deecbd80cd library: Add allow(unused_assignments) to custom MIR doctest
The lint is not yet reported due to span issues, but will be reported later.
2024-01-05 19:13:51 +03:00
Michael Goulet
8bea1df254
Rollup merge of #119583 - AngelicosPhosphoros:const_assume, r=RalfJung
Make `intrinsics::assume` const stable

Closes https://github.com/rust-lang/rust/issues/76972
Blocks https://github.com/rust-lang/rust/pull/119452

Approved in https://github.com/rust-lang/rust/pull/119452#issuecomment-1875741678

r? `@RalfJung`
2024-01-05 10:57:23 -05:00
Georg Semmler
2c3aeea1ba
Replace some usage of #[rustc_on_unimplemented] with
`#[diagnostic::on_unimplemented]`

This commit replaces those `#[rustc_on_unimplemented]` attributes with
their equivalent `#[diagnostic::on_unimplemented]` where this is
supported (So no filter or any extended option)
2024-01-05 15:23:09 +01:00
bors
5113ed28ea Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin
Merge `unused_tuple_struct_fields` into `dead_code`

This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group.

[Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-05 04:51:55 +00:00
Ming, Bai
fdf93830c9
Fixed ambiguity in hint.rs
Needle and haystack are actually not the same, they remain constant.
2024-01-04 15:48:22 -08:00
AngelicosPhosphoros
59c76fb21b Make intrinsics::assume const stable
Closes https://github.com/rust-lang/rust/issues/76972
Blocks https://github.com/rust-lang/rust/pull/119452

Approved in https://github.com/rust-lang/rust/pull/119452#issuecomment-1875741678
2024-01-04 19:14:31 +01:00
Matthias Krüger
e306cfb115
Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31
Make offset_of field parsing use metavariable which handles any spacing

As discussed at and around comments https://github.com/rust-lang/rust/issues/106655#issuecomment-1793485081 and https://github.com/rust-lang/rust/issues/106655#issuecomment-1793774183, the current arguments to offset_of do not accept all the whitespace combinations: `0. 1.1.1` and `0.1.1. 1` are currently treated specially in `tests/ui/offset-of/offset-of-tuple-nested.rs`.

They also do not allow [forwarding individual fields as in](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=444cdf0ec02b99e8fd5fd8d8ecb312ca)
```rust
macro_rules! off {
    ($a:expr) => {
        offset_of!(m::S, 0. $a)
    }
}
```

This PR replaces the macro arguments with `($Container:ty, $($fields:expr)+ $(,)?)` which does allow any arrangement of whitespace that I could come up with and the forwarding of fields example above.

This also allows for array indexing in the future, which I think is the last future extension to the syntax suggested in the offset_of RFC.

Tracking issue for offset_of: #106655
``@rustbot`` label F-offset_of

``@est31``
2024-01-04 15:34:00 +01:00
Matthias Krüger
a919d97aaa
Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors
custom mir: make it clear what the return block is

Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments:
```
Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue())
```

Also fix some outdated docs and add some docs to `Call` and `Drop`.
2024-01-04 15:33:58 +01:00
George Bateman
09bb07e38f
Make offset_of field parsing use metavariable which handles any spacing 2024-01-02 22:18:35 +00:00
Jake Goulding
5772818dc8 Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
Matthias Krüger
19580d56c2
Rollup merge of #119424 - ojeda:send-sync, r=est31
Primitive docs: fix confusing `Send` in `&T`'s list

The two lists in this document describe what traits are implemented on references when their underlying `T` also implements them. However, while it is true that `T: Send + Sync` implies `&T: Send` (which is what the sentence is trying to explain), it is confusing to have `Send` in the list because `T: Send` is not needed for that. In particular, the "also require" part may be interpreted as "both `T: Send` and `T: Sync` are required".

Instead, move `Send` back to where it was before commit 7a477869b7 ("Makes docs for references a little less confusing"), i.e. to the `&mut` list (where no extra nota is needed, i.e. it fits naturally) and move the `Sync` definition/note to the bottom as something independent.
2023-12-30 11:42:04 +01:00
Miguel Ojeda
dd928c8f75 Primitive docs: fix confusing Send in &T's list
The two lists in this document describe what traits are implemented on
references when their underlying `T` also implements them. However,
while it is true that `T: Send + Sync` implies `&T: Send` (which is
what the sentence is trying to explain), it is confusing to have `Send`
in the list because `T: Send` is not needed for that. In particular,
the "also require" part may be interpreted as "both `T: Send` and
`T: Sync` are required".

Instead, move `Send` back to where it was before commit 7a477869b7
("Makes docs for references a little less confusing"), i.e. to the `&mut`
list (where no extra nota is needed, i.e. it fits naturally) and move the
`Sync` definition/note to the bottom as something independent.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-12-29 22:26:23 +01:00
Emil Gardström
12dd5d1d0d
fix typo 2023-12-28 19:05:13 +01:00
Ralf Jung
4bf2794e59 custom mir: better type-checking 2023-12-26 20:15:35 +01:00
Ralf Jung
0f9baa8a31 custom mir: make it clear what the return block is 2023-12-26 20:15:26 +01:00
bors
e1fadb2c35 Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc
Add `hint::assert_unchecked`

Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430

I think that means this is good for nightly, since we can always rename it before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-26 15:31:44 +00:00
lch361
c082c1c4c3 Documented unsafe blocks 2023-12-25 01:59:37 +03:00
lch361
b15e13760a Removed redundant bounds checking at Split's next and next_mut methods 2023-12-25 01:34:07 +03:00
Linus Färnstrand
98899b7131 Stabilize ip_in_core feature 2023-12-24 12:23:50 +01:00
Michael Goulet
eef023c806
Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnay
Add `IntoAsyncIterator`

This introduces the `IntoAsyncIterator` trait and uses it in the desugaring of the unstable `for await` loop syntax. This is mostly added for symmetry with `Iterator` and `IntoIterator`.

r? `@compiler-errors`

cc `@rust-lang/libs-api,` `@rust-lang/wg-async`
2023-12-22 21:41:04 -05:00
bors
495203bf61 Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrum
Bump stage0 to 1.76 beta

r? `@Mark-Simulacrum`
2023-12-23 00:26:47 +00:00
Eric Holk
acb6f17adf
Use IntoAsyncIterator in for await loop desugaring 2023-12-22 11:01:06 -08:00
Eric Holk
8e34391d6a
Add IntoAsyncIterator 2023-12-22 11:01:05 -08:00
bors
208dd2032b Auto merge of #118847 - eholk:for-await, r=compiler-errors
Add support for `for await` loops

This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library.

Given a loop like:
```rust
for await i in iter {
    ...
}
```
this is desugared to something like:
```rust
let mut iter = iter.into_async_iter();
while let Some(i) = loop {
    match core::pin::Pin::new(&mut iter).poll_next(cx) {
        Poll::Ready(i) => break i,
        Poll::Pending => yield,
    }
} {
    ...
}
```

This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this.

I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue.

r? `@compiler-errors`
2023-12-22 14:17:10 +00:00
Pietro Albini
f9f5840eb4
update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
Pietro Albini
c00486c9bb
update version placeholders 2023-12-22 11:01:42 +01:00
bors
5ac4c8a63e Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcm
do not allow ABI mismatches inside repr(C) types

In https://github.com/rust-lang/rust/pull/115476 we allowed ABI mismatches inside `repr(C)` types. This wasn't really discussed much; I added it because from how I understand calling conventions, this should actually be safe in practice. However I entirely forgot to actually allow this in Miri, and in the mean time I have learned that too much ABI compatibility can be a problem for CFI (it can reject fewer calls so that gives an attacker more room to play with).

So I propose we take back that part about ABI compatibility in `repr(C)`. It is anyway something that C and C++ do not allow, as far as I understand.

In the future we might want to introduce a class of ABI compatibilities where we say "this is a bug and it may lead to aborting the process, but it won't lead to arbitrary misbehavior -- worst case it'll just transmute the arguments from the caller type to the callee type". That would give CFI leeway to reject such calls without introducing the risk of arbitrary UB. (The UB can still happen if the transmute leads to bad results, of course, but it wouldn't be due to ABI weirdness.)

#115476 hasn't reached beta yet so if we land this before Dec 22nd we can just pretend this all never happened. ;)  Otherwise we should do a beta backport (of the docs change at least).

Cc `@rust-lang/opsem` `@rust-lang/types`
2023-12-20 18:04:40 +00:00
Scott McMurray
7556d6f61b Add hint::assert_unchecked 2023-12-19 13:56:50 -08:00
Eric Holk
97df0d3657
Desugar for await loops 2023-12-19 12:26:27 -08:00
Caleb Zulawski
e61aaf91c8 Disable new intrinsics for bootstrap 2023-12-18 21:41:50 -05:00
Caleb Zulawski
d655dd6dca Add new intrinsics 2023-12-17 23:00:29 -05:00
Caleb Zulawski
4767aaf826 Further explain semantics 2023-12-17 21:17:00 -05:00
Caleb Zulawski
e245bafa9c Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17 21:17:00 -05:00