Commit graph

257933 commits

Author SHA1 Message Date
Michael Goulet 108b3f214a Properly gate safe keyword in pre-expansion 2024-06-20 14:14:49 -04:00
bors 1aaab8b9f8 Auto merge of #116088 - nbdd0121:unwind, r=Amanieu,RalfJung
Stabilise `c_unwind`

Fix #74990
Fix #115285 (that's also where FCP is happening)

Marking as draft PR for now due to `compiler_builtins` issues

r? `@Amanieu`
2024-06-20 11:22:59 +00:00
bors 1d96de2a20 Auto merge of #126409 - pacak:incr-uplorry, r=michaelwoerister
Trying to address an incremental compilation issues

This pull request contains two independent changes, one makes it so when `try_force_from_dep_node` fails to recover a query - it marks the node as "red" instead of "green" and the second one makes Debug impl for `DepNode` less panicky if it encounters something from the previous compilation that doesn't map to anything in the current one.

I'm not 100% confident that this is the correct approach, but so far I managed to find a bunch of comments suggesting that some things are allowed to fail in a certain way and changes I made are allowing for those things to fail this way and it fixes all the small reproducers I managed to find.

Compilation panic this pull request avoids is caused by an automatically generated code on an associated type and it is not happening if something else marks it as outdated first (or close like that, but scenario is quite obscure).

Fixes https://github.com/rust-lang/rust/issues/107226
Fixes https://github.com/rust-lang/rust/issues/125367
2024-06-20 09:06:16 +00:00
bors 1208eddaff Auto merge of #126726 - matthiaskrgr:rollup-ppe8ve3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #126620 (Actually taint InferCtxt when a fulfillment error is emitted)
 - #126649 (Fix `feature = "nightly"` in the new trait solver)
 - #126652 (Clarify that anonymous consts still do introduce a new scope)
 - #126703 (reword the hint::blackbox non-guarantees)
 - #126708 (Minimize `can_begin_literal_maybe_minus` usage)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-20 06:54:19 +00:00
Matthias Krüger c979535aa5
Rollup merge of #126708 - nnethercote:minimize-can_begin_literal_maybe_minus, r=compiler-errors
Minimize `can_begin_literal_maybe_minus` usage

`can_begin_literal_maybe_minus` is used in a few confusing ways. This PR makes them clearer.

r? ``@spastorino``
2024-06-20 07:52:45 +02:00
Matthias Krüger af073e4e88
Rollup merge of #126703 - the8472:on-blackbox-crypto-use, r=scottmcm
reword the hint::blackbox non-guarantees

People were tripped up by the "precludes", interpreting it that this function must not ever be used in cryptographic contexts rather than the std lib merely making zero promises about it being fit-for-purpose.

What remains unchanged is that if someone does try to use it *despite the warnings* then it is on them to pin their compiler versions and verify the assembly of every single binary build they do.
2024-06-20 07:52:45 +02:00
Matthias Krüger 03d558f5b6
Rollup merge of #126652 - Manishearth:anon-const-scope, r=bjorn3,Urgau
Clarify that anonymous consts still do introduce a new scope

See https://github.com/rust-lang/rust/issues/120363#issuecomment-2177064702

This error message is misleading: it's trying to say that `const _ : () = ...` is a workaround for the lint, but by saying that anonymous constants are treated as being in the parent scope, it makes them appear useless for scope-hiding.

They *are* useful for scope-hiding, they are simply treated as part of the parent scope when it comes to this lint.
2024-06-20 07:52:44 +02:00
Matthias Krüger 8ddc8921ff
Rollup merge of #126649 - compiler-errors:nightly, r=lcnr
Fix `feature = "nightly"` in the new trait solver

r? lcnr
2024-06-20 07:52:44 +02:00
Matthias Krüger e7be3562b7
Rollup merge of #126620 - oli-obk:taint_errors, r=fee1-dead
Actually taint InferCtxt when a fulfillment error is emitted

And avoid checking the global error counter

