Commit graph

9988 commits

Author SHA1 Message Date
Matthias Krüger 433189b742
Rollup merge of #105434 - nbdd0121:lib, r=thomcc
Fix warning when libcore is compiled with no_fp_fmt_parse

Discovered when trying to compile Rust-for-Linux with Rust 1.66 beta.

It'll be helpful if this is backported to beta (should be trivial enough for backporting), so Rust-for-Linux's rust version bump wouldn't need to do `--cap-lints allow` for libcore.
2022-12-08 12:57:33 +01:00
Matthias Krüger cd936cc812
Rollup merge of #105120 - solid-rs:patch/kmc-solid/maintainance, r=thomcc
kmc-solid: `std::sys` code maintenance

Includes a set of changes to fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets and make some other improvements.

- Address `fuzzy_provenance_casts` by using `expose_addr` and `from_exposed_addr` for pointer-integer casts
- Add a stub implementation of `is_terminal` (#98070)
- Address `unused_imports` and `unused_unsafe`
- Stop doing `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
2022-12-08 12:57:29 +01:00
Gary Guo a3c4c2ee1d Fix warning when libcore is compiled with no_fp_fmt_parse 2022-12-08 00:16:49 +00:00
bors 01fbc5ae78 Auto merge of #103459 - ChrisDenton:propagate-nulls, r=thomcc
Pass on null handle values to child process

Fixes #101645

In Windows, stdio handles are (semantically speaking) `Option<Handle>` where `Handle` is a non-zero value. When spawning a process with `Stdio::Inherit`, Rust currently turns zero values into `-1` values. This has the unfortunate effect of breaking console subprocesses (which typically need stdio) that are spawned from gui applications (that lack stdio by default) because the console process won't be assigned handles from the newly created console (as they usually would in that situation). Worse, `-1` is actually [a valid handle](https://doc.rust-lang.org/std/os/windows/io/struct.OwnedHandle.html) which means "the current process". So if a console process, for example, waits on stdin and it has a `-1` value then the process will end up waiting on itself.

This PR fixes it by propagating the nulls instead of converting them to `-1`.

While I think the current behaviour is a mistake, changing it (however justified) is an API change so I think this PR should at least have some input from t-libs-api. So choosing at random...

r? `@joshtriplett`
2022-12-07 13:52:52 +00:00
bors 91b8f34ac2 Auto merge of #104799 - pcc:linkage-fn, r=tmiasko
Support Option and similar enums as type of static variable with linkage attribute

Compiler MCP:
rust-lang/compiler-team#565
2022-12-07 10:24:59 +00:00
bors 023b5136b5 Auto merge of #105271 - eduardosm:inline-always-int-conv, r=scottmcm
Make integer-to-integer `From` impls `#[inline(always)]`

Splited from https://github.com/rust-lang/rust/pull/105262
2022-12-06 21:41:04 +00:00
Chris Denton 93b774a2a4
Don't set STARTF_USESTDHANDLES if none are set 2022-12-06 17:26:21 +00:00
Matthias Krüger 967085ecdf
Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk
Replace usage of `ResumeTy` in async lowering with `Context`

Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.

fixes https://github.com/rust-lang/rust/issues/104828 and https://github.com/rust-lang/rust/pull/104321#issuecomment-1336363077

r? `@oli-obk`
2022-12-06 16:54:54 +01:00
Matthias Krüger 7d8e329194
Rollup merge of #105243 - RalfJung:no-op-let, r=Mark-Simulacrum
remove no-op 'let _ = '

Also see the discussion at https://github.com/rust-lang/rust/pull/93563#discussion_r1034057555.

I don't know why these `Drop` implementations exist to begin with, given that their body does literally nothing, but did not want to change that. (It might affect dropck.)

Cc `````@ibraheemdev````` `````@Amanieu`````
2022-12-06 13:27:42 +01:00
Arpad Borsos cf031a3355
Replace usage of ResumeTy in async lowering with Context
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces
the raw pointer in `ResumeTy` and the `get_context` fn that pulls the
correct lifetimes out of thin air.
2022-12-06 10:16:23 +01:00
Yuki Okushi fa7d3ec630
Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot
Fix dupe word typos
2022-12-06 12:48:52 +09:00
Peter Collingbourne b4278b02a7 Reimplement weak! using Option. 2022-12-05 15:05:43 -08:00
Matthias Krüger e84e8f4165
Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov
std update libc version and freebsd image build dependencies
2022-12-05 20:43:43 +01:00
Matthias Krüger 8ad447c479
Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum
PartialEq: PERs are homogeneous

PartialEq claims that it corresponds to a PER, but that is only a well-defined statement when `Rhs == Self`. There is no standard notion of PER on a relation between two different sets/types. So move this out of the first paragraph and clarify this.
2022-12-05 20:43:40 +01:00
bors 203c8765ea Auto merge of #105046 - scottmcm:vecdeque-vs-vec, r=Mark-Simulacrum
Send `VecDeque::from_iter` via `Vec::from_iter`

Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-12-05 08:45:03 +00:00
Rageking8 58110572fb fix dupe word typos 2022-12-05 16:42:36 +08:00
Eduardo Sánchez Muñoz 2e51122647 Make integer-to-integer From impls #[inline(always)] 2022-12-04 22:55:18 +01:00
Ralf Jung c823dfa8b2 remove no-op 'let _ = ' 2022-12-04 10:32:00 +01:00
bors 9e772114e6 Auto merge of #101514 - nvzqz:nvzqz/stabilize-nonzero-bits, r=thomcc
Stabilize `nonzero_bits`

Closes #94881, implemented by #93292.

This change stabilizes the associated `BITS` constant for `NonZero{U,I}{8,16,32,64,128,size}` integers, e.g.:

```rs
impl NonZeroUsize {
    pub const BITS: u32 = usize::BITS;
}
```
2022-12-04 08:28:22 +00:00
David CARLIER 71cf892235 std update libc version and freebsd image build dependencies 2022-12-03 19:01:55 +00:00
Matthias Krüger 6f0a2adf6e
Rollup merge of #105153 - oli-obk:fail_faster, r=compiler-errors
Create a hacky fail-fast mode that stops tests at the first failure

This is useful for not having to wait until all 10k+ ui tests have finished running and then having to crawl through hundreds of failure reports.

You now only get the first report when you turn on that env var and no new tests are run at all

This works like a charm, but is obviously welded on very crudely
2022-12-03 17:37:42 +01:00
Yuki Okushi 019795b162
Rollup merge of #105100 - jhpratt:fix-docs, r=JohnTitor
Add missing intra-doc link

Trivial change. This makes the plain text into inline code and makes it a link.

`@rustbot` label +A-docs
2022-12-03 12:51:28 +09:00
Yuki Okushi 9f3ccd4bf6
Rollup merge of #105032 - HintringerFabian:improve_docs, r=JohnTitor
improve doc of into_boxed_slice and impl From<Vec<T>> for Box<[T]>

Improves description of `into_boxed_slice`, and adds example to `impl From<Vec<T>> for Box<[T]>`.
Fixes #98908
2022-12-03 12:51:27 +09:00
bors 32e613bbaa Auto merge of #104999 - saethlin:immediate-abort-inlining, r=thomcc
Adjust inlining attributes around panic_immediate_abort

The goal of `panic_immediate_abort` is to permit the panic runtime and formatting code paths to be optimized away. But while poking through some disassembly of a small program compiled with that option, I found that was not the case. Enabling LTO did address that specific issue, but enabling LTO is a steep price to pay for this feature doing its job.

This PR fixes that, by tweaking two things:
* All the slice indexing functions that we `const_eval_select` on get `#[inline]`. `objdump -dC` told me that originally some `_ct` functions could end up in an executable. I won't pretend to understand what's going on there.
* Normalize attributes across all `panic!` wrappers: use `inline(never) + cold` normally, and `inline` when `panic_immediate_abort` is enabled.

But also, with LTO and `panic_immediate_abort` enabled, this patch knocks ~709 kB out of the `.text` segment of `librustc_driver.so`. That is slightly surprising to me, my best theory is that this shifts some inlining earlier in compilation, enabling some subsequent optimizations. The size improvement of `librustc_driver.so` with `panic_immediate_abort` due to this patch is greater with LTO than without LTO, which I suppose backs up this theory.

I do not know how to test this. I would quite like to, because I think what this is solving was an accidental regression. This only works with `-Zbuild-std` which is a cargo flag, and thus can't be used in a rustc codegen test.

r? `@thomcc`

---

I do not seriously think anyone is going to use a compiler built with `panic_immediate_abort`, but I wanted a big complicated Rust program to try this out on, and the compiler is such.
2022-12-02 20:07:23 +00:00
Tomoaki Kawada ae7633f434 kmc-solid: Don't do Box::from_raw(&*(x: Box<T>) as *const T as *mut T)
This pattern seems to be considered illegal by Miri.
2022-12-02 16:58:41 +09:00
Matthias Krüger c7edfddc2f
Rollup merge of #105137 - yjhn:patch-1, r=Dylan-DPC
Add tracking issue number for `file_create_new` feature

It was missing a tracking issue, so I opened one (#105135).
2022-12-02 08:28:11 +01:00
Matthias Krüger 4c4dec4408
Rollup merge of #105126 - Sp00ph:const_new_in, r=dtolnay
Make `VecDeque::new_in` unstably const

(See #105072)
2022-12-02 08:28:09 +01:00
Matthias Krüger 4fdc3eb176
Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki
Add `type_ascribe!` macro as placeholder syntax for type ascription

This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription.

I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether.

Part of #101728
2022-12-02 08:28:08 +01:00
Oli Scherer e59025867d Create a hacky fail-fast mode that stops tests at the first failure 2022-12-01 20:29:18 +00:00
Andrius Pukšta 0af5b7265d
Add tracking issue for file_create_new 2022-12-01 17:42:31 +02:00
Markus Everling c959fbe771 Fix typo in comment 2022-12-01 12:44:29 +01:00
Markus Everling 929003aacf Make VecDeque::new_in unstably const 2022-12-01 12:15:29 +01:00
bors 9c0bc3028a Auto merge of #104975 - JakobDegen:custom_mir_let, r=oli-obk
`#![custom_mir]`: Various improvements

This PR makes a bunch of improvements to `#![custom_mir]`. Ideally this would be 4 PRs, one for each commit, but those would take forever to get merged and be a pain to juggle. Should still be reviewed one commit at a time though.

### Commit 1: Support arbitrary `let`

Before this change, all locals used in the body need to be declared at the top of the `mir!` invocation, which is rather annoying. We attempt to change that.

Unfortunately, we still have the requirement that the output of the `mir!` macro must resolve, typecheck, etc. Because of that, we can't just accept this in the THIR -> MIR parser because something like
```rust
{
    let x = 0;
    Goto(other)
}
other = {
    RET = x;
    Return()
}
```
will fail to resolve. Instead, the implementation does macro shenanigans to find the let declarations and extract them as part of the `mir!` macro. That *works*, but it is fairly complicated and degrades debuginfo by quite a bit. Specifically, the spans for any statements and declarations that are affected by this are completely wrong. My guess is that this is a net improvement though.

One way to recover some of the debuginfo would be to not support type annotations in the `let` statements, which would allow us to parse like `let $stmt:stmt`. That seems quite surprising though.

### Commit 2: Parse consts

Reuses most of the const parsing from regular Mir building for building custom mir

### Commit 3: Parse statics

Statics are slightly weird because the Mir primitive associated with them is a reference/pointer to them, so this is factored out separately.

### Commit 4: Fix some spans

A bunch of the spans were non-ideal, so we adjust them to be much more helpful.

r? `@oli-obk`
2022-12-01 10:40:10 +00:00
nils efea79ca80
Gate macros behind #[cfg(not(bootstrap))]
Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com>
2022-12-01 11:16:18 +01:00
Tomoaki Kawada f482e55adf kmc-solid: Address compiler warnings
Addresses the warn-by-default lints `unused_imports` and
`unused_unsafe`.
2022-12-01 13:18:05 +09:00
Tomoaki Kawada 47f2f6d615 kmc-solid: Add a stub implementation of is_terminal
Copied from `unsupported/io.rs`. Fixes build failure.
2022-12-01 13:18:05 +09:00
Tomoaki Kawada 427a079d31 kmc-solid: Use expose_addr and from_exposed_addr for pointer-integer casts
Pointer-integer casts are required for conversion between `EXINF` (ITRON
task entry point parameter) and `*const ThreadInner`. Addresses the
deny-level lint `fuzzy_provenance_casts`.
2022-12-01 13:18:05 +09:00
bors 1dcf6add3d Auto merge of #104160 - Ayush1325:windows-args, r=m-ou-se
Extract WStrUnits to sys_common::wstr

This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI).

This was originally a part of https://github.com/rust-lang/rust/pull/100316

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-01 01:22:32 +00:00
Jacob Pratt d777c84603
Add missing intra-doc link 2022-11-30 20:42:31 +00:00
Matthias Krüger c752eaa7de
Rollup merge of #104811 - haraldh:feat/wasm32_wasi_shutdown, r=joshtriplett
feat: implement TcpStream shutdown for wasm32-wasi

Signed-off-by: Harald Hoyer <harald@profian.com>
2022-11-30 07:00:31 +01:00
Jakob Degen 52ce1f7697 Support statics in custom mir 2022-11-29 19:27:26 -08:00
Jakob Degen 7578100317 Support most constant kinds in custom mir 2022-11-29 19:26:04 -08:00
Jakob Degen a98254179b Support arbitrary let statements in custom mir 2022-11-29 19:19:33 -08:00
Matthias Krüger aa674eefda
Rollup merge of #105049 - mkroening:hermit-fixes, r=jyn514
Hermit: Minor build fixes

These changes are necessary to build for the hermit targets.

CC: ``@stlankes``
2022-11-29 22:43:20 +01:00
Matthias Krüger 804fa66a02
Rollup merge of #105002 - zertosh:acp-140, r=dtolnay
Add `PathBuf::as_mut_os_string` and `Path::as_mut_os_str`

Implements rust-lang/libs-team#140 (tracking issue #105021).
2022-11-29 22:43:18 +01:00
Matthias Krüger e4d1fe7b15
Rollup merge of #104436 - ismailmaj:add-slice-to-stack-allocated-string-comment, r=Mark-Simulacrum
Add slice to the stack allocated string comment

Precise that the "stack allocated string" is not a string but a string slice.

``@rustbot`` label +A-docs
2022-11-29 22:43:16 +01:00
Ben Kimock 906c3601fa Adjust inlining attributes around panic_immediate_abort 2022-11-29 09:24:01 -05:00
Martin Kröning 0a4e5efe6f hermit: Remove unused exports 2022-11-29 12:25:35 +01:00
Martin Kröning c8f3203c46 hermit: Fix fuzzy_provenance_casts 2022-11-29 12:25:35 +01:00
Scott McMurray a964a37211 Send VecDeque::from_iter via Vec::from_iter
Since it's O(1) to convert between them now, might as well reuse the logic.

Mostly for the various specializations it does, but might also save some monomorphization work if, say, people collect slice iterators into both `Vec`s and `VecDeque`s.
2022-11-29 00:24:15 -08:00