Commit Graph

208698 Commits

Author SHA1 Message Date
kraktus
615b7617ed ref_option_ref do not lint when inner reference is mutable
As it makes the `Option` Non Copy
2022-10-21 13:48:41 +02:00
bjorn3
b1791eef6a Stop using a depracated function 2022-10-21 10:58:33 +00:00
bjorn3
da770abea3 Update to Cranelift 0.89.0 2022-10-21 10:55:20 +00:00
Rageking8
353ef694fb add test for issue 97607 2022-10-21 18:42:31 +08:00
bors
befc94e691 Auto merge of #2607 - RalfJung:rustup, r=RalfJung
Rustup
2022-10-21 10:21:17 +00:00
Ralf Jung
bb911ce32a add always-failing GetFileInformationByHandleEx stub 2022-10-21 12:20:25 +02:00
Ralf Jung
3ff0a33a83 WinConsole::new is not actually fallible 2022-10-21 12:18:33 +02:00
Rageking8
62a2a1d257 fix some typos 2022-10-21 18:04:00 +08:00
bors
0940040c04 Auto merge of #103310 - lcnr:rustc_hir_typeck, r=compiler-errors
move hir typeck into separate crate

second part https://github.com/rust-lang/compiler-team/issues/529

I avoided pretty much anything that wasn't just a simple move + path adjustment. Left fixmes for methods which are at an odd place

r? `@compiler-errors`
2022-10-21 09:52:18 +00:00
Ralf Jung
76c554eac2 rustup 2022-10-21 11:40:41 +02:00
Patrick Walton
da630ac79d Introduce deduced parameter attributes, and use them for deducing readonly on
indirect immutable freeze by-value function parameters.

Right now, `rustc` only examines function signatures and the platform ABI when
determining the LLVM attributes to apply to parameters. This results in missed
optimizations, because there are some attributes that can be determined via
analysis of the MIR making up the function body. In particular, `readonly`
could be applied to most indirectly-passed by-value function arguments
(specifically, those that are freeze and are observed not to be mutated), but
it currently is not.

This patch introduces the machinery that allows `rustc` to determine those
attributes. It consists of a query, `deduced_param_attrs`, that, when
evaluated, analyzes the MIR of the function to determine supplementary
attributes. The results of this query for each function are written into the
crate metadata so that the deduced parameter attributes can be applied to
cross-crate functions. In this patch, we simply check the parameter for
mutations to determine whether the `readonly` attribute should be applied to
parameters that are indirect immutable freeze by-value.  More attributes could
conceivably be deduced in the future: `nocapture` and `noalias` come to mind.