fixes #122044
fixes #123255
fixes #123276
fixes #125799
2024-06-20 07:52:43 +02:00
bors 54fcd5bb92 Auto merge of #126534 - Rejyr:comment-section-migration, r=jieyouxu
Migrate `run-make/comment-section` to `rmake.rs`

Part of #121876.

r? `@jieyouxu`

try-job: x86_64-msvc
try-job: aarch64-gnu
try-job: aarch64-apple
2024-06-20 04:40:44 +00:00
Manish Goregaokar e8a9af9ad9 Clarify that anonymous consts still do introduce a new scope 2024-06-19 18:34:15 -07:00
bors 3d5d7a24f7 Auto merge of #126308 - scottmcm:ban-some-coercions, r=saethlin
Ban `ArrayToPointer` and `MutToConstPointer` from runtime MIR

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/CastKind.3A.3APointerCoercion.20in.20Runtime.20MIR/near/443955195>

Apparently MIR borrowck cares about at least one of these for checking variance.

In runtime MIR, though, there's no need for them as `PtrToPtr` does the same thing.

(Banning them simplifies passes like GVN that no longer need to handle multiple cast possibilities.)

r? mir
2024-06-19 22:34:11 +00:00
Gary Guo bb2716effd Fix wasm_exceptions test 2024-06-19 21:26:48 +01:00
Jerry Wang f44494cb3a
Migrate run-make/comment-section to rmake.rs 2024-06-19 15:55:57 -04:00
Nicholas Nethercote c6f78270b6 Introduce can_begin_string_literal.
We currently use `can_begin_literal_maybe_minus` in a couple of places
where only string literals are allowed. This commit introduces a
more specific function, which makes things clearer. It doesn't change
behaviour because the two functions affected (`is_unsafe_foreign_mod`
and `check_keyword_case`) are always followed by a call to `parse_abi`,
which checks again for a string literal.
2024-06-20 04:50:40 +10:00
Nicholas Nethercote 7d9a92ba31 Inline can_begin_literal_maybe_minus call into two places.
It's clearer this way, because the `Interpolated` cases in
`can_begin_const_arg` and `is_pat_range_end_start` are more permissive
than the `Interpolated` cases in `can_begin_literal_maybe_minus`.
2024-06-20 04:50:38 +10:00
bors d8a38b0002 Auto merge of #119127 - joboet:array_repeat, r=scottmcm
Implement `array::repeat`

See rust-lang/libs-team#310.

I've decided to make the function use the input value as last element instead of cloning it to every position and dropping it, and to make this part of the API so that callers are not surprised by this behaviour.

TODO: open a tracking issue. I'll wait for the ACP to be accepted, first.

`@rustbot` label +T-libs-api +T-libs
r? libs
2024-06-19 18:47:04 +00:00
The 8472 95e214d6e5 reword the hint::blackbox non-guarantees
People were tripped up by the "precludes", interpreting it that this function
must not ever be used in cryptographic contexts rather than the std lib merely
making zero promises about it being fit-for-purpose.

What remains unchanged is that if someone does try to use it *despite the warnings*
then it is on them to pin their compiler versions and verify the assembly of every
single binary build they do.
2024-06-19 20:01:32 +02:00
Scott McMurray e04e35133f bug! more uses of these in runtime stuff 2024-06-19 10:44:01 -07:00
Scott McMurray 4630d1b23b Ban ArrayToPointer and MutToConstPointer from runtime MIR
Apparently MIR borrowck cares about at least one of these for checking variance.

In runtime MIR, though, there's no need for them as `PtrToPtr` does the same thing.

(Banning them simplifies passes like GVN that no longer need to handle multiple cast possibilities.)
2024-06-19 10:44:01 -07:00
bors 5c8459f1ec Auto merge of #126691 - fee1-dead-contrib:rollup-v4vtowh, r=fee1-dead
Rollup of 5 pull requests

