Commit Graph

239130 Commits

Author SHA1 Message Date
Michael Goulet
6388c0ef04
Rollup merge of #118000 - compiler-errors:placeholder-ty-outlives, r=aliemjay
Make regionck care about placeholders in outlives components

Currently, we don't consider a placeholder type `!T` to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for `non_lifetime_binders`, and even more problematic for `with_negative_coherence`, since negative coherence uses placeholders as universals.

This PR adds `Component::Placeholder` which acts much like `Component::Param`. This currently causes a regression in some non-lifetime-binders tests because `for<T> T: 'static` doesn't imply itself when processing outlives obligations, so code like this will fail:

```
fn foo() where for<T> T: 'static {
  foo() //~ fails
}
```

Since the where clause doesn't imply itself. This requires making the `MatchAgainstHigherRankedOutlives` relation smarter when it comes to binders.

r? types
2023-11-19 19:14:35 -08:00
Michael Goulet
40a781b179
Rollup merge of #117994 - compiler-errors:throw-away-regions-in-coherence, r=lcnr
Ignore but do not assume region obligations from unifying headers in negative coherence

Partly addresses a FIXME that was added in #112875. Just as we can throw away the nested trait/projection obligations from unifying two impl headers, we can also just throw away the region obligations too.

I removed part of the FIXME that was incorrect, namely:
> Given that the only region constraints we get are involving inference regions in the root, it shouldn't matter, but still sus.

This is not true when unifying `fn(A)` and `for<'b> fn(&'b B)` which ends up with placeholder region outlives from non-root universes. I'm pretty sure this is okay, though it would be nice if we were to use them as assumptions. See the `explicit` revision of the test I committed, which still fails.

Fixes #117986

r? lcnr, feel free to reassign tho.
2023-11-19 19:14:35 -08:00
Michael Goulet
e6a3ca0c65
Rollup merge of #117988 - estebank:issue-106020, r=cjgillot
Handle attempts to have multiple `cfg`d tail expressions

When encountering code that seems like it might be trying to have multiple tail expressions depending on `cfg` information, suggest alternatives that will success to parse.

```rust
fn foo() -> String {
    #[cfg(feature = "validation")]
    [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>()
    #[cfg(not(feature = "validation"))]
    String::new()
}
```

```
error: expected `;`, found `#`
  --> $DIR/multiple-tail-expr-behind-cfg.rs:5:64
   |
LL |     #[cfg(feature = "validation")]
   |     ------------------------------ only `;` terminated statements or tail expressions are allowed after this attribute
