Commit Graph

270802 Commits

Author SHA1 Message Date
Matthias Krüger
978f592539
Rollup merge of #132948 - RalfJung:const_unicode_case_lookup, r=Noratrieb
stabilize const_unicode_case_lookup

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

See there for t-libs-api FCP
2024-11-12 23:26:43 +01:00
Matthias Krüger
5419f41f9a
Rollup merge of #132851 - chansuke:update-comment, r=thomcc
Update the doc comment of `ASCII_CASE_MASK`

Revived and continued the work from https://github.com/rust-lang/rust/pull/120282.

the original [branch](https://github.com/mahmudsudo/rust-1/tree/patch-1) was deleted, i created a new branch to carry the changes forward
2024-11-12 23:26:42 +01:00
Matthias Krüger
bd79fe7a94
Rollup merge of #132702 - 1c3t3a:issue-132615, r=rcvalle
CFI: Append debug location to CFI blocks

Currently we're not appending debug locations to the inserted CFI blocks. This shows up in #132615 and #100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks.

Credits also belong to `@jakos-sec` who worked with me on this.
2024-11-12 23:26:41 +01:00
bors
f7273e0044 Auto merge of #132954 - matthiaskrgr:rollup-x3rww9h, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #131831 (extend the "if-unchanged" logic for compiler builds)
 - #132541 (Proper support for cross-crate recursive const stability checks)
 - #132657 (AIX: add run-make support)
 - #132901 (Warn about invalid `mir-enable-passes` pass names)
 - #132923 (Triagebot: Consolidate the T-compiler ad hoc assignment groups)
 - #132938 (Make precise capturing suggestion machine-applicable only if it has no APITs)
 - #132947 (clarify `must_produce_diag` ICE for debugging)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 18:04:27 +00:00
Matthias Krüger
f00a31c44d
Rollup merge of #132947 - lqd:trimmed-ice, r=compiler-errors
clarify `must_produce_diag` ICE for debugging

We have a sanity check to ensure the expensive `trimmed_def_paths` functions are called only when producing diagnostics, and not e.g. on the happy path. The panic often happens IME during development because of randomly printing stuff, causing an ICE if no diagnostics were also emitted.

I have this change locally but figured it could be useful to others, so this PR clarifies the message when this happens during development.

The output currently looks like this by default; it's a bit confusing with words missing:

```
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:628:17:
must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; `with_no_trimmed_paths` for debugging. called at: disabled backtrace
stack backtrace:
   0:     0x7ffff79570f6 - std::backtrace_rs::backtrace::libunwind::trace::h33576c57327a3cea
                               at .../library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7ffff79570f6 - std::backtrace_rs::backtrace::trace_unsynchronized::h7972a09393b420db
                               at .../library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ffff79570f6 - std::sys::backtrace::_print_fmt::hae8c5bbfbf7a8322
                               at .../library/std/src/sys/backtrace.rs:66:9
   3:     0x7ffff79570f6 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1fd6a7a210f5b535
...
```

The new output mentions how to get more information and locate where the `with_no_trimmed_paths` call needs to be added.

1. By default, backtraces are disabled:
```
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:642:17:
`trimmed_def_paths` called, diagnostics were expected but none were emitted. Use `with_no_trimmed_paths` for debugging. Backtraces are currently disabled: set `RUST_BACKTRACE=1` and re-run to see where it happened.
stack backtrace:
   0:     0x7ffff79565f6 - std::backtrace_rs::backtrace::libunwind::trace::h33576c57327a3cea
...
```

2. With backtraces enabled:
```
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:642:17:
`trimmed_def_paths` called, diagnostics were expected but none were emitted. Use `with_no_trimmed_paths` for debugging. This happened in the following `must_produce_diag` call's backtrace:
   0: <rustc_errors::DiagCtxtHandle>::set_must_produce_diag
             at .../compiler/rustc_errors/src/lib.rs:1133:58
   1: <rustc_session::session::Session>::record_trimmed_def_paths
             at .../compiler/rustc_session/src/session.rs:327:9
   2: rustc_middle::ty::print::pretty::trimmed_def_paths
             at .../compiler/rustc_middle/src/ty/print/pretty.rs:3351:5
...
```

A `\n` could be added here or there, but it didn't matter much whenever I hit this case with the new message.
2024-11-12 18:11:07 +01:00
Matthias Krüger
11c7b01aa7
Rollup merge of #132938 - compiler-errors:ed2024-apit-sugg, r=chenyukang
Make precise capturing suggestion machine-applicable only if it has no APITs

cc https://github.com/rust-lang/rust/issues/132932

The only case where this suggestion is not machine-applicable is when we suggest turning arg-position impl trait into type parameters, which may expose type parameters that were not turbofishable before.
2024-11-12 18:11:06 +01:00
Matthias Krüger
15fbae8ed9
Rollup merge of #132923 - fmease:triagebot-update-t-compiler, r=wesleywiser
Triagebot: Consolidate the T-compiler ad hoc assignment groups

https://github.com/rust-lang/compiler-team/issues/757

1. Inline compiler-team and compiler-team-contributors into compiler
2. Sort members alphabetically
2024-11-12 18:11:05 +01:00
Matthias Krüger
8628fd553d
Rollup merge of #132901 - clubby789:enable-pass-check, r=jieyouxu
Warn about invalid `mir-enable-passes` pass names

Fixes #132805
2024-11-12 18:11:05 +01:00
Matthias Krüger
8f67b5b349
Rollup merge of #132657 - mustartt:aix-run-make-support, r=jieyouxu
AIX: add run-make support

On AIX, we are required explicit link against `c++` and `c++abi` to support running the run-make test suite.
2024-11-12 18:11:04 +01:00
Matthias Krüger
4a699fc475
Rollup merge of #132541 - RalfJung:const-stable-extern-crate, r=compiler-errors
Proper support for cross-crate recursive const stability checks

~~Stacked on top of https://github.com/rust-lang/rust/pull/132492; only the last three commits are new.~~

In a crate without `staged_api` but with `-Zforce-unstable-if-unmarked`, we now subject all functions marked with `#[rustc_const_stable_indirect]` to recursive const stability checks. We require an opt-in so that by default, a crate can be built with `-Zforce-unstable-if-unmarked` and use nightly features as usual. This property is recorded in the crate metadata so when a `staged_api` crate calls such a function, it sees the `#[rustc_const_stable_indirect]` and allows it to be exposed on stable. This, finally, will let us expose `const fn` from hashbrown on stable.

The second commit makes const stability more like regular stability: via `check_missing_const_stability`, we ensure that all publicly reachable functions have a const stability attribute -- both in  `staged_api` crates and `-Zforce-unstable-if-unmarked` crates. To achieve this, we move around the stability computation so that const stability is computed after regular stability is done. This lets us access the final result of the regular stability computation, which we use so that `const fn` can inherit the regular stability (but only if that is "unstable"). Fortunately, this lets us get rid of an `Option` in `ConstStability`.

This is the last PR that I have planned in this series.

r? `@compiler-errors`
2024-11-12 18:11:04 +01:00
Matthias Krüger
134459ea3d
Rollup merge of #131831 - onur-ozkan:improve-rustc-if-unchanged-logic, r=Mark-Simulacrum
extend the "if-unchanged" logic for compiler builds

Implements the first item from [this tracking issue](https://github.com/rust-lang/rust/issues/131744).

In short, we want to make "if-unchanged" logic to check for changes outside of certain allowed directories, and this PR implements that.

See https://github.com/rust-lang/rust/issues/131658 for more context.
2024-11-12 18:11:03 +01:00
bors
6503543d11 Auto merge of #132282 - Noratrieb:it-is-the-end-of-serial, r=cjgillot
Delete the `cfg(not(parallel))` serial compiler

Since it's inception a long time ago, the parallel compiler and its cfgs have been a maintenance burden. This was a necessary evil the allow iteration while not degrading performance because of synchronization overhead.

But this time is over. Thanks to the amazing work by the parallel working group (and the dyn sync crimes), the parallel compiler has now been fast enough to be shipped by default in nightly for quite a while now.
Stable and beta have still been on the serial compiler, because they can't use `-Zthreads` anyways.
But this is quite suboptimal:
- the maintenance burden still sucks
- we're not testing the serial compiler in nightly

Because of these reasons, it's time to end it. The serial compiler has served us well in the years since it was split from the parallel one, but it's over now.

Let the knight slay one head of the two-headed dragon!

#113349

Note that the default is still 1 thread, as more than 1 thread is still fairly broken.

cc `@onur-ozkan` to see if i did the bootstrap field removal correctly, `@SparrowLii` on the sync parts
2024-11-12 15:14:56 +00:00
Ralf Jung
eddab479fd stabilize const_unicode_case_lookup 2024-11-12 15:13:31 +01:00
Noratrieb
505b8e1332 Delete the cfg(not(parallel)) serial compiler
Since it's inception a long time ago, the parallel compiler and its cfgs
have been a maintenance burden. This was a necessary evil the allow
iteration while not degrading performance because of synchronization
overhead.

But this time is over. Thanks to the amazing work by the parallel
working group (and the dyn sync crimes), the parallel compiler has now
been fast enough to be shipped by default in nightly for quite a while
now.
Stable and beta have still been on the serial compiler, because they
can't use `-Zthreads` anyways.
But this is quite suboptimal:
- the maintenance burden still sucks
- we're not testing the serial compiler in nightly

Because of these reasons, it's time to end it. The serial compiler has
served us well in the years since it was split from the parallel one,
but it's over now.

Let the knight slay one head of the two-headed dragon!
2024-11-12 13:38:58 +00:00
clubby789
8c64e9d17d Rename PASS_NAMES to disambiguate 2024-11-12 13:28:05 +00:00
clubby789
12036830d0 Store known passes as an IndexSet 2024-11-12 13:28:05 +00:00
clubby789
94371d5a8c Validate and test -Zmir-enable-passes 2024-11-12 13:28:05 +00:00
clubby789
2a9cc8f4d6 Declare all MIR passes in a list 2024-11-12 13:28:00 +00:00
bors
583b25d8d1 Auto merge of #132843 - RalfJung:mono-time-checks, r=lcnr
move all mono-time checks into their own folder, and their own query

The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features.

Instead of doing this "inside" the collector, this PR refactors things so that we have a new `rustc_monomorphize::mono_checks` module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change, which is nice.

This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector.

Cc `@saethlin` since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.
2024-11-12 11:24:46 +00:00
Rémy Rakic
c6659251c9 clarify must_produce_diag ICE for debugging 2024-11-12 11:21:43 +00:00
bors
5700240aff Auto merge of #132943 - matthiaskrgr:rollup-164l3ej, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #132651 (Remove attributes from generics in built-in derive macros)
 - #132668 (Feature gate yield expressions not in 2024)
 - #132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`)
 - #132895 (Generalize `NonNull::from_raw_parts` per ACP362)
 - #132914 (Update grammar in std::cell docs.)
 - #132927 (Consolidate type system const evaluation under `traits::evaluate_const`)
 - #132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors)
 - #132941 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 08:15:38 +00:00
Matthias Krüger
38c2db4020
Rollup merge of #132941 - lnicola:sync-from-ra2, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-11-12 08:07:20 +01:00
Matthias Krüger
9a4a954359
Rollup merge of #132935 - compiler-errors:arg-math, r=nnethercote
Make sure to ignore elided lifetimes when pointing at args for fulfillment errors

See the comment I left in the code.

---

If we have something like:

```
fn foo<'a, T: 'a + BoundThatIsNotSatisfied>() {}
```

And the user turbofishes just the type args:

```
foo::<()>();
```

Then if we try pointing at `()` (i.e. the type argument for `T`), we don't actually consider the possibility that the lifetimes may have been left out of the turbofish. We try indexing incorrectly into the HIR args, and bail on the suggestion.
2024-11-12 08:07:19 +01:00
Matthias Krüger
ea61714d52
Rollup merge of #132927 - BoxyUwU:consolidate_type_system_const_eval, r=compiler-errors
Consolidate type system const evaluation under `traits::evaluate_const`

Part of #130704

Fixes #128232
Fixes #118545

Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants.

Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold.

From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters.

r? `@compiler-errors`
2024-11-12 08:07:18 +01:00
Matthias Krüger
87d5faf5b6
Rollup merge of #132914 - rcorre:cell-grammar, r=tgross35
Update grammar in std::cell docs.

Using "having" in both the leading sentence and the bullets is unnecessary.
It makes it read as "it is only possible to have having several immutable...".
2024-11-12 08:07:18 +01:00
Matthias Krüger
72c62688d1
Rollup merge of #132895 - scottmcm:generalize-nonnull-from-raw-parts, r=ibraheemdev
Generalize `NonNull::from_raw_parts` per ACP362

I did the raw pointers in #125701, but apparently forgot `NonNull`.

cc https://github.com/rust-lang/libs-team/issues/362
2024-11-12 08:07:17 +01:00
Matthias Krüger
3a0cc81ca3
Rollup merge of #132771 - ismailarilik:test/configure/cover-parse-args-in-src-bootstrap-configure-py, r=onur-ozkan
test(configure): cover `parse_args` in `src/bootstrap/configure.py`

I was reading `src/bootstrap/configure.py` and `parse_args` function there seems complex. So I added some tests to cover it and prevent regressions.
2024-11-12 08:07:16 +01:00
Matthias Krüger
1dd975beb3
Rollup merge of #132668 - ehuss:yield-gate-2024, r=davidtwco
Feature gate yield expressions not in 2024

This changes it so that yield expressions are no longer allowed in the 2024 edition without a feature gate. We are currently only reserving the `gen` keyword in the 2024 edition, and not allowing anything else to be implicitly enabled by the edition.

In practice this doesn't have a significant difference since yield expressions can't really be used outside of coroutines or gen blocks, which have their own feature gates. However, it does affect what is accepted pre-expansion, and I would feel more comfortable not allowing yield expressions.

I believe the stabilization process for gen blocks or coroutines will not need to check the edition here, so this shouldn't ever be needed.
2024-11-12 08:07:16 +01:00
Matthias Krüger
b18ee9858b
Rollup merge of #132651 - PonasKovas:master, r=fmease
Remove attributes from generics in built-in derive macros

Related issue #132561

Removes all attributes from generics in the expanded implementations of built-in derive macros.
2024-11-12 08:07:15 +01:00
Ralf Jung
378049633d allow rustc_private feature in force-unstable-if-unmarked crates 2024-11-12 07:14:49 +01:00
bors
9a9daddd0d Auto merge of #132940 - matthiaskrgr:rollup-f0czmkq, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #132487 (Provide placeholder generics for traits in "no method found for type parameter" suggestions)
 - #132627 (cleanup: Remove outdated comment of `thir_body`)
 - #132653 (Don't use `maybe_unwrap_block` when checking for macro calls in a block expr)
 - #132793 (Update mdbook to 0.4.42)
 - #132847 (elem_offset / subslice_range: use addr() instead of 'as usize')
 - #132869 (split up the first paragraph of doc comments for better summaries)
 - #132929 (Check for null in the `alloc_zeroed` example)
 - #132933 (Make sure that we suggest turbofishing the right type arg for never suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 05:51:31 +00:00
Matthias Krüger
506f52c7f3
Rollup merge of #132933 - compiler-errors:never-lint-arg-bug, r=WaffleLapkin
Make sure that we suggest turbofishing the right type arg for never suggestion

I had a bug where rust would suggest the wrong arg to turbofish `()` if there were any early-bound lifetimes...

r? WaffleLapkin
2024-11-12 06:27:20 +01:00
Matthias Krüger
119b939c18
Rollup merge of #132929 - cuviper:check-alloc_zeroed, r=tgross35
Check for null in the `alloc_zeroed` example

We should demonstrate good behavior, just like #99198 did for `alloc`.
2024-11-12 06:27:20 +01:00
Matthias Krüger
0555bb2a1b
Rollup merge of #132869 - lolbinarycat:library-fix-too_long_first_doc_paragraph, r=tgross35
split up the first paragraph of doc comments for better summaries

used `./x clippy -Aclippy::all '-Wclippy::too_long_first_doc_paragraph' library/core library/alloc` to find these issues.
2024-11-12 06:27:19 +01:00
Matthias Krüger
953064f00a
Rollup merge of #132847 - RalfJung:addr-dont-expose, r=Mark-Simulacrum
elem_offset / subslice_range: use addr() instead of 'as usize'

There's no reason to use ptr-to-int casts with their subtle semantics here.
2024-11-12 06:27:19 +01:00
Matthias Krüger
52bb9fafd0
Rollup merge of #132793 - ehuss:update-mdbook, r=Mark-Simulacrum
Update mdbook to 0.4.42

This updates mdbook to 0.4.42
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0441

There were some significant changes that I would like to get early testing on.

This also updates rust-by-example which was required due to an update to the theme file.
2024-11-12 06:27:18 +01:00
Matthias Krüger
b7dc4813a8
Rollup merge of #132653 - BoxyUwU:const_arg_stmt_mac_call, r=compiler-errors
Don't use `maybe_unwrap_block` when checking for macro calls in a block expr

Fixes #131915

Using `maybe_unwrap_block` to determine if we are looking at a `{ mac_call!{} }` will fail sometimes as `mac_call!{}` could be a `StmtKind::MacCall` not a `StmtKind::Expr`. This caused the def collector to think that `{ mac_call!{} }` was a non-trivial const argument and create a definition for it even though it should not.

r? `@compiler-errors`  cc `@camelid`
2024-11-12 06:27:17 +01:00
Matthias Krüger
2ad4a3568d
Rollup merge of #132627 - adwinwhite:thir_body_cleanup, r=compiler-errors
cleanup: Remove outdated comment of `thir_body`

When typeck fails, `thir_body` returns `ErrorGuaranteed` rather than empty body.

No other code follows this outdated description except `check_unsafety`, which is also cleaned up in this PR.
2024-11-12 06:27:17 +01:00
Matthias Krüger
9098e03fb2
Rollup merge of #132487 - dianne:include-trait-args-in-suggestion, r=fmease
Provide placeholder generics for traits in "no method found for type parameter" suggestions

In the diagnostics for the error ``no method named `method` found for type parameter `T` in the current scope [E0599]``, the compiler will suggest adding bounds on `T` for traits that define a method named `method`. However, these suggestions didn't include any generic arguments, so applying them would result in a `missing generics for trait` or `missing lifetime specifier` error. This PR adds placeholder arguments to the suggestion in such cases. Specifically, I tried to base the placeholders off of what's done in suggestions for when generics are missing or too few are provided:
- The placeholder for a parameter without a default is the name of the parameter.
- Placeholders are not provided for parameters with defaults.

Placeholder arguments are enclosed in `/*` and `*/`, and the applicability of the suggestion is downgraded to `Applicability::HasPlaceholders` if any placeholders are provided.

Fixes #132407
2024-11-12 06:27:16 +01:00
ismailarilik
1ba72db242 test(configure): cover parse_args in src/bootstrap/configure.py 2024-11-12 07:28:23 +03:00
Michael Goulet
0dc6c1e594 Make precise capturing suggestion machine-applicable only if it has not APITs 2024-11-12 04:08:34 +00:00
Michael Goulet
8473e3f6af Make sure that we suggest turbofishing the right type arg 2024-11-12 03:02:23 +00:00
Boxy
bea0148ac6 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
bors
67f21277cd Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #120077 (Add Set entry API )
 - #132144 (Arbitrary self types v2: (unused) Receiver trait)
 - #132297 (Document some `check_expr` methods, and other misc `hir_typeck` tweaks)
 - #132820 (Add a default implementation for CodegenBackend::link)
 - #132881 (triagebot: Autolabel rustdoc book)
 - #132912 (Simplify some places that deal with generic parameter defaults)
 - #132916 (Unvacation fmease)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 02:51:21 +00:00
Michael Goulet
d128c80c7a Make sure to ignore elided lifetimes when pointing at args for fulfillment errors 2024-11-12 02:08:39 +00:00
Josh Stone
2ddb91acd1 Check for null in the alloc_zeroed example
We should demonstrate good behavior, just like #99198 did for `alloc`.
2024-11-11 16:30:37 -08:00
León Orell Valerian Liehr
5b7423c2fc
Triagebot: Consolidate the T-compiler ad hoc groups 2024-11-12 00:33:23 +01:00
Matthias Krüger
2d026525db
Rollup merge of #132916 - fmease:unvac-me, r=fmease
Unvacation fmease

It's become a hindrance.
r? ghost
2024-11-11 21:58:34 +01:00
Matthias Krüger
b41baf8c81
Rollup merge of #132912 - fmease:simplify-gen-param-default-users, r=compiler-errors
Simplify some places that deal with generic parameter defaults
2024-11-11 21:58:33 +01:00
Matthias Krüger
f344169e7d
Rollup merge of #132881 - aDotInTheVoid:docs-for-docs, r=jieyouxu
triagebot: Autolabel rustdoc book

Inspired by #132876 not getting labeled as https://github.com/rust-lang/rust/labels/T-rustdoc

r? `@GuillaumeGomez`
2024-11-11 21:58:32 +01:00