Commit Graph

208643 Commits

Author SHA1 Message Date
bors
5c8bff74bc Auto merge of #101263 - lopopolo:lopopolo/c-unwind-fn-ptr-impls, r=thomcc
Add default trait implementations for "c-unwind" ABI function pointers

Following up on #92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in #92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib.

An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in #99531 but this change looks to be blocked on a lang MCP.

Following `@RalfJung's` suggestion in https://github.com/rust-lang/rust/pull/99531#issuecomment-1233440142, this commit is another cut at #92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`.

I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature.

RFC: https://github.com/rust-lang/rfcs/pull/2945
Tracking Issue: https://github.com/rust-lang/rust/issues/74990
2022-10-21 20:59:03 +00:00
bors
b72e451310 Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
`ref_option_ref` do not lint when inner reference is mutable

changelog: FP: [`ref_option_ref`]: No longer lints if the inner reference is mutable

fix https://github.com/rust-lang/rust-clippy/issues/9682
2022-10-21 20:19:30 +00:00
bors
b2e5a719bb Auto merge of #9685 - kraktus:collapsible_match, r=llogiq
[`collapsible_match`] specify field name when destructuring structs

changelog: [`collapsible_match`] specify field name when destructuring structs

fix https://github.com/rust-lang/rust-clippy/issues/9647

I wasn't the sure about the best way to convey the message in the lint message since it does not use suggestion. Because I liked the former output highlighting both spans, I've left it as before, only modifying the span label.
2022-10-21 19:27:35 +00:00
Michael Goulet
cb61113cdc tests 2022-10-21 19:04:13 +00:00
Michael Goulet
9f6b9dd644 Delay ambiguity span bug in normalize query iff not rustdoc 2022-10-21 18:53:16 +00:00
bors
57e2c06a8d Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers
Change process spawning to inherit the parent's signal mask by default

Previously, the signal mask was always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked for all transitive processes.

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-21 18:09:03 +00:00
bors
fc3bcacbe7 Auto merge of #2612 - ChrisDenton:getfiletype, r=RalfJung
add GetFileType stub

because I'm planning to break miri again https://github.com/rust-lang/rust/pull/103360

See [GetFileType](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfiletype)
2022-10-21 17:51:44 +00:00
Michael Howell
526c1d32f6 rustdoc: prevent method summary margin from being applied to docblocks 2022-10-21 10:48:41 -07:00
Chris Denton
590834b032
add GetFileType stub 2022-10-21 18:34:51 +01:00
Michael Howell
0dbf233fc9 rustdoc: merge identical CSS blocks 2022-10-21 10:31:33 -07:00
Chris Denton
d7b0bcb20f
Reduce false positives in msys2 detection
This checks that:

* the handle is a pipe
* the pipe's file name starts with "msys-" or "cygwin-" rather than looking in the full path.
2022-10-21 18:06:12 +01:00
bors
6504d2ef5f Auto merge of #2611 - pfmooney:libffi, r=RalfJung
Update libffi-sys to 2.0.1

Prior version of libffi [could not be cross-compiled to illumos](https://github.com/tov/libffi-rs/pull/59) due to host-triple complications.  This should fix rustup builds of miri for the illumos platform.
2022-10-21 16:33:36 +00:00
Patrick Mooney
b42721ce45 Update libffi-sys to 2.0.1
Prior version of libffi could not be cross-compiled to illumos due to
host-triple complications.  This should fix rustup builds of miri for
the illumos platform.
2022-10-21 11:18:23 -05:00
Maybe Waffle
e97d295d00 Remove incorrect comment in Vec::drain 2022-10-21 15:29:02 +00:00
bors
ba9d01be67 Auto merge of #98450 - lqd:doc-metadata, r=lqd,GuillaumeGomez
Remove more attributes from metadata

A lot of the attributes that are currently stored in the metadata aren't used at all. The biggest metadata usage comes from the doc attributes currently but they are needed by rustdoc so we only removed the ones that cannot be used in downstream crates (doc comments on private items).

r? `@ghost`
2022-10-21 15:27:56 +00:00
Ralf Jung
bdc4acb7bf bootstrap: also create rustc-src component in sysroot 2022-10-21 17:07:27 +02:00
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