Commit Graph

240633 Commits

Author SHA1 Message Date
Matthias Krüger
caeaf31316
Rollup merge of #118574 - Enselic:query-instability, r=cjgillot
rustc_session: Address all `rustc::potential_query_instability` lints

Instead of allowing `rustc::potential_query_instability` on the whole crate we go over each lint and allow it individually if it is safe to do. Turns out all instances were safe to allow in this crate.

Part of #84447 which is **E-help-wanted**.
2023-12-03 21:28:32 +01:00
Matthias Krüger
80c94e81d9
Rollup merge of #118525 - Zalathar:skip-spans, r=cjgillot
coverage: Skip spans that can't be un-expanded back to the function body

When we extract coverage spans from MIR, we try to "un-expand" them back to spans that are inside the function's body span.

In cases where that doesn't succeed, the current code just swaps in the entire body span instead. But that tends to result in coverage spans that are completely unrelated to the control flow of the affected code, so it's better to just discard those spans.

---

Extracted from #118305, since this is a general improvement that isn't specific to branch coverage.

---

`@rustbot` label +A-code-coverage
2023-12-03 21:28:32 +01:00
Matthias Krüger
591b84583c
Rollup merge of #117869 - GuillaumeGomez:comment-highlighting-item-decl, r=notriddle
[rustdoc] Add highlighting for comments in items declaration

Fixes #117555.

So after the discussion in https://github.com/rust-lang/rust/pull/117643, the outcome was that having the comments in the item declaration at the same level (in term of color) as the rest of the code was actually a bit distracting and could be improved.

The current highlighting color for comments is "lighter" than the rest and I think it fits perfectly to improve the current situation. With this, we now have different "levels" which makes it easier to read and filter out what we want when reading the items declaration.

Here's a screenshot:

![image](https://github.com/rust-lang/rust/assets/3050060/dbd98029-e98b-4997-9a89-6b823eaac9a4)

r? `@notriddle`
2023-12-03 21:28:32 +01:00
bors
d12dc74a2c Auto merge of #118072 - estebank:issue-98982, r=cjgillot
Provide structured suggestion for type mismatch in loop

We currently provide only a `help` message, this PR introduces the last two structured suggestions instead:

```
error[E0308]: mismatched types
  --> $DIR/issue-98982.rs:2:5
   |
LL |   fn foo() -> i32 {
   |               --- expected `i32` because of return type
LL | /     for i in 0..0 {
LL | |         return i;
LL | |     }
   | |_____^ expected `i32`, found `()`
   |
note: the function expects a value to always be returned, but loops might run zero times
  --> $DIR/issue-98982.rs:2:5
   |
LL |     for i in 0..0 {
   |     ^^^^^^^^^^^^^ this might have zero elements to iterate on
LL |         return i;
   |         -------- if the loop doesn't execute, this value would never get returned
help: return a value for the case when the loop has zero elements to iterate on
   |
LL ~     }
LL ~     /* `i32` value */
   |
help: otherwise consider changing the return type to account for that possibility
   |
LL ~ fn foo() -> Option<i32> {
LL |     for i in 0..0 {
LL ~         return Some(i);
LL ~     }
LL ~     None
   |
```

Fix #98982.
2023-12-03 18:57:49 +00:00
bors
487d999e03 Auto merge of #3206 - RalfJung:simd-bitmask, r=RalfJung
SIMD bitmasks: use 'round up to multiple of 8' rather than 'clamp to at least 8'

This should prepare us better for a future with non-power-of-2 vectors, if they ever happen.
2023-12-03 18:28:31 +00:00
Ralf Jung
7c6ed0cc19 SIMD bitmasks: use 'round up to multiple of 8' rather than 'clamp to at least 8' 2023-12-03 19:24:03 +01:00
bors
db07cccb1e Auto merge of #113730 - belovdv:jobserver-init-check, r=petrochenkov
Report errors in jobserver inherited through environment variables

This pr attempts to catch situations, when jobserver exists, but is not being inherited.

r? `@petrochenkov`
2023-12-03 16:28:22 +00:00
bors
6da09594e6 Auto merge of #3205 - RalfJung:simd-bitmask, r=RalfJung
also test simd_select_bitmask on arrays for less than 8 elements
2023-12-03 15:21:45 +00:00
Ralf Jung
6e74d2ad50 disable a test that currently fails on big-endian 2023-12-03 16:19:53 +01:00
Ralf Jung
c9463698db also test directly calling simd_select_bitmask 2023-12-03 16:17:12 +01:00
Ralf Jung
92b4ffc688 handle the array case consistently for simd_select_bitmask and simd_bitmask
also move the two next to each other
2023-12-03 15:45:38 +01:00
bors
21d88b32cb Auto merge of #118526 - sjwang05:issue-118510, r=petrochenkov
Fix ICE: `fn_arg_names: unexpected item DefId(..)`

Fixes #118510
2023-12-03 14:26:39 +00:00
Martin Nordholts
d87460a507 rustc_session: Address all rustc::potential_query_instability lints
Instead of allowing `rustc::potential_query_instability` on the whole
crate we go over each lint and allow it individually if it is safe to
do. Turns out all instances were safe to allow in this crate.
2023-12-03 15:05:39 +01:00
Ralf Jung
56f50d53d1 also test simd_select_bitmask on arrays for less than 8 elements 2023-12-03 14:42:41 +01:00
Vadim Petrochenkov
17e799c270 rustc: Harmonize DefKind and DefPathData
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`.

`DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`.
It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change.

Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values.

`DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-03 16:24:56 +03:00
bors
8b6a4a93ed Auto merge of #118567 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2023-12-03 11:59:32 +00:00
Nadrieril
431cc4a3b0 Satisfy tidy 2023-12-03 12:25:46 +01:00
Nadrieril
70deb9a57f Disallow arm bodies on never patterns 2023-12-03 12:25:46 +01:00
Nadrieril
06a8ed10b6 Disallow guards on never patterns 2023-12-03 12:25:46 +01:00
Nadrieril
a2dcb3a6d9 Disallow an arm without a body (except for never patterns)
Parsing now accepts a match arm without a body, so we must make sure to
only accept that if the pattern is a never pattern.
2023-12-03 12:25:46 +01:00
Nadrieril
0bfebc6105 Detect attempts to expand a macro to a match arm again
Because a macro invocation can expand to a never pattern, we can't rule
out a `arm!(),` arm at parse time. Instead we detect that case at
expansion time, if the macro tries to output a pattern followed by `=>`.
2023-12-03 12:25:46 +01:00
Nadrieril
80bdcbf50a Parse a pattern with no arm 2023-12-03 12:25:46 +01:00
bors
28f9fe3262 Auto merge of #3204 - RalfJung:simd, r=RalfJung
add new SIMD intrinsics
2023-12-03 11:11:20 +00:00
Ralf Jung
2903f1c322 add simd_bswap and simd_bitreverse 2023-12-03 12:08:02 +01:00
Ralf Jung
31ea5181b6 add simd_cttz and simd_ctlz 2023-12-03 12:07:51 +01:00
Ralf Jung
edabd477f8 interpret: make numeric_intrinsic accessible from Miri 2023-12-03 11:51:58 +01:00
Ralf Jung
11db9de728 simd_select_bitmask: support passing the mask as an array 2023-12-03 11:28:40 +01:00
bors
2a316c410d Auto merge of #3203 - RalfJung:trophy, r=RalfJung
new trophy case entry

Cc https://github.com/rust-lang/rust/pull/118460
2023-12-03 09:49:42 +00:00
Ralf Jung
323ca94d92 new trophy case entry 2023-12-03 10:47:59 +01:00
bors
7ceaf19868 Auto merge of #118546 - RalfJung:hashbrown, r=Amanieu
update hashbrown

I had to also pull in an updated syn to make that work, and then cargo pulled in some more package updates.

r? `@Amanieu`
2023-12-03 09:03:14 +00:00
Ralf Jung
ef15a8182b codegen, miri: fix computing the offset of an unsized field in a packed struct 2023-12-03 08:26:51 +01:00
Ralf Jung
5a20bac6b3 more targeted errors when extern types end up in places they should not 2023-12-03 08:11:15 +01:00
bors
71940e0a8a Auto merge of #118487 - RalfJung:exposed-provenance, r=thomcc
move exposed-provenance APIs into separate feature gate

We have already stated explicitly for all the 'exposed' functions that

> Using this method means that code is *not* following strict provenance rules.

However, they were part of the same feature gate and still described as part of the strict provenance experiment. Unfortunately, their semantics are much less clear and certainly nowhere near stabilization, so in preparation for an attempt to stabilize the strict provenance APIs, I suggest we split the things related to "exposed" into their own feature gate. I also used this opportunity to better explain how Exposed Provenance fits into the larger plan here: this is *one possible candidate* for `as` semantics, but we don't know if it is actually viable, so we can't really promise that it is equivalent to `as`. If it works out we probably want to make `as` equivalent to the 'exposed' APIs; if it doesn't, we will remove them again and try to find some other semantics for `as`.
2023-12-03 07:04:12 +00:00
bors
6318e9dd89 Auto merge of #3202 - rust-lang:rustup-2023-12-03, r=saethlin
Automatic Rustup
2023-12-03 05:23:24 +00:00
The Miri Conjob Bot
3a6753b8b9 Merge from rustc 2023-12-03 05:11:24 +00:00
The Miri Conjob Bot
48176d4447 Preparing for merge from rustc 2023-12-03 05:04:26 +00:00
bors
2f1ba4a0af Auto merge of #118128 - RalfJung:bad-intrinsics, r=the8472
warn against using intrinsics that leave the scope of our memory model
2023-12-03 05:03:12 +00:00
bors
225e36cff9 Auto merge of #118542 - chenyukang:yukang-fix-parser-ice-118531, r=cjgillot
Fix parser ICE from attrs

Fixes #118531,
Fixes #118530.
2023-12-03 03:05:17 +00:00
Zalathar
eb2d4cb541 coverage: Skip spans that can't be un-expanded back to the function body
When we extract coverage spans from MIR, we try to "un-expand" them back to
spans that are inside the function's body span.

In cases where that doesn't succeed, the current code just swaps in the entire
body span instead. But that tends to result in coverage spans that are
completely unrelated to the control flow of the affected code, so it's better
to just discard those spans.
2023-12-03 12:35:33 +11:00
bors
1ca8b71cff Auto merge of #118541 - weihanglo:update-cargo, r=weihanglo
Update cargo

27 commits in 26333c732095d207aa05932ce863d850fb309386..623b788496b3e51dc2f9282373cf0f6971a229b5
2023-11-28 20:07:39 +0000 to 2023-12-02 18:10:03 +0000
- docs(book): make old title anchorable (rust-lang/cargo#13102)
- Revert "chore(deps): update rust crate openssl to 0.10.60 [security]" (rust-lang/cargo#13101)
- test(install): use TCP connection instead of thread sleep (rust-lang/cargo#13099)
- test(mdman): Switch to snapbox (rust-lang/cargo#13098)
- Include declared list of features in fingerprint for `-Zcheck-cfg` (rust-lang/cargo#13012)
- chore(deps): update compatible (rust-lang/cargo#13083)
- chore(ci): Always update gix packages together (rust-lang/cargo#13093)
- chore(deps): update rust crate windows-sys to 0.52 (rust-lang/cargo#13089)
- refactor(toml): Decouple logic from schema (rust-lang/cargo#13080)
- Have cargo add --optional &lt;dep&gt; create a &lt;dep&gt; = "dep:&lt;dep&gt; feature (rust-lang/cargo#13071)
- Add `--public` for `cargo add` (rust-lang/cargo#13046)
- chore(deps): update rust crate toml_edit to 0.21.0 (rust-lang/cargo#13088)
- chore(deps): update rust crate rusqlite to 0.30.0 (rust-lang/cargo#13087)
- test(trim-paths): exercise with real world debugger (rust-lang/cargo#13091)
- Fixed uninstall a running binary failed on Windows (rust-lang/cargo#13053)
- chore(deps): update rust crate itertools to 0.12.0 (rust-lang/cargo#13086)
- Add more options to registry test support. (rust-lang/cargo#13085)
- Don't filter on workspace members when scraping doc examples (rust-lang/cargo#13077)
- Remove the outdated comment (rust-lang/cargo#13076)
- fix(resolver): Remove unused public-deps error handling (rust-lang/cargo#13036)
- Fixes error count display is different when there's only one error left (rust-lang/cargo#12484)
- fix: reorder `--remap-path-prefix` flags for `-Zbuild-std` (rust-lang/cargo#13065)
- remove jobserver env var in some tests (rust-lang/cargo#13072)
- doc: clarify different target has different set of `CARGO_CFG_*` values (rust-lang/cargo#13069)
- docs: remove review capacity notice in PR template (rust-lang/cargo#13070)
- chore(deps): update rust crate openssl to 0.10.60 [security] (rust-lang/cargo#13068)
- fix(resolver): De-prioritize no-rust-version in MSRV resolver (rust-lang/cargo#13066)
2023-12-02 23:59:15 +00:00
Weihang Lo
c1f6925a49
Update cargo 2023-12-02 18:29:33 -05:00
sjwang05
a2171feb33
Fix ICE when suggesting closures for non-fn-like defs 2023-12-02 15:03:24 -08:00
bors
90e321d82a Auto merge of #118347 - Mark-Simulacrum:asm-code-size, r=spastorino
Avoid per-register closure expansions

Best reviewed with whitespace ignored.

This hopefully reduces overall size of the binary. Probably zero impact in instructions/cycles in rustc-perf since we don't really have any asm benchmarks AFAIK...
2023-12-02 22:00:48 +00:00
Mark Rousskov
5980a17c52 Avoid per-register closure expansions 2023-12-02 15:31:18 -05:00
bors
d5fab33766 Auto merge of #118484 - blyxxyz:os-str-slice, r=BurntSushi
Add substring API for `OsStr`

This adds a method for taking a substring of an `OsStr`, which in combination with [`OsStr::as_encoded_bytes()`](https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.as_encoded_bytes) makes it possible to implement most string operations in safe code.

API:
```rust
impl OsStr {
    pub fn slice_encoded_bytes<R: ops::RangeBounds<usize>>(&self, range: R) -> &Self;
}
```
Motivation, examples and research at https://github.com/rust-lang/libs-team/issues/306.

Tracking issue: #118485

cc `@epage`
r? libs-api
2023-12-02 20:02:15 +00:00
Alex Crichton
672ea93652 std: Invert logic for inclusion of sys_common::net
The `library/std/src/sys_common/net.rs` module is intended to define
common implementations of networking-related APIs across a variety of
platforms that share similar APIs (e.g. Berkeley-style sockets and all).
This module is not included for more fringe targets however such as UEFI
or "unknown" targets to libstd (those classified as `restricted-std`).
Previously the `sys_common/net.rs` file was set up such that an
allow-list indicated it shouldn't be used. This commit inverts the logic
to have an allow-list of when it should be used instead.

The goal of this commit is to make it a bit easier to experiment with a
new Rust target. Currently more esoteric targets are required to get an
exception in this `cfg_if` block to use `crate::sys::net` such as for
unsupported targets. With this inversion of logic only targets which
actually support networking will be listed, where most of those are
lumped under `cfg(unix)`.

Given that this change is likely to cause some breakage for some target
by accident I've attempted to be somewhat robust with this by following
these steps to defining the new predicate for inverted logic.

1. Take all supported targets and filter out all `cfg(unix)` ones as
   these should all support `sys_common/net.rs`.
2. Take remaining targets and filter out `cfg(windows)` ones.
3. The remaining dozen-or-so targets were all audited by hand. Mostly
   this included `target_os = "hermit"` and `target_os = "solid_asp3"`
   which required an allow-list entry, but remaining targets were all
   already excluded (didn't use `sys_common/net.rs` so they were left
   out.

If this causes breakage it should be relatively easy to fix and I'd be
happy to follow-up with any PRs necessary.
2023-12-02 11:38:32 -08:00
Ralf Jung
c0c0b5b5a6 allow zerocopy license 2023-12-02 19:38:50 +01:00
Ralf Jung
71c9ceb4da update hashbrown 2023-12-02 19:16:09 +01:00
bors
3f1e30a0a5 Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, r=workingjubilee
Portable SIMD subtree update

Syncs nightly to the latest changes from rust-lang/portable-simd

r? `@rust-lang/libs`
2023-12-02 18:04:01 +00:00
bors
0908f173fd Auto merge of #118543 - matthiaskrgr:rollup-0kl4o90, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #118514 (rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternative)
 - #118524 (Add more information to StableMIR Instance)
 - #118528 (replace `once_cell::sync::OnceCell` with std `OnceLock`)
 - #118539 (move packed-struct tests into packed/ folder)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-02 16:06:01 +00:00