Commit Graph

272310 Commits

Author SHA1 Message Date
Jacob Pratt
6b58941688
Rollup merge of #133898 - onur-ozkan:ignore-git-hook-on-dist-sources, r=jieyouxu
skip `setup::Hook` on non-git sources

Running `setup::Hook` (with `x setup`) leads tarball sources to panic and this PR resolves that problem by skipping `Hook` step on non-git sources.
2024-12-05 05:50:55 -05:00
Jacob Pratt
3c58e5d522
Rollup merge of #133888 - ChrisDenton:job, r=jieyouxu
Improve bootstrap job objects

This attempts to fix a few comments on bootstrap job objects.

I also fixed an issue where if duplicating the job object handle into the python process failed, it would close the job object. This would then result in the job object closing all attached processes, which at that point includes the current process. The fix is to simply never close the job object handle at any point after the current process is assigned to it.
2024-12-05 05:50:54 -05:00
Jacob Pratt
aaea63e9e2
Rollup merge of #133882 - jyn514:doc-backtraces, r=saethlin
Improve comments for the default backtrace printer

The existing comments were misleading, confusing, and outdated.

Take this comment for example:
```
// Any frames between `__rust_begin_short_backtrace` and `__rust_end_short_backtrace`
// are omitted from the backtrace in short mode, `__rust_end_short_backtrace` will be
// called before the panic hook, so we won't ignore any frames if there is no
// invoke of `__rust_begin_short_backtrace`.
```

this is just wrong. here is an example (full) backtrace:

<details>

```
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `/home/jyn/.local/lib/cargo/target/debug/example`
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x56499698c595 - std::backtrace_rs::backtrace::libunwind::trace::h5ef2cc16e9a7415a
   1:     0x56499698c595 - std::backtrace_rs::backtrace::trace_unsynchronized::h9b5e016e9075f714
   2:     0x56499698c595 - std::sys_common::backtrace::_print_fmt::h2f62c7f9ff224e93
   3:     0x56499698c595 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbe51682735731910
   4:     0x5649969aa26b - core::fmt::rt::Argument::fmt::h1994ab2b310d665e
   5:     0x5649969aa26b - core::fmt::write::hade58a36d63468d7
   6:     0x56499698a43f - std::io::Write::write_fmt::h16145587d801a9ab
   7:     0x56499698c36e - std::sys_common::backtrace::_print::ha8082e56201dadb4
   8:     0x56499698c36e - std::sys_common::backtrace::print::he30f96b4e7f6cbfd
   9:     0x56499698d709 - std::panicking::default_hook::{{closure}}::hf0801f6b18a968d3
  10:     0x56499698d4ac - std::panicking::default_hook::hd2defec7eda5aeb0
  11:     0x56499698dc31 - std::panicking::rust_panic_with_hook::hde93283600065c53
  12:     0x56499698daf3 - std::panicking::begin_panic_handler::{{closure}}::h5e151adbdb7ec0c1
  13:     0x56499698ca59 - std::sys_common::backtrace::__rust_end_short_backtrace::he36a1407e0f77700
  14:     0x56499698d7d4 - rust_begin_unwind
  15:     0x5649969a9503 - core::panicking::panic_fmt::h2380d41365f95412
  16:     0x5649969a958c - core::panicking::panic::h38cf8db80e8c6e67
  17:     0x5649969a93e9 - core::option::unwrap_failed::he72696e53ff29a05
  18:     0x5649969722b6 - core::option::Option<T>::unwrap::hb574dc0dc1703062
  19:     0x5649969722b6 - example::main::h7a867aafacd93d75
  20:     0x5649969721db - core::ops::function::FnOnce::call_once::h734f99a5e57291b7
  21:     0x56499697226e - std::sys_common::backtrace::__rust_begin_short_backtrace::h02f5d58c351c4756
  22:     0x564996972241 - std::rt::lang_start::{{closure}}::h8b134fe2c31a4355
  23:     0x564996988662 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h88d7bb571ee2aaf4
  24:     0x564996988662 - std::panicking::try::do_call::hfb78dfb6599c871d
  25:     0x564996988662 - std::panicking::try::habd041c8c4c8e50c
  27:     0x564996988662 - std::rt::lang_start_internal::{{closure}}::h227591a6f9c0879e
  28:     0x564996988662 - std::panicking::try::do_call::h3c5878333c38916a
  29:     0x564996988662 - std::panicking::try::h5af7b3a127cdae70
  31:     0x564996988662 - std::rt::lang_start_internal::hbc85e809eeace0dd
  32:     0x56499697221a - std::rt::lang_start::ha1eb16922c9cb224
  33:     0x5649969722ee - main
  34:     0x7f031962a1ca - __libc_start_call_main
  35:     0x7f031962a28b - __libc_start_main_impl
  36:     0x5649969720a5 - _start
  37:                0x0 - <unknown>
```

