Commit Graph

208627 Commits

Author SHA1 Message Date
Michael Goulet 419fde7a38 Handle RPITITs properly in register_hidden_type 2022-10-21 14:57:01 +00:00
Oli Scherer d6cf8934db Require Drop impls to have the same constness on its bounds as the bounds on the struct have 2022-10-21 14:22:13 +00:00
Oli Scherer 349ba6bb51 Remove needless special cases and dead code 2022-10-21 14:21:44 +00:00
clubby789 3f1e99936a Update UI tests 2022-10-21 14:43:58 +01:00
clubby789 717bf35366 Different suggestions for when associated functions are referred to 2022-10-21 14:38:44 +01:00
kraktus 487c6fc9ad [`collapsible_match`] specify field name when destructuring structs 2022-10-21 14:51:13 +02:00
Andreas Molzer e3606b2b02 Reduce mutability in std-use of with_metadata_of 2022-10-21 14:49:29 +02:00
bors 233542bf42 Auto merge of #2610 - RalfJung:issue-1909, r=RalfJung
add test for #1909

Fixes https://github.com/rust-lang/miri/issues/1909
2022-10-21 12:48:54 +00:00
Andreas Molzer 71c39dea4d Argument type for mutable with_metadata_of (#75091)
The method takes two pointer arguments: one `self` supplying the pointer
value, and a second pointer supplying the metadata.

The new parameter type more clearly reflects the actual requirements.
The provenance of the metadata parameter is disregarded completely.
Using a mutable pointer in the call site can be coerced to a const
pointer while the reverse is not true.

An example of the current use:

```rust
// Manually taking an unsized object from a `ManuallyDrop` into another allocation.
let val: &core::mem::ManuallyDrop<T> = …;

let ptr = val as *const _ as *mut T;
let ptr = uninit.as_ptr().with_metadata_of(ptr);
```

This could then instead be simplified to:

```rust
// Manually taking an unsized object from a `ManuallyDrop` into another allocation.
let val: &core::mem::ManuallyDrop<T> = …;

let ptr = uninit.as_ptr().with_metadata_of(&**val);
```
2022-10-21 14:46:14 +02:00
bors 657f246812 Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
 - #102922 (Filtering spans when emitting json)
 - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
 - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
 - #103260 (Fixup a few tests needing asm support)
 - #103321 (rustdoc: improve appearance of source page navigation bar)

Failed merges:

 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-21 12:41:09 +00:00
Ralf Jung f554ebbc77 add test for #1909 2022-10-21 14:28:12 +02:00
bors 9670a3092f Auto merge of #2609 - RalfJung:is_terminal, r=RalfJung
Use is_terminal to implement isatty

This means that Linux targets on Windows hosts should give a correct reply. We still don't have an implementation for Windows targets though, that requires some tracking of handles.

Fixes https://github.com/rust-lang/miri/issues/2419

Also restructure our `fs` tests a bit to test the parts that don't need libc separately.

`as_unix_host_fd` is now not used any more, but it could become useful again in the future so I kept it.
2022-10-21 12:23:11 +00:00
Ralf Jung 1c9f3682f5 test is_terminal 2022-10-21 14:22:12 +02:00
Ralf Jung 7300aac798 split libc tests from stdlib tests 2022-10-21 14:22:12 +02:00
Ralf Jung 9a1edc3c06 use is_terminal to implement isatty 2022-10-21 14:22:12 +02:00
Dylan DPC 325e9203ba
Rollup merge of #103321 - notriddle:notriddle/source-page-top-bar-layout, r=GuillaumeGomez
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.

Preview: https://notriddle.com/notriddle-rustdoc-demos/source-page-header/src/std/lib.rs.html

## Before

![image](https://user-images.githubusercontent.com/1593513/197053420-02a64627-48ed-4bb6-9363-a1863d47b092.png)

## After

![image](https://user-images.githubusercontent.com/1593513/197053355-bd6149f9-0f5c-47da-aeb7-590b5eecb5da.png)
2022-10-21 17:30:00 +05:30
Dylan DPC 3055eb9b26
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Fixup a few tests needing asm support
2022-10-21 17:29:59 +05:30
Dylan DPC 41a1cfdbaf
Rollup merge of #103111 - cjgillot:shadow-label, r=estebank
Account for hygiene in typo suggestions, and use them to point to shadowed names

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

r? `@estebank`
2022-10-21 17:29:59 +05:30
Dylan DPC e11511dfa6
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errors
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use

- Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing.
- Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic.
- Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc.

cc #100717
2022-10-21 17:29:58 +05:30
Dylan DPC 0a0e9f73af
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Filtering spans when emitting json

According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.
2022-10-21 17:29:58 +05:30
Dylan DPC 66d91d8276
Rollup merge of #102287 - compiler-errors:unused-must-use-also-supertrait, r=fee1-dead
Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`

Given `impl Trait`, if one of its supertraits has a `#[must_use]`, then trigger the lint. This means that, for example, `-> impl ExactSizeIterator` also triggers the `must_use` on `trait Iterator`, which fixes #102183.

This might need `@rust-lang/lang` sign-off, since it changes the behavior of the lint, so cc'ing them.
2022-10-21 17:29:57 +05:30
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