Successful merges:

 - #126668 (Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`)
 - #126674 (Allow tracing through item_bounds query invocations on opaques)
 - #126675 (Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code)
 - #126681 (Rework doc-test attribute documentation example)
 - #126684 (Migrate `run-make/glibc-staticlib-args` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 16:10:30 +00:00
joboet 0aa3310a9a
update codegen test for array::repeat 2024-06-19 17:48:05 +02:00
joboet e1aacea74d
core: add tracking issue for array::repeat 2024-06-19 17:48:00 +02:00
joboet 1a8b0d7c53
add codegen test for array::repeat 2024-06-19 17:29:54 +02:00
joboet 39a918002e
core: simplify implementation of array::repeat, address other nits 2024-06-19 17:29:54 +02:00
joboet 8aa24572f0
core: implement UncheckedIterator for RepeatN 2024-06-19 17:29:54 +02:00
joboet 3d4f8b1f45
core: implement array::repeat 2024-06-19 17:29:53 +02:00
Oli Scherer e4c9a8cf9b Const generic parameters aren't bounds, even if we end up erroring because of the bound that binds the parameter's type 2024-06-19 14:58:29 +00:00
fee1-dead 9e8a7a87e4
Rollup merge of #126684 - GuillaumeGomez:migrate-run-make-glibc-staticlib-args, r=Kobzol
Migrate `run-make/glibc-staticlib-args` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? ``@jieyouxu``
2024-06-19 22:51:06 +08:00
fee1-dead 69e26df5c4
Rollup merge of #126681 - Urgau:rustdoc-deny-doc, r=GuillaumeGomez
Rework doc-test attribute documentation example

This PR change the doc-test attribute documentation example to prefer a more neutral example `deny(dead_code)`, instead of `deny(warnings)`, which is less susceptible to breakage across Rust version.

r? ```@GuillaumeGomez```
2024-06-19 22:51:05 +08:00
fee1-dead e649eca1d2
Rollup merge of #126675 - oli-obk:diagnostics_opaque, r=jackh726
Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code

Explanation in comments of the function.

r? ```@compiler-errors```

cc https://github.com/rust-lang/rust/issues/116652
2024-06-19 22:51:05 +08:00
fee1-dead cc4ace33cf
Rollup merge of #126674 - oli-obk:tracing_item_bounds, r=lqd
Allow tracing through item_bounds query invocations on opaques

Previously these caused cycles when printing the result of the query.
2024-06-19 22:51:04 +08:00
fee1-dead be3b5663ae
Rollup merge of #126668 - fmease:rm-rustc_dump_program_clauses-attrs, r=fee1-dead
Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`

Likely NOP since #113303.

r? `@fee1-dead`
2024-06-19 22:51:03 +08:00
bors 894f7a4ba6 Auto merge of #126678 - nnethercote:fix-duplicated-attrs-on-nt-expr, r=petrochenkov
Fix duplicated attributes on nonterminal expressions

This PR fixes a long-standing bug (#86055) whereby expression attributes can be duplicated when expanded through declarative macros.

First, consider how items are parsed in declarative macros:
```
Items:
- parse_nonterminal
  - parse_item(ForceCollect::Yes)
    - parse_item_
      - attrs = parse_outer_attributes
      - parse_item_common(attrs)
        - maybe_whole!
        - collect_tokens_trailing_token
```
The important thing is that the parsing of outer attributes is outside token collection, so the item's tokens don't include the attributes. This is how it's supposed to be.

Now consider how expression are parsed in declarative macros:
```
Exprs:
- parse_nonterminal
  - parse_expr_force_collect
    - collect_tokens_no_attrs
      - collect_tokens_trailing_token
        - parse_expr
          - parse_expr_res(None)
            - parse_expr_assoc_with
              - parse_expr_prefix
                - parse_or_use_outer_attributes
                - parse_expr_dot_or_call