Adding `readonly` to indirect function parameters where applicable enables some
potential optimizations in LLVM that are discussed in [issue 103103] and [PR
103070] around avoiding stack-to-stack memory copies that appear in functions
like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These
functions pass a large structure unchanged by value to a subfunction that also
doesn't mutate it. Since the structure in this case is passed as an indirect
parameter, it's a pointer from LLVM's perspective. As a result, the
intermediate copy of the structure that our codegen emits could be optimized
away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly
nocapture noalias` in both the caller and callee. We already pass `nocapture
noalias`, but we're missing `readonly`, as we can't determine whether a
by-value parameter is mutated by examining the signature in Rust. I didn't have
much success with having LLVM infer the `readonly` attribute, even with fat
LTO; it seems that deducing it at the MIR level is necessary.

No large benefits should be expected from this optimization *now*; LLVM needs
some changes (discussed in [PR 103070]) to more aggressively use the `noalias
nocapture readonly` combination in its alias analysis. I have some LLVM patches
for these optimizations and have had them looked over. With all the patches
applied locally, I enabled LLVM to remove all the `memcpy`s from the following
code:

```rust
fn main() {
    println!("Hello {}", 3);
}
```

which is a significant codegen improvement over the status quo. I expect that
if this optimization kicks in in multiple places even for such a simple
program, then it will apply to Rust code all over the place.

[issue 103103]: https://github.com/rust-lang/rust/issues/103103

[PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-21 02:33:15 -07:00
Ralf Jung
9b57a2f55a merge rustc history 2022-10-21 10:18:54 +02:00
Sarthak Singh
cc6ad45148 replaced wrong test with the correct mcve 2022-10-21 13:08:30 +05:30
bors
b1ab3b738a Auto merge of #103308 - sunfishcode:sunfishcode/wasi-io-safety, r=joshtriplett
Mark `std::os::wasi::io::AsFd` etc. as stable.

io_safety was stabilized in Rust 1.63, so mark the io_safety exports in `std::os::wasi::io` as stable.

Fixes #103306.
2022-10-21 04:05:02 +00:00
Ben Kimock
9b6791078a Add a missing precondition check 2022-10-20 20:40:35 -04:00
Michael Goulet
6e21b7a9b7 Do not suggest trivially false const predicates 2022-10-20 23:24:45 +00:00
Guillaume Gomez
41263d2898 Add UI regression test when querying visibility of generic parameter 2022-10-20 22:44:10 +00:00
Guillaume Gomez
7f0224e868 Add ui test to ensure attributes generated from macros are kept as expected 2022-10-20 22:44:10 +00:00
Guillaume Gomez
ae5108a1ed Add code comments and documentation 2022-10-20 22:44:10 +00:00
Guillaume Gomez
72d6fde130 Remove doc comments only for private items or some specific doc comments 2022-10-20 22:44:10 +00:00
Guillaume Gomez
b12b65c1b7 Add missing @local_only on attributes 2022-10-20 22:44:10 +00:00
bors
53e3577486 Auto merge of #2601 - DrMeepster:windows_init_once, r=RalfJung
Add Windows InitOnceBeginInitialize and InitOnceComplete shims

Fixes #2595
2022-10-20 22:03:17 +00:00
Ralf Jung
a39629b88f slight refactoring 2022-10-21 00:02:06 +02:00
Rain
a52c79e859 Change process spawning to inherit the parent's signal mask by default
Previously, the signal mask is always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked.

With this change, the default behavior changes to inherit the signal mask.

This also changes the signal disposition for `SIGPIPE` to only be
changed if the `#[unix_sigpipe]` attribute isn't set.
2022-10-20 14:53:38 -07:00
lcnr
adc700b089 update doc links 2022-10-20 23:47:49 +02:00
Dan Gohman
7ac645a565 Make the whole std::os::wasi::io module stable. 2022-10-20 14:31:11 -07:00
bors
dcb3761150 Auto merge of #103322 - matthiaskrgr:rollup-m9zgpft, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103221 (Fix `SelfVisitor::is_self_ty` ICE)
 - #103230 (Clarify startup)
 - #103281 (Adjust `transmute{,_copy}` to be clearer about which of `T` and `U` is input vs output)
 - #103288 (Fixed docs typo in `library/std/src/time.rs`)
 - #103296 (+/- shortcut now only expand/collapse, not both)
 - #103297 (fix typo)
 - #103313 (Don't label `src/test` tests as `A-testsuite`)
 - #103315 (interpret: remove an incorrect assertion)
 - #103319 (Improve "`~const` is not allowed here" message)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-20 21:08:28 +00:00
Matthias Krüger
f9944a9d2c
Rollup merge of #103319 - fee1-dead-contrib:improve_tilde_const_msg, r=oli-obk
Improve "`~const` is not allowed here" message

r? `@oli-obk`
2022-10-20 22:42:42 +02:00
Matthias Krüger
801e32647e
Rollup merge of #103315 - RalfJung:interpret-switchint-ice, r=bjorn3
interpret: remove an incorrect assertion

This fixes an ICE in Miri, [reported](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/SwitchInt.20with.20no.20targets.3F) by `@saethlin.` The faulty assertion was introduced by 432535da2b, when a previously correct assertion checking that the `otherwise` target exists got replaced by this assertion checking that at least one more target beyond `otherwise` exists.

Sadly we don't have a small reproducer so I don't think we can easily add a testcase.
2022-10-20 22:42:41 +02:00
Matthias Krüger
01111d4450
Rollup merge of #103313 - compiler-errors:no-test, r=jyn514
Don't label `src/test` tests as `A-testsuite`

