Joshua Nelson
31e39446ec
Stabilize #![feature(label_break_value)]
...
# Stabilization proposal
The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.
There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630
Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251 . This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006
Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249
nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983 ) but there are no open RFCs,
and the design space seems rather speculative.
joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804
withoutboats has regrettably left the language team.
joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353
[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+
## Report
+ Feature gate:
- d695a497bb/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
- 6b2d3d5f3c/compiler/rustc_parse/src/parser/diagnostics.rs (L2629)
- f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L749)
- f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L1001)
- 111df9e6ed/compiler/rustc_passes/src/loops.rs (L254)
- d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L2079)
- d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L1569)
+ Tests:
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs
## Interactions with other features
Labels follow the hygiene of local variables.
label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
'foo: {
Err(())?;
break 'foo;
}
};
```
label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
|| break 'a
//~^ ERROR use of unreachable label `'a`
//~| ERROR `break` inside of a closure
}
```
label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
match false 'b: { //~ ERROR block label not supported here
_ => {}
}
}
macro_rules! m {
($b:block) => {
'lab: $b; //~ ERROR cannot use a `block` macro fragment here
unsafe $b; //~ ERROR cannot use a `block` macro fragment here
|x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
}
}
fn foo() {
m!({});
}
```
[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23 21:14:12 -05:00
bors
878aef79dc
Auto merge of #100810 - matthiaskrgr:rollup-xep778s, r=matthiaskrgr
...
Rollup of 9 pull requests
Successful merges:
- #97963 (net listen backlog set to negative on Linux.)
- #99935 (Reenable disabled early syntax gates as future-incompatibility lints)
- #100129 (add miri-test-libstd support to libstd)
- #100500 (Ban references to `Self` in trait object substs for projection predicates too.)
- #100636 (Revert "Revert "Allow dynamic linking for iOS/tvOS targets."")
- #100718 ([rustdoc] Fix item info display)
- #100769 (Suggest adding a reference to a trait assoc item)
- #100777 (elaborate how revisions work with FileCheck stuff in src/test/codegen)
- #100796 (Refactor: remove unnecessary string searchings)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-20 20:08:26 +00:00
Matthias Krüger
e93edf3335
Rollup merge of #100129 - RalfJung:miri-test-libstd, r=thomcc
...
add miri-test-libstd support to libstd
- The first commit mirrors what we already have in liballoc.
- The second commit adds some regression tests that only really make sense to be run in Miri, since they rely on Miri's extra checks to detect anything.
- The third commit makes the MPSC tests work in reasonable time in Miri by reducing iteration counts.
- The fourth commit silences some warnings due to code being disabled with `cfg(miri)`
2022-08-20 19:45:11 +02:00
Matthias Krüger
d9789b6903
Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472
...
net listen backlog set to negative on Linux.
it will be 4076 (from 5.4) or 128.
2022-08-20 19:45:09 +02:00
Matthias Krüger
77db317eed
Rollup merge of #100710 - ChrisDenton:load-library, r=thomcc
...
Windows: Load synch functions together
Attempt to load all the required sync functions and fail if any one of them fails.
This fixes a FIXME by going back to optional loading of `WakeByAddressSingle`.
Also reintroduces a macro for optional loading of functions but keeps it separate from the fallback macro rather than having that do two different jobs.
r? `@thomcc`
2022-08-20 19:32:13 +02:00
Matthias Krüger
c4fa35bb41
Rollup merge of #100642 - mzohreva:mz/update-sgx-abi-cancel-queue, r=Mark-Simulacrum
...
Update fortanix-sgx-abi and export some useful SGX usercall traits
Update `fortanix-sgx-abi` to 0.5.0 to add support for cancel queue (see https://github.com/fortanix/rust-sgx/pull/405 and https://github.com/fortanix/rust-sgx/pull/404 ).
Export some useful traits for processing SGX usercall. This is needed for https://github.com/fortanix/rust-sgx/pull/404 to avoid duplication.
cc `@raoulstrackx` and `@jethrogb`
2022-08-20 19:32:10 +02:00
Matthias Krüger
d49906519b
Rollup merge of #99544 - dylni:expose-utf8lossy, r=Mark-Simulacrum
...
Expose `Utf8Lossy` as `Utf8Chunks`
This PR changes the feature for `Utf8Lossy` from `str_internals` to `utf8_lossy` and improves the API. This is done to eventually expose the API as stable.
Proposal: rust-lang/libs-team#54
Tracking Issue: #99543
2022-08-20 19:32:07 +02:00
dylni
e8ee0b7b2b
Expose Utf8Lossy
as Utf8Chunks
2022-08-20 12:49:20 -04:00
Matthias Krüger
1e47e8a9ee
Rollup merge of #100729 - thomcc:less-initialized, r=ChrisDenton
...
Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`
I've also tried to be slightly more careful about integer overflows, although in practice this is likely still not handled ideally.
r? `@ChrisDenton`
2022-08-20 07:09:04 +02:00
Matthias Krüger
368f08a65f
Rollup merge of #100383 - fortanix:raoul/aepic_leak_mitigation, r=cuviper
...
Mitigate stale data reads on SGX platform
Intel disclosed the Stale Data Read vulnerability yesterday. In order to mitigate this issue completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks. This PR implements this mitigation
References:
- https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html
- https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html
cc: ``@jethrogb``
2022-08-20 07:08:58 +02:00
Chris Denton
625e7e9579
Use const instead of static
2022-08-20 04:15:47 +01:00
Chris Denton
efd305e0ec
Simplify load/store
2022-08-20 04:15:46 +01:00
Thom Chiovoloni
d4cba61099
Fix comment typo
2022-08-19 08:45:21 -07:00
Ralf Jung
fbcdf2a383
clarify lib.rs attribute structure
2022-08-18 18:07:39 -04:00
Ralf Jung
438e49c1cb
silence some unused-fn warnings in miri std builds
2022-08-18 18:07:39 -04:00
Ralf Jung
8c8dc125b1
make many std tests work in Miri
2022-08-18 18:07:39 -04:00
Ralf Jung
27b0444333
add some Miri-only tests
2022-08-18 18:07:39 -04:00
Ralf Jung
ac66baad1a
add miri-test-libstd support to libstd
2022-08-18 18:07:39 -04:00
Thom Chiovoloni
f50f8782fe
Avoid zeroing a 1kb stack buffer on every call to std::sys::windows::fill_utf16_buf
2022-08-18 15:04:28 -07:00
Chris Denton
b631ca0c2f
Windows: Load synch functions together
...
Attempt to load all the required sync functions and fail if any one of them fails.
This reintroduces a macro for optional loading of functions but keeps it separate from the fallback macro rather than having that do two different jobs.
2022-08-18 07:39:14 +01:00
Raoul Strackx
2a23d08aae
Mitigate Stale Data Read for xAPIC vulnerability
...
In order to mitigate the Stale Data Read for xAPIC vulnerability completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks.
References:
- https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html
- https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html
2022-08-17 09:51:03 +02:00
Mohsen Zohrevandi
70dd980c8d
Update fortanix-sgx-abi and export some useful SGX usercall traits
...
Update fortanix-sgx-abi to 0.5.0 to add support for cancel queue (see
https://github.com/fortanix/rust-sgx/pull/405 and
https://github.com/fortanix/rust-sgx/pull/404 ).
Export some useful traits for processing SGX usercall. This is needed
for https://github.com/fortanix/rust-sgx/pull/404 to avoid duplication.
2022-08-16 11:01:53 -07:00
Markus Reiter
44d62425b9
Simplify IpDisplayBuffer
API.
2022-08-16 19:32:00 +02:00
Markus Reiter
31540f5e15
Use MaybeUninit<u8>
for IpDisplayBuffer
.
2022-08-16 18:12:06 +02:00
Markus Reiter
033e9d66ff
Move IpDisplayBuffer
into submodule.
2022-08-16 17:57:46 +02:00
Markus Reiter
5a11b814d4
Add IpDisplayBuffer
helper struct.
2022-08-16 17:54:55 +02:00
Raoul Strackx
25de53f768
Refactor copying data to userspace
2022-08-16 15:01:18 +02:00
bors
3694b7d307
Auto merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister
...
Never inline Windows dtor access
Inlining can cause problem If used in a Rust dylib. See #44391 .
r? `@Mark-Simulacrum`
2022-08-15 23:57:44 +00:00
Matthias Krüger
b8b3ead67a
Rollup merge of #100249 - Meziu:master, r=joshtriplett
...
Fix HorizonOS regression in FileTimes
The changes in #98246 caused a regression for multiple Newlib-based systems. This is just a fix including HorizonOS to the list of targets which require a workaround.
``@AzureMarker`` ``@ian-h-chamberlain``
r? ``@nagisa``
2022-08-14 20:16:00 +02:00
Michael Goulet
ea42f3cfd7
Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum
...
avoid some int2ptr casts in thread_local_key tests
2022-08-13 14:10:05 -07:00
Mark Rousskov
1c40ef70a1
Apply changes from rustfmt bump
2022-08-12 16:28:16 -04:00
Mark Rousskov
154a09dd91
Adjust cfgs
2022-08-12 16:28:15 -04:00
Dylan DPC
51eed00ca9
Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm
...
cleanup code w/ pointers in std a little
Use pointer methods (`byte_add`, `null_mut`, etc) to make code in std a little nicer.
2022-08-12 20:39:10 +05:30
Dylan DPC
a8c799a6a0
Rollup merge of #100022 - joboet:faster_threadid, r=joshtriplett
...
Optimize thread ID generation
By using atomics where available, thread IDs can be generated without locking while still enforcing uniqueness.
2022-08-12 20:39:09 +05:30
bors
569788e47e
Auto merge of #99624 - vincenzopalazzo:macros/unix_error, r=Amanieu
...
promote debug_assert to assert when possible and useful
This PR fixed a very old issue https://github.com/rust-lang/rust/issues/94705 to clarify and improve the POSIX error checking, and some of the checks are skipped because can have no benefit, but I'm sure that this can open some interesting discussion.
Fixes https://github.com/rust-lang/rust/issues/94705
cc: `@tavianator`
cc: `@cuviper`
2022-08-12 09:49:55 +00:00
Matthias Krüger
c7578b4e65
Rollup merge of #100418 - tbodt:stabilize-backtrace, r=dtolnay
...
Add stability attributes to BacktraceStatus variants
Fixes #100399
2022-08-11 22:53:10 +02:00
Matthias Krüger
bd64d67d11
Rollup merge of #100203 - compiler-errors:command-args-size-hint, r=m-ou-se
...
provide correct size hint for unsupported platform `CommandArgs`
Split from https://github.com/rust-lang/rust/pull/99880#discussion_r932994172
2022-08-11 22:53:04 +02:00
Matthias Krüger
6737549aaf
Rollup merge of #99421 - Bryanskiy:android-crt-static, r=petrochenkov
...
add crt-static for android
2022-08-11 22:52:58 +02:00
Theodore Dubois
121fab0396
Add stability attributes to BacktraceStatus variants
...
Fixes #100399
2022-08-11 11:00:07 -07:00
Dylan DPC
a5b0f72e71
Rollup merge of #100287 - cuviper:no-linux-prctl, r=Mark-Simulacrum
...
linux: Use `pthread_setname_np` instead of `prctl`
This function is available on Linux since glibc 2.12, musl 1.1.16, and
uClibc 1.0.20. The main advantage over `prctl` is that it properly
represents the pointer argument, rather than a multi-purpose `long`,
so we're better representing strict provenance (#95496 ).
2022-08-11 22:47:02 +05:30
Ralf Jung
b5786dcae6
avoid some int2ptr casts in thread_local_key tests
2022-08-11 09:39:25 -04:00
bors
187654481f
Auto merge of #100298 - BlackHoleFox:hashmap_keygen_cleanup, r=Mark-Simulacrum
...
Replace pointer casting in hashmap_random_keys with safe code
The old code was unnecessarily unsafe and relied on the layout of tuples always being the same as an array of the same size (which might be bad with `-Z randomize-layout`)?
The replacement has [identical codegen](https://rust.godbolt.org/z/qxsvdb8nx ), so it seems like a reasonable change.
2022-08-11 02:46:32 +00:00
Vincenzo Palazzo
d91dff3c1b
promote debug_assert to assert
...
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-08-11 01:18:45 +00:00
Bryanskiy
874ee5bede
add crt-static for android
2022-08-10 19:42:24 +03:00
joboet
3d21c371ef
std: optimize thread ID generation
2022-08-10 16:56:09 +02:00
Matthias Krüger
e10f924e27
Rollup merge of #99573 - tbodt:stabilize-backtrace, r=yaahc
...
Stabilize backtrace
This PR stabilizes the std::backtrace module. As of #99431 , the std::Error::backtrace item has been removed, and so the rest of the backtrace feature is set to be stabilized.
Previous discussion can be found in #72981 , #3156 .
Stabilized API summary:
```rust
pub mod std {
pub mod backtrace {
pub struct Backtrace { }
pub enum BacktraceStatus {
Unsupported,
Disabled,
Captured,
}
impl fmt::Debug for Backtrace {}
impl Backtrace {
pub fn capture() -> Backtrace;
pub fn force_capture() -> Backtrace;
pub const fn disabled() -> Backtrace;
pub fn status(&self) -> BacktraceStatus;
}
impl fmt::Display for Backtrace {}
}
}
```
`@yaahc`
2022-08-10 07:21:33 +02:00
Jane Losare-Lusby
21396828e4
Apply suggestions from code review
2022-08-09 15:59:53 -07:00
BlackHoleFox
0cf9503751
Replace pointer casting in hashmap_random_keys with safe code
...
The old code was unnecessarily unsafe and relied on the layout
of tuples always being the same as an array of the same size.
2022-08-08 18:49:17 -07:00
Josh Stone
013986be1b
linux: Use pthread_setname_np
instead of prctl
...
This function is available on Linux since glibc 2.12, musl 1.1.16, and
uClibc 1.0.20. The main advantage over `prctl` is that it properly
represents the pointer argument, rather than a multi-purpose `long`,
so we're better representing strict provenance (#95496 ).
2022-08-08 13:27:09 -07:00
Andrea Ciliberti
926f58745e
Fix HorizonOS regression in FileTimes
2022-08-07 19:30:05 +02:00