```
The important thing is that the parsing of outer attributes is inside token collection, so the the expr's tokens do include the attributes, i.e. in `AttributesData::tokens`.

This PR fixes the bug by rearranging expression parsing to that outer attribute parsing happens outside of token collection. This requires a number of small refactorings because expression parsing is somewhat complicated. While doing so the PR makes the code a bit cleaner and simpler, by eliminating `parse_or_use_outer_attributes` and `Option<AttrWrapper>` arguments (in favour of the simpler `parse_outer_attributes` and `AttrWrapper` arguments), and simplifying `LhsExpr`.

r? `@petrochenkov`
2024-06-19 13:58:21 +00:00
Gary Guo 4c4d62d74f Fix non-x86 tests 2024-06-19 13:54:56 +01:00
Gary Guo 9d2b932d71 Fix broken aarch64 unwind test 2024-06-19 13:54:55 +01:00
Gary Guo da8ac73d91 Add a hack to prevent proc_macro misopt in CI 2024-06-19 13:54:55 +01:00
Gary Guo 5812b1fd12 Remove c_unwind from tests and fix tests 2024-06-19 13:54:55 +01:00
Gary Guo ebdfcd93a3 Stabilise c_unwind 2024-06-19 13:54:51 +01:00
Guillaume Gomez 0c2bfd913e Migrate run-make/glibc-staticlib-args to rmake.rs 2024-06-19 13:57:55 +02:00
Michael Baikov 12f8d12b41 local_def_path_hash_to_def_id can fail
local_def_path_hash_to_def_id is used by Debug impl for DepNode and it
looks for DefPathHash inside the current compilation. During incremental
compilation we are going through nodes that belong to a previous
compilation and might not be present and a simple attempt to print such
node with tracing::debug (try_mark_parent_green does it for example)
results in a otherwise avoidable panic

Panic was added in https://github.com/rust-lang/rust/pull/82183,
specifically in 2b60338ee9, with a comment "We only use this mapping for
cases where we know that it must succeed.", but I'm not sure if this
property holds when we traverse nodes from the old compilation in order
to figure out if they are valid or not
2024-06-19 07:45:47 -04:00
Michael Baikov db5ed4bd79 Allow for try_force_from_dep_node to fail
The way it is implemented currently try_force_from_dep_node returns true
as long as there's a function to force the query. It wasn't this way
from the beginning, earlier version was producing forcing result and it
was changed in https://github.com/rust-lang/rust/pull/89978, I couldn't
find any comments addressing this change.

One way it can fail is by failing to recover the query in
DepNodeParams::recover - when we are trying to query something that no
longer exists in the current environment
2024-06-19 07:21:41 -04:00
bors 3186d17d56 Auto merge of #126679 - fmease:rollup-njrv2py, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #125447 (Allow constraining opaque types during subtyping in the trait system)
 - #125766 (MCDC Coverage: instrument last boolean RHS operands from condition coverage)
 - #125880 (Remove `src/tools/rust-demangler`)
 - #126154 (StorageLive: refresh storage (instead of UB) when local is already live)
 - #126572 (override user defined channel when using precompiled rustc)
 - #126662 (Unconditionally warn on usage of `wasm32-wasi`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-19 11:09:31 +00:00
Urgau d70d76b9e7 Rework doc-test attribute documentation example 2024-06-19 13:08:26 +02:00
León Orell Valerian Liehr ca61d7470a
Rollup merge of #126662 - alexcrichton:warn-on-wasm32-wasi, r=michaelwoerister
Unconditionally warn on usage of `wasm32-wasi`

This commit is a continuation of the work originally proposed in rust-lang/compiler-team#607 and later amended in
rust-lang/compiler-team#695. The end goal is to rename `wasm32-wasi` to `wasm32-wasip1` to reflect WASI's development and distinguish the preexisting target from the `wasm32-wasip2` target that WASI is now developing. Work for this transition began in #120468 which landed in Rust 1.78 which became stable on 2024-05-02.

This implements the next phase of the transition plan to warn on usage of `wasm32-wasi`. This is intended to help alert users that a removal is pending and all release channels have the replacement available as well. This will reach stable on 2024-09-05. The next stage of the plan is to remove the `wasm32-wasi` target some time in October 2024 which means that the removal will reach stable on 2025-01-09. For reference a full schedule of this transition is listed [here].

Currently this implementation is a simple unconditional warning whenever `rustc --target wasm32-wasi` is invoked. As-implemented there's no way to turn off the warning other than to switch to the `wasm32-wasip1` target.

[here]: https://github.com/rust-lang/rust/pull/120468#issuecomment-1977878747
2024-06-19 13:04:59 +02:00
León Orell Valerian Liehr cbf9d57e89
Rollup merge of #126572 - onur-ozkan:channel-problem, r=clubby789
override user defined channel when using precompiled rustc

We need to override `rust.channel` if it's manually specified when using the CI rustc. This is because if the compiler uses a different channel than the one specified in config.toml, tests may fail due to using a different channel than the one used by the compiler during tests.

For more context, see https://github.com/rust-lang/rust/pull/122709#issuecomment-2165246281.
2024-06-19 13:04:59 +02:00
León Orell Valerian Liehr 035285b464
Rollup merge of #126154 - RalfJung:storage-live, r=compiler-errors
StorageLive: refresh storage (instead of UB) when local is already live

Blocked on [this FCP](https://github.com/rust-lang/rust/issues/99160#issuecomment-2155924538), which also contains the motivation.

Fixes https://github.com/rust-lang/rust/issues/99160
Fixes https://github.com/rust-lang/rust/issues/98896 (by declaring it not-a-bug)
Fixes https://github.com/rust-lang/rust/issues/119366
Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/129
2024-06-19 13:04:58 +02:00
León Orell Valerian Liehr 1e460368fd
Rollup merge of #125880 - Zalathar:demangler, r=oli-obk
Remove `src/tools/rust-demangler`

`rust-demangler` is a small binary that reads a list of mangled symbols from stdin, demangles them (using the `rustc-demangle` library crate), and prints the demangled symbols to stdout.

It was added as part of the initial implementation of coverage instrumentation in 2020/2021, so that coverage tests could pass it to `llvm-cov --Xdemangler` when generating coverage reports. It has been largely untouched since then.

As of #125816 it is no longer used by coverage tests, and has no remaining in-tree uses.

There is code in bootstrap to build and package the demangler, but it's unclear where the resulting binaries actually end up, or whether there's any reasonable way for `rustup` users to obtain them.

---

For users needing a command-line demangler, `rustfilt` exists and is more actively maintained. It's also quite easy to use the `rustc-demangle` library to build a custom command-line demangler if necessary, with only a few lines of code.

The tool's name (`rust-demangler`) is easily confused with the name of the library crate `rustc-demangle`, so removing the tool will eliminate that confusion. There also doesn't appear to be much reason to use `rust-demangler` over `rustfilt`.

---

This PR therefore removes the tool, and removes all of its associated code from bootstrap.

MCP filed: https://github.com/rust-lang/compiler-team/issues/754
2024-06-19 13:04:58 +02:00
León Orell Valerian Liehr a7cf6ece62
Rollup merge of #125766 - RenjiSann:fresh-mcdc-branch-on-bool, r=nnethercote
MCDC Coverage: instrument last boolean RHS operands from condition coverage

Fresh PR from #124652

--

This PR ensures that the top-level boolean expressions that are not part of the control flow are correctly instrumented thanks to condition coverage.

See discussion on https://github.com/rust-lang/rust/issues/124120.
Depends on `@Zalathar` 's condition coverage implementation #125756.
2024-06-19 13:04:57 +02:00
León Orell Valerian Liehr 25d47fe388
Rollup merge of #125447 - oli-obk:eq_opaque_pred, r=compiler-errors
Allow constraining opaque types during subtyping in the trait system

Previous attempt: https://github.com/rust-lang/rust/pull/123979

Sometimes we don't immediately perform subtyping, but instead register a subtyping obligation and solve that obligation when its inference variables become resolved. Unlike immediate subtyping, we currently do not allow registering hidden types for opaque types. This PR also allows that.
2024-06-19 13:04:56 +02:00