Commit graph

258006 commits

Author SHA1 Message Date
Manish Goregaokar e8a9af9ad9 Clarify that anonymous consts still do introduce a new scope 2024-06-19 18:34:15 -07:00
Nicholas Nethercote 19b7192c72 Fix assertion failure for some Expect diagnostics.
In #120699 I moved some code dealing with `has_future_breakage` earlier
in `emit_diagnostic`. Issue #126521 identified a case where that
reordering was invalid (leading to an assertion failure) for some `Expect`
diagnostics.

This commit partially undoes the change, by moving the handling of
unstable `Expect` diagnostics earlier again. This makes
`emit_diagnostic` a bit uglier, but is necessary to fix the problem.

Fixes #126521.
2024-06-20 10:17:40 +10:00
Nicholas Nethercote b5a5647ee0 Move an EMIT_MIR comment.
This belongs on a function, not a `use` declaration.
2024-06-20 09:23:20 +10:00
Nicholas Nethercote 9981d61cdb Remove useless tidy-alphabetical markers.
rustfmt already sorts `use` declarations within the same group.
2024-06-20 09:23:20 +10:00
Nicholas Nethercote b104fbec85 Add blank lines after module-level // comments.
Similar to the previous commit.
2024-06-20 09:23:20 +10:00
Nicholas Nethercote 665821cb60 Add blank lines after module-level //! comments.
Most modules have such a blank line, but some don't. Inserting the blank
line makes it clearer that the `//!` comments are describing the entire
module, rather than the `use` declaration(s) that immediately follows.
2024-06-20 09:23:20 +10:00
Nicholas Nethercote 09006d6a88 Convert some module-level // and /// comments to //!.
This makes their intent and expected location clearer. We see some
examples where these comments were not clearly separate from `use`
declarations, which made it hard to understand what the comment is
describing.
2024-06-20 09:23:18 +10: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
George Bateman 35c65a8c0c
Make Option::as_[mut_]slice const 2024-06-19 21:44:47 +01: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
Oneirical e7ea063622 rewrite forced-unwind-terminate-pof to rmake 2024-06-19 14:39:09 -04: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
Trevor Gross 477e9e8051 Update float tests to include f16 and f128 2024-06-19 13:30:21 -04:00
Trevor Gross ff9efea646 Resolve Clippy f16 and f128 unimplemented!/FIXMEs
This removes the ICE codepaths for `f16` and `f128` in Clippy.
`rustc_apfloat` is used as a dependency for the parsing of these types,
since their `FromStr` implementation will not be available in the
standard library for a while.
2024-06-19 13:30:21 -04: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
Oneirical b3c51323b5 make assert_stderr_contains print its contents on panic 2024-06-19 11:50:22 -04: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