</details>

note particularly frames 13-21, from start_backtrace to end_backtrace. with PrintFmt::Short, these are the *only* frames that are printed; i.e. we are doing the exact opposite of the comment.

r? ``@saethlin``
2024-12-05 05:50:53 -05:00
Jacob Pratt
5dd102e2f8
Rollup merge of #133867 - taiki-e:platform-support, r=Noratrieb
Fix "std" support status of some tier 3 targets

https://github.com/rust-lang/rust/pull/127265 marked targets with empty "std" support status as no-std targets in target-spec metadata:

> * Where a targets 'std' or 'host tools' support is listed as '?' in the rust docs, these are left as 'None' with this PR. The corresponding changes in cargo will only reject an attempt to build std if the 'std' field is 'Some(false)'. In the case it is 'None', cargo will continue trying to build

However, this is not accurate because "std" support status has a marker indicating that it is a no-std target. (empty status is just invalid.)

https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-3

> The `std` column in the table below has the following meanings:
>
> * ✓ indicates the full standard library is available.
> * \* indicates the target only supports [`no_std`] development.
> * ? indicates the standard library support is unknown or a work-in-progress.
>
> [`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html

This PR fixes the status of targets whose "std" support status is currently set to empty and update target-spec metadata.

The new status is set based on the following criteria:

- Set to ✓ for targets that I regularly check in [rust-cross-toolchain](https://github.com/taiki-e/rust-cross-toolchain) that the `cargo test` works. (riscv32-unknown-linux-gnu,{riscv64,s390x}-unknown-linux-musl)
  - Targets where `cargo run` works but `cargo test` does not work tend to have incomplete std support (e.g., riscv32 musl f3068b66e0), so I included them in the group below that means “work in progress” rather than in this group.
- Set powerpc64le FreeBSD to ✓ on both std and host_tools, because the [Rust package](https://www.freshports.org/lang/rust/) is available.
- Set to ? (which means "unknown" or “work in progress”) for all other affected targets because these are Linux, Android, FreeBSD, or Fuchsia, all of which are operating systems that support std if properly supported.

r? Noratrieb
cc ``@harmou01``
2024-12-05 05:50:52 -05:00
Jacob Pratt
f5f8a1f8ce
Rollup merge of #133844 - RalfJung:simd_relaxed_fma-nondet, r=workingjubilee
clarify simd_relaxed_fma non-determinism

This is the safer spec in the sense that it is more likely to be satisfied by the backend -- and if people are okay with a non-deterministic result, I assume they don't care whether it's the same choice across all lanes or not?

Cc ``@calebzulawski`` ``@workingjubilee``
2024-12-05 05:50:51 -05:00
Jacob Pratt
b5a7f41a87
Rollup merge of #127565 - esp-rs:xtensa-vaargs, r=workingjubilee
Teach rustc about the Xtensa VaListImpl

Following on from the target Xtensa target PRs (https://github.com/rust-lang/rust/pull/125141, https://github.com/rust-lang/rust/pull/126380), this PR teaches rustc about the structure of the VA list on the Xtensa arch, as well as adding the required lowering to be able to actually use it.
2024-12-05 05:50:50 -05:00
onur-ozkan
34d6a269e9 skip setup::Hook on non-git sources
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-12-05 11:17:13 +03:00
bors
0e98766a54 Auto merge of #133893 - fmease:rollup-11pi6fg, r=fmease
Rollup of 10 pull requests

Successful merges:

 - #118833 (Add lint against function pointer comparisons)
 - #122161 (Fix suggestion when shorthand `self` has erroneous type)
 - #133233 (Add context to "const in pattern" errors)
 - #133761 (Update books)
 - #133843 (Do not emit empty suggestion)
 - #133863 (Rename `core_pattern_type` and `core_pattern_types` lib feature  gates to `pattern_type_macro`)
 - #133872 (No need to create placeholders for GAT args in confirm_object_candidate)
 - #133874 (`fn_sig_for_fn_abi` should return a `ty::FnSig`, no need for a binder)
 - #133890 (Add a new test ui/incoherent-inherent-impls/no-other-unrelated-errors to check E0116 does not cause unrelated errors)
 - #133892 (Revert #133817)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-05 07:08:49 +00:00
León Orell Valerian Liehr
1f1dfd54eb
Rollup merge of #133892 - jieyouxu:revert-eprintln, r=jieyouxu
Revert #133817

This reverts commit 0585134e70, reversing changes made to 5530869e0f.

#133817 unfortunately only converted the `println!` instances to `eprintln!`, meaning that some test output (via compiletest/bootstrap) was messed up because stdout/stderr output interleaved improperly when some `println!` instances were converted to `eprintln!` instances, while some `print!` instances remain unchanged. This made reading test output annoying for contributors cc #133879.

Closes #133879 by reverting.

#133817 can be relanded in the future when `print!` instances are also matched with `println!` instances.

cc `@clubby789`

This is a clean revert so I'm going to self-approve this PR.
2024-12-05 07:29:59 +01:00
León Orell Valerian Liehr
37c6b55254
Rollup merge of #133890 - kei519:fix-125814, r=compiler-errors
Add a new test ui/incoherent-inherent-impls/no-other-unrelated-errors to check E0116 does not cause unrelated errors

rustc xxx (we do not know) to 1.82.0 emits unrelated errors when E0116 is present (see #125814).

We do not know what caused and fixed it, but add a test to confirm rustc does not cause the same error in the future.
2024-12-05 07:29:58 +01:00
León Orell Valerian Liehr
4f99d6c95e
Rollup merge of #133874 - compiler-errors:fn-sig-binder, r=oli-obk
`fn_sig_for_fn_abi` should return a `ty::FnSig`, no need for a binder

r? oli-obk

Split out of #133122
2024-12-05 07:29:58 +01:00
León Orell Valerian Liehr
3a01e40d32
Rollup merge of #133872 - compiler-errors:simplify-gat-check, r=oli-obk
No need to create placeholders for GAT args in confirm_object_candidate

We no longer need this logic to add placeholders for GAT args since with the removal of the `gat_extended` feature gate (https://github.com/rust-lang/rust/pull/133768) we no longer allow GATs in dyn trait anyways.

r? oli-obk
2024-12-05 07:29:57 +01:00
León Orell Valerian Liehr
44174d9213
Rollup merge of #133863 - oli-obk:push-pystoxvtvssx, r=lqd
Rename `core_pattern_type` and `core_pattern_types` lib feature  gates to `pattern_type_macro`

That's what the gates are actually gating, and the single char difference in naming was not helpful either

fixes #128987
2024-12-05 07:29:56 +01:00
León Orell Valerian Liehr
ab16eeba5c
Rollup merge of #133843 - estebank:empty-semi-sugg, r=jieyouxu
Do not emit empty suggestion

The `println!();` statement's span doesn't include the `;`, and the modified suggestions where trying to get the `;` by getting the differenece between the statement's and the expression's spans, which was an empty suggestion.

Fix #133833, fix #133834.
2024-12-05 07:29:56 +01:00
León Orell Valerian Liehr
d692b1fb2b
Rollup merge of #133761 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

12 commits in e16dd73690a6cc3ecdc5f5d94bbc3ce158a42e16..614c19cb4025636eb2ba68ebb3d44e3bd3a5e6e4
2024-12-02 16:22:15 UTC to 2024-11-26 21:15:51 UTC

- Fix more inverted uses of “shadowed” (rust-lang/book#4122)
- Fix a couple inverted uses of “shadowed” (rust-lang/book#4121)
- Fix confusion between variable `hello` and string `"hello"` (rust-lang/book#4118)
- Ch. 17: fix some wording issues (rust-lang/book#4117)
- Rephrase for clarity (rust-lang/book#3809)
- Link to tests section of rustc book for `cargo test -- --help` docs (rust-lang/book#4116)
- Drop a pedantry-triggering sentence about IEEE-754 (rust-lang/book#4114)
- Very small clarification on if let (rust-lang/book#4113)
- Ch17-05: Typos (rust-lang/book#4099)
- Ch20-01: Fix typos (rust-lang/book#4105)
- Add a short paragraph on editors and IDEs in installation (rust-lang/book#4112)
- Rust 2024: update Ch. 20 for new `unsafe` rules (rust-lang/book#4111)

## rust-lang/reference

8 commits in 5c86c739ec71b8bc839310ff47fa94e94635bba9..ede56d1bbe132bac476b5029cd6d7508ca9572e9
2024-11-25 17:23:35 +0000 to 2024-12-03 22:26:55 +0000
- Claim to follow Unicode 16 for lexing identifiers. (rust-lang/reference#1688)
- Clarify rules for on_unimplemented warnings (rust-lang/reference#1680)
- Enable triagebot merge-conflict notifications (rust-lang/reference#1682)
- Update default edition to 2024 for code examples (rust-lang/reference#1684)
- Fix weak keywords (rust-lang/reference#1685)
- `const` expression can borrow static items (rust-lang/reference#1610)
- Update function-pointer.md for stabilization of `extended_varargs_abi_support` (rust-lang/reference#1687)
- fix inconsistent spacing in example (rust-lang/reference#1686)

## edition-guide

1 commits in f48b0e842a3911c63240e955d042089e9e0894c7..128669297c8a7fdf771042eaec18b8adfaeaf0cd
2024-11-25 16:20:27 +0000 to 2024-12-03 22:02:43 +0000
- Fix `if_let_rescope` applicability (rust-lang/edition-guide#339)

## rust-lang/rustc-dev-guide

6 commits in 787b4166ccc67bd8f72a6e3ef6685ce9ce82909a..b21d99b770f9aceb0810c843847c52f86f45d2ed
2024-12-02 04:45:30 UTC to 2024-11-27 10:31:58 UTC

- Spell out `git submodule deinit -f --all` (rust-lang/rustc-dev-guide#2153)
- Explain how to deal with exploded git submodules (rust-lang/rustc-dev-guide#2152)
- Update `//@ proc-macro` aux build directive docs (rust-lang/rustc-dev-guide#2149)
- Remove `pretty-expanded` as it no longer exists (rust-lang/rustc-dev-guide#2147)
- Fix trivial typo (rust-lang/rustc-dev-guide#2148)
- Remove -Zfuel. (rust-lang/rustc-dev-guide#2032)
2024-12-05 07:29:55 +01:00
León Orell Valerian Liehr
626db06409
Rollup merge of #133233 - estebank:const-errors, r=Nadrieril
Add context to "const in pattern" errors

*Each commit addresses specific diagnostics.*

- Add primary span labels
- Point at `const` item, and `const` generic param definition
- Reword messages and notes
- Point at generic param through which an associated `const` is being referenced
- Silence const in pattern with evaluation errors when they come from `const` items that already emit a diagnostic
- On non-structural type in const used as pattern, point at the type that should derive `PartialEq`
2024-12-05 07:29:54 +01:00
León Orell Valerian Liehr
bc13c82e6e
Rollup merge of #122161 - compiler-errors:shorthand-self, r=fmease
Fix suggestion when shorthand `self` has erroneous type

Fixes #122086

r? estebank
2024-12-05 07:29:54 +01:00
León Orell Valerian Liehr
35ea48d588
Rollup merge of #118833 - Urgau:lint_function_pointer_comparisons, r=cjgillot
Add lint against function pointer comparisons

This is kind of a follow-up to https://github.com/rust-lang/rust/pull/117758 where we added a lint against wide pointer comparisons for being ambiguous and unreliable; well function pointer comparisons are also unreliable. We should IMO follow a similar logic and warn people about it.

-----

## `unpredictable_function_pointer_comparisons`

*warn-by-default*

The `unpredictable_function_pointer_comparisons` lint checks comparison of function pointer as the operands.

### Example

```rust
fn foo() {}
let a = foo as fn();

let _ = a == foo;
```

### Explanation

Function pointers comparisons do not produce meaningful result since they are never guaranteed to be unique and could vary between different code generation units. Furthermore different function could have the same address after being merged together.

----

This PR also uplift the very similar `clippy::fn_address_comparisons` lint, which only linted on if one of the operand was an `ty::FnDef` while this PR lints proposes to lint on all `ty::FnPtr` and `ty::FnDef`.

```@rustbot``` labels +I-lang-nominated

~~Edit: Blocked on https://github.com/rust-lang/libs-team/issues/323 being accepted and it's follow-up pr~~
2024-12-05 07:29:53 +01:00
Jieyou Xu
5b75493d99 Revert "Rollup merge of #133817 - clubby789:bootstrap-eprintln, r=jieyouxu"
This reverts commit 0585134e70, reversing
changes made to 5530869e0f.

The PR unfortunately only converted the `ln!` instances, meaning that
test output was messed up because stdout/stderr output interleaved when
some `println!` instances were converted to `eprintln!` instances, while
some `println!` instances remain unchanged.
2024-12-05 05:59:28 +00:00
bors
5a0a5e6db9 Auto merge of #133828 - compiler-errors:incr-sad, r=lcnr
Make sure to record deps from cached task in new solver on first run

We weren't actually performing a read of the dep node in `with_cached_task` in the new solver, which meant that all queries that computed a goal for the first time were just not recording the query dependencies that we call in that query.

In the incremental test, the typeck query for `fn poll` isn't being marked red even tho it's invalidated due to its writeback results changing. This happens b/c we normalize `Self::Error` into `Error`, which should call `type_of` which is a red query (since `ty::Adt` contains an `AdtDef`, and that `AdtDef`'s stable hash changes since it's ). However, since we weren't tracking deps in that normalize query, the typeck result was remaining green, and we were trying to decode a def id that no longer exists (the field that got removed).

r? lcnr
2024-12-05 04:16:03 +00:00
kei519
892d5850fb Add a new test ui/incoherent-inherent-impls/no-other-unrelated-errors to check E0116 does not cause unrelated errors
rustc xxx (we do not know) to 1.82.0 emits unrelated errors when E0116
is present (see #125814).

We do not know what caused and fixed it, but add a test to confirm rustc
does not cause the same error in the future.
2024-12-05 13:06:34 +09:00
Chris Denton
898d75122f
Update comments on Windows job objects 2024-12-05 03:45:05 +00:00
Chris Denton
a89f340efe
Nested job objects are now supported in CI
Nested job objects aren't supported on Windows 7 but we've long since moved on from that.
2024-12-05 03:18:53 +00:00
Chris Denton
01442e70a7
Never close a job after the process is assigned 2024-12-05 03:13:47 +00:00
jyn
736c61e773 Improve comments for the default backtrace printer
The existing comments were misleading, confusing, and wrong.

Take this comment for example:
```
// Any frames between `__rust_begin_short_backtrace` and `__rust_end_short_backtrace`
// are omitted from the backtrace in short mode, `__rust_end_short_backtrace` will be
// called before the panic hook, so we won't ignore any frames if there is no
// invoke of `__rust_begin_short_backtrace`.
```

this is just wrong. here is an example (full) backtrace:

```
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `/home/jyn/.local/lib/cargo/target/debug/example`
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x56499698c595 - std::backtrace_rs::backtrace::libunwind::trace::h5ef2cc16e9a7415a
   1:     0x56499698c595 - std::backtrace_rs::backtrace::trace_unsynchronized::h9b5e016e9075f714
   2:     0x56499698c595 - std::sys_common::backtrace::_print_fmt::h2f62c7f9ff224e93
   3:     0x56499698c595 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbe51682735731910
   4:     0x5649969aa26b - core::fmt::rt::Argument::fmt::h1994ab2b310d665e
   5:     0x5649969aa26b - core::fmt::write::hade58a36d63468d7
   6:     0x56499698a43f - std::io::Write::write_fmt::h16145587d801a9ab
   7:     0x56499698c36e - std::sys_common::backtrace::_print::ha8082e56201dadb4
   8:     0x56499698c36e - std::sys_common::backtrace::print::he30f96b4e7f6cbfd
   9:     0x56499698d709 - std::panicking::default_hook::{{closure}}::hf0801f6b18a968d3
  10:     0x56499698d4ac - std::panicking::default_hook::hd2defec7eda5aeb0
  11:     0x56499698dc31 - std::panicking::rust_panic_with_hook::hde93283600065c53
  12:     0x56499698daf3 - std::panicking::begin_panic_handler::{{closure}}::h5e151adbdb7ec0c1
  13:     0x56499698ca59 - std::sys_common::backtrace::__rust_end_short_backtrace::he36a1407e0f77700
  14:     0x56499698d7d4 - rust_begin_unwind
  15:     0x5649969a9503 - core::panicking::panic_fmt::h2380d41365f95412
  16:     0x5649969a958c - core::panicking::panic::h38cf8db80e8c6e67
  17:     0x5649969a93e9 - core::option::unwrap_failed::he72696e53ff29a05
  18:     0x5649969722b6 - core::option::Option<T>::unwrap::hb574dc0dc1703062
  19:     0x5649969722b6 - example::main::h7a867aafacd93d75
  20:     0x5649969721db - core::ops::function::FnOnce::call_once::h734f99a5e57291b7
  21:     0x56499697226e - std::sys_common::backtrace::__rust_begin_short_backtrace::h02f5d58c351c4756
  22:     0x564996972241 - std::rt::lang_start::{{closure}}::h8b134fe2c31a4355
  23:     0x564996988662 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h88d7bb571ee2aaf4
  24:     0x564996988662 - std::panicking::try::do_call::hfb78dfb6599c871d
  25:     0x564996988662 - std::panicking::try::habd041c8c4c8e50c
  27:     0x564996988662 - std::rt::lang_start_internal::{{closure}}::h227591a6f9c0879e
  28:     0x564996988662 - std::panicking::try::do_call::h3c5878333c38916a
  29:     0x564996988662 - std::panicking::try::h5af7b3a127cdae70
  31:     0x564996988662 - std::rt::lang_start_internal::hbc85e809eeace0dd
  32:     0x56499697221a - std::rt::lang_start::ha1eb16922c9cb224
  33:     0x5649969722ee - main
  34:     0x7f031962a1ca - __libc_start_call_main
  35:     0x7f031962a28b - __libc_start_main_impl
  36:     0x5649969720a5 - _start
  37:                0x0 - <unknown>
```

note particularly frames 13-21, from start_backtrace to end_backtrace. with PrintFmt::Short, these are the *only* frames that are printed; i.e. we are doing the exact opposite of the comment.
2024-12-04 20:54:37 -05:00
Taiki Endo
e3638e2421 Mark all Linux/Android/BSD/Fuchsia as supporting "std" in target-spec metadata 2024-12-05 10:49:36 +09:00
Eric Huss
1c14127fd6 Update edition-guide and reference 2024-12-04 15:42:24 -08:00
Michael Goulet
03aec5dbef fn_sig_for_fn_abi should return a ty::FnSig, no need for a binder 2024-12-04 21:23:36 +00:00
Esteban Küber
4e6a401b22 review comments: reword messages and simplify logic 2024-12-04 20:49:05 +00:00
Michael Goulet
81291ec7ea No need to create placeholders for GAT args in confirm_object_candidate 2024-12-04 20:38:06 +00:00
Esteban Küber
da58406c73 fix test 2024-12-04 20:29:36 +00:00
Esteban Küber
d136b3108d Add more context to fall-through "const pattern of non-structural type" error
Point at types that need to be marked with `#[derive(PartialEq)]`.

We use a visitor to look at a type that isn't structural, looking for all ADTs that don't derive `PartialEq`. These can either be manual `impl PartialEq`s or no `impl` at all, so we differentiate between those two cases to provide more context to the user. We also only point at types and impls from the local crate, otherwise show only a note.

```
error: constant of non-structural type `&[B]` in a pattern
  --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9
   |
LL | struct B(i32);
   | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns
LL |
LL | const A: &[B] = &[];
   | ------------- constant defined here
...
LL |         A => (),
   |         ^ constant of non-structural type
   |
   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
```
2024-12-04 20:29:36 +00:00
Esteban Küber
27a1880593 Add context to fall-through "const pattern of non-structural type" error
Unify wording with the regular non-structural type error.
2024-12-04 20:29:36 +00:00
Esteban Küber
335d05aee5 Add additional context for non-sructural type constant used in pattern
- Point at type that should derive `PartialEq` to be structural.
- Point at manual `impl PartialEq`, explaining that it is not sufficient to be structural.

```
error: constant of non-structural type `MyType` in a pattern
  --> $DIR/const-partial_eq-fallback-ice.rs:14:12
   |
LL | struct MyType;
   | ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL | const CONSTANT: &&MyType = &&MyType;
   | ------------------------ constant defined here
...
LL |     if let CONSTANT = &&MyType {
   |            ^^^^^^^^ constant of non-structural type
   |
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
  --> $DIR/const-partial_eq-fallback-ice.rs:5:1
   |
LL | impl PartialEq<usize> for MyType {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2024-12-04 20:29:36 +00:00
Esteban Küber
fb2f6a44c0 Reword message for non-structural type constant in pattern 2024-12-04 20:29:36 +00:00
Esteban Küber
a6040bc230 Specify type kind of constant that can't be used in patterns
```
error: trait object `dyn Send` cannot be used in patterns
  --> $DIR/issue-70972-dyn-trait.rs:6:9
   |
LL | const F: &'static dyn Send = &7u32;
   | -------------------------- constant defined here
...
LL |         F => panic!(),
   |         ^ trait object can't be used in patterns
```
2024-12-04 20:29:36 +00:00
Esteban Küber
253eb95d45 Tweak output of some const pattern errors
- Add primary span labels.
- Point at const generic parameter used as pattern.
- Point at statics used as pattern.
- Point at let bindings used in const pattern.
2024-12-04 20:29:36 +00:00
Esteban Küber
87ddc1ea33 Point at generic param through which a const is used in a pattern
```
error[E0158]: constant pattern depends on a generic parameter, which is not allowed
  --> $DIR/associated-const-type-parameter-pattern.rs:20:9
   |
LL | pub trait Foo {
   | -------------
LL |     const X: EFoo;
   |     ------------- constant defined here
...
LL | pub fn test<A: Foo, B: Foo>(arg: EFoo) {
   |             - constant depends on this generic param
LL |     match arg {
LL |         A::X => println!("A::X"),
   |         ^^^^ `const` depends on a generic parameter
```
2024-12-04 20:29:36 +00:00
Esteban Küber
c0f00086f8 Tweak ptr in pattern error
Conform to error style guide.
2024-12-04 20:29:36 +00:00
Esteban Küber
cc492edc9d Tweak unevaluated constant in pattern error
Silence errors that are implied by the errors in the `const` item definition.

Add a primary span label.
2024-12-04 20:29:35 +00:00
Esteban Küber
c6205055e0 On const pattern errors, point at the const item definition
Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition:

```
error[E0158]: constant pattern depends on a generic parameter
  --> $DIR/associated-const-type-parameter-pattern.rs:20:9
   |
LL | pub trait Foo {
   | -------------
LL |     const X: EFoo;
   |     ------------- constant defined here
...
LL |         A::X => println!("A::X"),
   |         ^^^^
```
2024-12-04 20:29:35 +00:00
Michael Goulet
05c34cc5ed Fix suggestion when shorthand self has erroneous type 2024-12-04 19:52:53 +00:00
Taiki Endo
76f9aa1d7e Fix "std" support status of some tier 3 targets 2024-12-05 04:23:57 +09:00
Esteban Küber
1b449e123d Do not emit empty suggestion
The `println!();` statement's span doesn't include the `;`, and the modified suggestions where trying to get the `;` by getting the differenece between the statement's and the expression's spans, which was an empty suggestion.

Fix #133833, fix #133834.
2024-12-04 17:40:39 +00:00
bors
acabb52482 Auto merge of #133865 - matthiaskrgr:rollup-9v2f3w4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #133737 (Include LLDB and GDB visualizers in MSVC distribution)
 - #133774 (Make CoercePointee errors translatable)
 - #133831 (Don't try and handle unfed `type_of` on anon consts)
 - #133847 (Remove `-Zshow-span`.)
 - #133849 (coverage: Use a separate counter type and simplification step during counter creation)
 - #133850 (Avoid `opaque type not constrained` errors in the presence of other errors)
 - #133851 (Stop git from merging generated files)
 - #133856 (Update sysinfo version to 0.33.0)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-04 17:25:11 +00:00
Matthias Krüger
670affb122
Rollup merge of #133856 - GuillaumeGomez:update-sysinfo, r=clubby789
Update sysinfo version to 0.33.0
2024-12-04 18:23:44 +01:00
Matthias Krüger
d80d2c64b7
Rollup merge of #133851 - oli-obk:push-pzwykzozkomq, r=jieyouxu
Stop git from merging generated files

See the relevant documentation for details: https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Unset-1-1-1

This will cause `.stderr`, `.stdout`, `.mir`, and `.fixed` files to stop generating conflict markers and instead just pick the version from your branch, not the one you're rebasing over. Git will still raise a conflict and thus stop a rebase at that commit, but it avoids having to deal with conflict markers in files where we just bless them away anyway.
2024-12-04 18:23:44 +01:00
Matthias Krüger
ea4e7192ac
Rollup merge of #133850 - oli-obk:push-xryukktpyooq, r=compiler-errors
Avoid `opaque type not constrained` errors in the presence of other errors

pulled out of https://github.com/rust-lang/rust/pull/128440

These errors carry no new information if the opaque type was actually used in a constraining (but erroneous) way somewhere.
2024-12-04 18:23:43 +01:00
Matthias Krüger
553db5faee
Rollup merge of #133849 - Zalathar:replay, r=oli-obk
coverage: Use a separate counter type and simplification step during counter creation

When instrumenting a function's MIR for coverage, there is a point where we need to decide, for each node in the control-flow graph, whether its execution count will be tracked by a physical counter, or by an expression that combines physical counters from other parts of the graph.

Currently the code for doing that is heavily tied to the final form of the LLVM coverage mapping format, and performs some important simplification steps on-the-fly. These factors make the code extremely difficult to modify without breaking or massively worsening the resulting coverage-instrumentation metadata.

---

This PR aims to improve that situation somewhat by adding an extra intermediate representation between the code that chooses how each node will be counted, and the code that converts those decisions into actual tables of physical counters and trees of counter expressions.

As part of doing that, some of the simplifications that are currently performed during the main counter creation step have been pulled out into a separate step.

In most cases the resulting coverage metadata is equivalent, slightly better, or slightly worse. The biggest outlier is `counters.rs`, where the coverage metadata ends up about 10% larger. This seems to be the result of the new approach having less subexpression sharing (because it relies on flatten-sort-cancel), and therefore being less effective at taking advantage of MIR optimizations to replace counters for unused control-flow with zeroes. I think the modest downside is acceptable in light of the future possibilities opened up by this decoupling.
2024-12-04 18:23:42 +01:00
Matthias Krüger
a4dc9634a8
Rollup merge of #133847 - nnethercote:rm-Z-show-span, r=compiler-errors
Remove `-Zshow-span`.

It's very old (added in #12087). It's strange, and it's not clear what its use cases are. It only works with the crate root file because it runs before expansion. I suspect it won't be missed.

r? `@estebank`
2024-12-04 18:23:42 +01:00