Nearly every PR modifies `src/test`; A-testsuite is meant to be for things affecting the test runners themselves.

cc https://github.com/rust-lang/rust/pull/103204#discussion_r1000868781

r? `@jyn514`
2022-10-20 22:42:41 +02:00
Matthias Krüger
1d97a58820
Rollup merge of #103297 - catandcoder:master, r=JohnTitor
fix typo
2022-10-20 22:42:40 +02:00
Matthias Krüger
5bf18adaa2
Rollup merge of #103296 - GuillaumeGomez:collapse-expand-shortcuts, r=notriddle
+/- shortcut now only expand/collapse, not both

Fixes https://github.com/rust-lang/rust/issues/102772.

r? ```@notriddle```
2022-10-20 22:42:40 +02:00
Matthias Krüger
c6a680ebc5
Rollup merge of #103288 - johnmatthiggins:master, r=thomcc
Fixed docs typo in `library/std/src/time.rs`

* Changed comment from `Previous rust versions panicked when self was earlier than the current time.` to `Previous rust versions panicked when the current time was earlier than self.`
* Resolves #103282.
2022-10-20 22:42:39 +02:00
Matthias Krüger
cfb424a044
Rollup merge of #103281 - thomcc:long-overdue, r=jyn514
Adjust `transmute{,_copy}` to be clearer about which of `T` and `U` is input vs output

This is essentially a documentation-only change (although it does touch code in an irrelevant way).
2022-10-20 22:42:39 +02:00
Matthias Krüger
be4816fbf0
Rollup merge of #103230 - nnethercote:clarify-startup, r=jyn514
Clarify startup

A small follow-up to #102769.

r? `@jyn514`
2022-10-20 22:42:38 +02:00
Matthias Krüger
7ee4b218a8
Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obk
Fix `SelfVisitor::is_self_ty` ICE

Fixes #103202
2022-10-20 22:42:38 +02:00
Michael Howell
f6dd4708cf rustdoc: improve appearance of source page navigation bar
This commit changes things so that the search bar is exactly centered between
the top of the page and the top of the source code content area.
2022-10-20 13:31:06 -07:00
DrMeepster
7e56e773de change rust version to fix CI 2022-10-20 22:19:06 +02:00
DrMeepster
b649b96bc8 remove redundant Ok(...?) 2022-10-20 22:19:06 +02:00
DrMeepster
7cf32a7d47 code reuse for sync ids 2022-10-20 22:19:06 +02:00
DrMeepster
7ca6b175b4 use Default derive for InitOnceStatus 2022-10-20 22:19:06 +02:00
DrMeepster
22d06f9754 update rust version 2022-10-20 22:19:06 +02:00
DrMeepster
342251cb64 add test for init once 2022-10-20 22:19:06 +02:00
DrMeepster
3244c117f8 add windows one time initialization 2022-10-20 22:19:06 +02:00
Deadbeef
ebf5028574 Improve "~const is not allowed here" message 2022-10-20 19:32:16 +00:00
bors
69f01fdff5 Auto merge of #13451 - Veykril:lang-config, r=Veykril
internal: Properly handle language configuration config changes
2022-10-20 19:15:30 +00:00
Lukas Wirth
a8e0a20ce4 internal: Properly handle language configuration config changes 2022-10-20 21:14:36 +02:00
bors
2481721211 Auto merge of #13447 - Veykril:didsavedoc-block, r=Veykril
fix: Fix DidSaveDocument requests blocking the server on startup

Follow up to https://github.com/rust-lang/rust-analyzer/pull/13428
Fixes https://github.com/rust-lang/rust-analyzer/issues/13434
2022-10-20 18:13:09 +00:00
bors
7741e3dc73 Auto merge of #13448 - yotamofek:python-ext-polyfill-workaround, r=Veykril
Workaround the python vscode extension's polyfill

Fixes #13442

`String.replaceAll` and `String.replace` behave the same when given a (/g-flagged) Regex, so fix is very simple.
2022-10-20 17:59:14 +00:00
Yotam Ofek
e05df93b8e Workaround the python vscode extension's polyfill 2022-10-20 17:56:51 +00:00