LL |     [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>()
   |                                                                ^ expected `;` here
LL |     #[cfg(not(feature = "validation"))]
   |     - unexpected token
   |
help: add `;` here
   |
LL |     [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>();
   |                                                                +
help: alternatively, consider surrounding the expression with a block
   |
LL |     { [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>() }
   |     +                                                             +
help: it seems like you are trying to provide different expressions depending on `cfg`, consider using `if cfg!(..)`
   |
LL ~     if cfg!(feature = "validation") {
LL ~         [1, 2, 3].iter().map(|c| c.to_string()).collect::<String>()
LL ~     } else if cfg!(not(feature = "validation")) {
LL ~         String::new()
LL +     }
   |
```

Fix #106020.

r? `@oli-obk`
2023-11-19 19:14:34 -08:00
Michael Goulet
6d33e900d8
Rollup merge of #117957 - the8472:pidfd-wait, r=Mark-Simulacrum
if available use a Child's pidfd for kill/wait

This should get us closer to stabilization of pidfds since they now do something useful. And they're `CLOEXEC` now.

```
$ strace -ffe clone,sendmsg,recvmsg,execve,kill,pidfd_open,pidfd_send_signal,waitpid,waitid ./x test std --no-doc -- pidfd

[...]
running 1 tests
strace: Process 816007 attached
[pid 816007] pidfd_open(816006, 0)      = 3
[pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0c6b787990) = 816008
strace: Process 816008 attached
[pid 816007] recvmsg(3,  <unfinished ...>
[pid 816008] pidfd_open(816008, 0)      = 3
[pid 816008] sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0
[pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0
[pid 816008] execve("/usr/bin/false", ["false"], 0x7ffcf2100048 /* 105 vars */) = 0
[pid 816007] waitid(P_PIDFD, 4,  <unfinished ...>
[pid 816008] +++ exited with 1 +++
[pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0}, WEXITED, NULL) = 0
[pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0} ---
[pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 816009 attached
, child_tidptr=0x7f0c6b787990) = 816009
[pid 816007] recvmsg(3,  <unfinished ...>
[pid 816009] pidfd_open(816009, 0)      = 3
[pid 816009] sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0
[pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0
[pid 816009] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffcf2100048 /* 105 vars */) = 0
[pid 816007] waitid(P_PIDFD, 5, {}, WNOHANG|WEXITED, NULL) = 0
[pid 816007] pidfd_send_signal(5, SIGKILL, NULL, 0) = 0
[pid 816007] waitid(P_PIDFD, 5,  <unfinished ...>
[pid 816009] +++ killed by SIGKILL +++
[pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0}, WEXITED, NULL) = 0
[pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0} ---
[pid 816007] +++ exited with 0 +++
```
2023-11-19 19:14:34 -08:00
Michael Goulet
a7f805d277
Rollup merge of #117891 - compiler-errors:recover-for-dyn, r=davidtwco
Recover `dyn` and `impl` after `for<...>`

Recover `dyn` and `impl` after `for<...>` in types. Reuses the logic for parsing bare trait objects, so it doesn't fix cases like `for<'a> dyn Trait + dyn Trait` or anything, but that seems somewhat of a different issue.

Parsing recovery logic is a bit involved, but I couldn't find a way to simplify it.

Fixes #117882
2023-11-19 19:14:33 -08:00
Michael Goulet
94d9b7e708
Rollup merge of #117832 - RalfJung:interpret-shift, r=cjgillot
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch

While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
2023-11-19 19:14:33 -08:00
Michael Goulet
b39791aec2
Rollup merge of #117828 - Nilstrieb:astconv-hashmaps, r=petrochenkov
Avoid iterating over hashmaps in astconv
2023-11-19 19:14:32 -08:00
bors
4f3da903a4 Auto merge of #116828 - compiler-errors:nightlyify-rustc_type_ir, r=jackh726
Begin to abstract `rustc_type_ir` for rust-analyzer

This adds the "nightly" feature which is used by the compiler, and falls back to more simple implementations when that is not active.

r? `@lcnr` or `@jackh726`
2023-11-19 22:55:15 +00:00
bors
9a66e4471f Auto merge of #117683 - estebank:priv-builder-sugg, r=cjgillot
When encountering struct fn call literal with private fields, suggest all builders

When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.

Add a way to give pre-sorted suggestions.
2023-11-19 20:58:16 +00:00
Michael Goulet
488dcb7af3 Ignore but do not assume region obligations from unifying headers in negative coherence 2023-11-19 19:20:02 +00:00
Michael Goulet
8f267e2b87 Make regionck care about placeholders in outlives components 2023-11-19 19:12:20 +00:00
bors
d19980e1ce Auto merge of #117500 - RalfJung:aggregate-abi, r=davidtwco
Ensure sanity of all computed ABIs

This moves the ABI sanity assertions from the codegen backend to the ABI computation logic. Sadly, due to past mistakes, we [have to](https://github.com/rust-lang/rust/pull/117351#issuecomment-1788495503) be able to compute a sane ABI for nonsensical function types like `extern "C" fn(str) -> str`.  So to make the sanity check pass we first need to make all ABI adjustment deal with unsized types... and we have no shared infrastructure for those adjustments, so that's a bunch of copy-paste. At least we have assertions failing loudly when one accidentally sets a different mode for an unsized argument.

To achieve this, this re-lands the parts of https://github.com/rust-lang/rust/pull/80594 that got reverted in https://github.com/rust-lang/rust/pull/81388.  To avoid breaking wasm ABI again, that ABI now explicitly opts-in to the (wrong, broken) ABI that we currently keep for backwards compatibility. That's still better than having *every* ABI use the wrong broken default!

Cc `@bjorn3`
Fixes https://github.com/rust-lang/rust/issues/115845
2023-11-19 18:42:20 +00:00
Esteban Küber
ac56b06b44 fix rebase 2023-11-19 18:07:22 +00:00
Esteban Küber
b0d7ccb133 fmt 2023-11-19 17:50:47 +00:00
Esteban Küber
a519c9b6b7 review comments 2023-11-19 17:50:47 +00:00
Esteban Küber
4d16171f56 Account for number of arguments in suggestion 2023-11-19 17:50:47 +00:00
Esteban Küber
00265f0cc0 fix tidy 2023-11-19 17:50:47 +00:00
Esteban Küber
69edf8e784 Suggest Default::default() for struct literals with private fields 2023-11-19 17:50:47 +00:00
Esteban Küber
be0958f5ab Suggest builder functions on struct literal with private fields 2023-11-19 17:50:47 +00:00
Esteban Küber
1dfec45dc9 Remove unnecessary .collect() 2023-11-19 17:50:47 +00:00
Esteban Küber
987155f35d Suggest using builder on curly brace struct called as fn 2023-11-19 17:50:46 +00:00
Esteban Küber
12a8bb8d9b Do not suggest struct literal when fields are private 2023-11-19 17:50:46 +00:00
Esteban Küber
e0e379b6fd Add test for public struct with private fields 2023-11-19 17:50:46 +00:00
Esteban Küber
a4f47de7ff On private tuple struct, suggest Default::default when possible 2023-11-19 17:50:46 +00:00
Esteban Küber
f1ae02f4bd Don't sort span_suggestions, leave that to caller 2023-11-19 17:50:45 +00:00
Esteban Küber
42aa1273b0 When encountering struct fn call literal with private fields, suggest all builders
When encountering code like `Box(42)`, suggest `Box::new(42)` and *all*
other associated functions that return `-> Box<T>`.
2023-11-19 17:47:41 +00:00
Nilstrieb
13959bf376 Avoid iterating over hashmaps in astconv 2023-11-19 17:45:02 +01:00
bors
290fc68f2d Auto merge of #117888 - notriddle:notriddle/releases, r=Mark-Simulacrum
doc: add release notes to standalone doc bundle

Preview: http://notriddle.com/rustdoc-html-demo-5/release-notes/releases.html

This is a workaround for #101714 on top of being a useful addition in its own right. It is intended to change the "canonical URL" for viewing the release notes from GitHub, which is relatively slow, to a pre-rendered HTML file that loads from the same CDN as the standard library docs. It also means you get a copy of the release notes when installing the rust-docs with rustup.
2023-11-19 16:44:55 +00:00
Ralf Jung
c7b8dd4e93 make_direct_deprecated: dont overwrite already set attributes 2023-11-19 16:03:07 +01:00
Michael Howell
0bf77206ad Fix outdated doc comment on Releases doc build step 2023-11-19 08:01:17 -07:00
bors
27794f95fd Auto merge of #118024 - notriddle:notriddle/search-speed, r=GuillaumeGomez
rustdoc-search: optimize unifyFunctionTypes

Final profile output:
https://notriddle.com/rustdoc-html-demo-5/profile-4/index.html

This PR contains three commits that improve performance of this hot inner loop: reduces the number of allocations, a fast path for the 1-element basic query case, and reconstructing the multi-element query case to use recursion instead of an explicit `backtracking` array. It also adds new test cases that I found while working on this.

r? `@GuillaumeGomez`
2023-11-19 14:47:08 +00:00
The 8472
f34e7f4768 Don't set cmsg fields in msghdr if we have no cmsg to send 2023-11-19 15:19:47 +01:00
Ralf Jung
cfb47ca5df disable csky test on CI 2023-11-19 15:01:33 +01:00
bors
097261f241 Auto merge of #118054 - max-niederman:pinned-must-use, r=Nilstrieb
Lint pinned `#[must_use]` pointers (in particular, `Box<T>` where `T` is `#[must_use]`) in `unused_must_use`.

Fixes: #111458

This is motivated by a common async/await pattern:

```rs
fn foo() -> Pin<Box<dyn Future<Output = i32>>> {
    Box::pin(async { 42 })
}

// call `foo`, but forget to await the result
foo();
```

Unlike with `async fn` or return position `impl Future`, this does not currently warn the user that the `Future` is unused.

To fix this, I've extended the `unused_must_use` lint to catch `Pin<P>`, where `P` must be used. In particular, this applies to `Pin<Box<T>>`, where `T` must be used. I'm not sure if there are other pointers where this applies, but I can't think of any situation the user wouldn't want to be warned.
2023-11-19 12:23:59 +00:00
bors
10a98e8bff Auto merge of #118051 - GuillaumeGomez:cleanup-rustdoc, r=notriddle
Remove unneeded `unknown` variable and `Symbol` creation when iterating over items in rustdoc rendering

I realized that we were creating a `Symbol` but never actually used it since we check that `item.name` is always `Some()`.

r? `@notriddle`
2023-11-19 09:40:47 +00:00
bors
d0474fba92 Auto merge of #117807 - RalfJung:raw-str-slice, r=davidtwco
patterns: don't ice when encountering a raw str slice

Fixes https://github.com/rust-lang/rust/issues/117806
2023-11-19 07:44:43 +00:00
bors
7d0e1bca0f Auto merge of #117364 - BlackHoleFox:farewell-bitcode-no-remorse, r=davidtwco
Remove legacy bitcode defaults from all Apple specs

Xcode 14 [deprecated bitcode with warnings](https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes#Deprecations) and now [Xcode 15 has dropped it completely](https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Deprecations). `rustc` should follow what the platform tooling is doing as well since it just increases binary sizes for no gain at this point.

`cc` made a [similar change last month](https://github.com/rust-lang/cc-rs/pull/812).

Two things show this should have minimal impact:
- Apple has stopped accepting apps built with versions of Xcode (<14) that generate bitcode
- The app store has been stripping bitcode off IPA releases for over 2 years now.

I didn't nuke all the bitcode changes added in https://github.com/rust-lang/rust/pull/71970/ since maybe another target in the future could need mandatory bitcode embedding.

Staticlibs built for iOS still link correctly with XCode 15 against a test app when using a compiler built from this branch.

cc `@thomcc` `@keith`
2023-11-19 05:35:08 +00:00
Max Niederman
c5ed7b0ead
add test for pinned must_use pointers 2023-11-18 21:01:02 -08:00
Max Niederman
173b950311
catch pinned must_use types in unused_must_use 2023-11-18 20:04:50 -08:00
bors
d052f6fde6 Auto merge of #117895 - mzohreva:mz/fix-sgx-backtrace, r=Mark-Simulacrum
Adjust frame IP in backtraces relative to image base for SGX target

This is followup to https://github.com/rust-lang/backtrace-rs/pull/566.

The backtraces printed by `panic!` or generated by `std::backtrace::Backtrace` in SGX target are not usable. The frame addresses need to be relative to image base address so they can be used for symbol resolution. Here's an example panic backtrace generated before this change:

```
$ cargo r --target x86_64-fortanix-unknown-sgx
...
stack backtrace:
   0:     0x7f8fe401d3a5 - <unknown>
   1:     0x7f8fe4034780 - <unknown>
   2:     0x7f8fe401c5a3 - <unknown>
   3:     0x7f8fe401d1f5 - <unknown>
   4:     0x7f8fe401e6f6 - <unknown>
```
Here's the same panic after this change:
```
$ cargo +stage1 r --target x86_64-fortanix-unknown-sgx
stack backtrace:
   0:            0x198bf - <unknown>
   1:            0x3d181 - <unknown>
   2:            0x26164 - <unknown>
   3:            0x19705 - <unknown>
   4:            0x1ef36 - <unknown>
```
cc `@jethrogb` and `@workingjubilee`
2023-11-19 03:00:18 +00:00
bors
0d3dfb5296 Auto merge of #117868 - ferrocene:pa-omit-git-hash, r=Mark-Simulacrum
Set `CFG_OMIT_GIT_HASH=1` during builds when `omit-git-hash` is enabled

This environment variable will allow tools like Cargo to disable their own detection when `omit-git-hash` is set to `true`.

I created this PR because of https://github.com/rust-lang/cargo/pull/12968. There is not a dependency between the two PRs, they can land in any order. They just won't do anything until both of them are merged into the repo.
2023-11-19 01:05:22 +00:00
Michael Howell
a3d90036c5 Do not call dry_run twice
Co-authored-by: Onur Özkan <onurozkan.dev@outlook.com>
2023-11-18 16:21:44 -07:00
Michael Howell
d82b3748d5 rustdoc-search: switch to recursive backtracking
This is significantly faster, because

- It allows the one-element fast path to kick in on multi-
  element queries.
- It constructs intermediate data structures more lazily
  than the old system did.

It's measurably faster than the old algo even without the fast path, but
that fast path still helps significantly.
2023-11-18 16:12:43 -07:00
bors
ea6b131132 Auto merge of #117813 - onur-ozkan:simplify-download-ci-llvm-option, r=Mark-Simulacrum
deprecate `if-available` value of `download-ci-llvm`

This PR deprecates the use of the `if-available` value for `download-ci-llvm` since `if-unchanged` serves the same purpose when no changes are detected. In cases where changes are present, it is assumed that compiling LLVM is acceptable (otherwise, why make changes there?).

This was probably missing in the #110087 issue before.

cc `@RalfJung`
2023-11-18 23:02:12 +00:00
Guillaume Gomez
1e55fc1243 Remove unneeded unknown variable and Symbol creation when iterating over items in rustdoc rendering 2023-11-18 23:05:30 +01:00
bors
4cb3beec86 Auto merge of #118046 - TaKO8Ki:rollup-6jdgwe5, r=TaKO8Ki
Rollup of 5 pull requests

Successful merges:

 - #116750 (Add Seek::seek_relative)
 - #117110 (Suggest field typo through derefs)
 - #117961 (Add `x suggest` entries for testing `mir-opt` and `coverage`)
 - #118020 (Fix links to `From<{OwnedHandle, OwnedFd}> for std::process::Child{Stdin, Stdout, Stderr}` in 1.74 release notes)
 - #118034 (bump few deps to fix unsoundness and drop few dup deps)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-18 21:03:01 +00:00
Takayuki Maeda
62e71fada6
Rollup merge of #118034 - klensy:dep-up-18-11-23, r=Mark-Simulacrum
bump few deps to fix unsoundness and drop few dup deps

jsondocck: bump jsonpath to 0.3, dropping few dup dependencies
changes: https://github.com/freestrings/jsonpath/compare/v0.2.6...v0.3.0

self_cell: bump to 0.10.3 due to RUSTSEC-2023-0070
https://rustsec.org/advisories/RUSTSEC-2023-0070.html https://github.com/Voultapher/self_cell/issues/49

bump h2 to 0.3.22, dropping few dup crate versions
https://github.com/hyperium/h2/blob/v0.3.22/CHANGELOG.md
2023-11-19 04:14:42 +09:00
Takayuki Maeda
49d69c477a
Rollup merge of #118020 - Lireer:patch-1, r=Mark-Simulacrum
Fix links to `From<{OwnedHandle, OwnedFd}> for std::process::Child{Stdin, Stdout, Stderr}` in 1.74 release notes
2023-11-19 04:14:42 +09:00
Takayuki Maeda
b82532765c
Rollup merge of #117961 - Zalathar:suggest, r=Mark-Simulacrum
Add `x suggest` entries for testing `mir-opt` and `coverage`

The `x suggest` subcommand uses git to find paths that have been modified, and uses those paths to suggest relevant test suites to run.

This PR adds suggestions for `x test mir-opt` and `x test coverage` .
2023-11-19 04:14:41 +09:00
Takayuki Maeda
9e84f6d86a
Rollup merge of #117110 - estebank:deref-field-suggestion, r=b-naber
Suggest field typo through derefs

Take into account implicit dereferences when suggesting fields.

```
error[E0609]: no field `longname` on type `Arc<S>`
  --> $DIR/suggest-field-through-deref.rs:10:15
   |
LL |     let _ = x.longname;
   |               ^^^^^^^^ help: a field with a similar name exists: `long_name`
```

CC https://github.com/rust-lang/rust/issues/78374#issuecomment-719564114
2023-11-19 04:14:41 +09:00