Commit Graph

12665 Commits

Author SHA1 Message Date
Nadrieril
99468bb760 Update tests 2024-08-10 12:07:17 +02:00
Nadrieril
cd40769c02 Stabilize min_exhaustive_patterns 2024-08-10 12:07:17 +02:00
bors
19469cb536 Auto merge of #128714 - camelid:wf-struct-exprs, r=BoxyUwU
WF-check struct field types at construction site

Fixes #126272.
Fixes #127299.

Rustc of course already WF-checked the field types at the definition
site, but for error tainting of consts to work properly, there needs to
be an error emitted at the use site. Previously, with no use-site error,
we proceeded with CTFE and ran into ICEs since we are running code with
type errors.

Emitting use-site errors also brings struct-like constructors more in
line with fn-like constructors since they already emit use-site errors
for WF issues.

r? `@BoxyUwU`
2024-08-10 05:27:17 +00:00
burlinchen
3dc083dfd8 test(std): Add codegen test for array::from_fn optimization
This commit adds a new test file 'array-from_fn.rs' to the codegen test suite.
The test checks the behavior of std::array::from_fn under different optimization levels:

1. At opt-level=0 (debug build), it verifies that the core::array::Guard
   is present in the generated code.
2. At opt-level=s (size optimization), it ensures that the Guard is
   optimized out.

This test helps ensure that the compiler correctly optimizes array::from_fn
calls in release builds while maintaining safety checks in debug builds.
2024-08-10 10:44:24 +08:00
Michael Goulet
20a16bb3c5 Add test
Co-authored-by: Georg Semmler <github@weiznich.de>
2024-08-09 22:02:23 -04:00
bors
69b380dc1c Auto merge of #128584 - DianQK:tests-for-llvm-19, r=nikic
Add a set of tests for LLVM 19

Close #107681. Close #118306. Close #126585.

r? compiler
2024-08-10 01:59:54 +00:00
Esteban Küber
860c8cdeaf Differentiate between methods and associated functions
Accurately refer to assoc fn without receiver as assoc fn instead of methods.
Add `AssocItem::descr` method to centralize where we call methods and associated functions.
2024-08-10 00:54:16 +00:00
Ben Kimock
d6c0ebef50 Polymorphize RawVec 2024-08-09 20:06:26 -04:00
Ben Kimock
f595539b81 Fix dump-ice-to-disk for RUSTC_ICE=0 users 2024-08-09 20:01:25 -04:00
Michael Howell
4dc13c5471 diagnostics: do not warn when a lifetime bound infers itself 2024-08-09 16:16:16 -07:00
bors
68d2e8a66e Auto merge of #125642 - khuey:zstd, r=Kobzol
Enable zstd for debug compression.

Set LLVM_ENABLE_ZSTD alongside LLVM_ENABLE_ZLIB so that --compress-debug-sections=zstd is an option.

See #120953

try-job: x86_64-gnu-tools
2024-08-09 22:44:37 +00:00
Chris Denton
ef90df6904
Update reason why fmt-write-bloat ignores windows 2024-08-09 21:21:43 +00:00
Chris Denton
2cc029edf5
Only link libc on *nix platforms 2024-08-09 21:17:32 +00:00
Ralf Jung
9a233bb9dd interpret: make identity upcasts a NOP again to avoid them generating a new random vtable 2024-08-09 18:48:45 +02:00
Matthias Krüger
665a1a4b55
Rollup merge of #128865 - jieyouxu:unicurd, r=Urgau
Ensure let stmt compound assignment removal suggestion respect codepoint boundaries

Previously we would try to issue a suggestion for `let x <op>= 1`, i.e.
a compound assignment within a `let` binding, to remove the `<op>`. The
suggestion code unfortunately incorrectly assumed that the `<op>` is an
exactly-1-byte ASCII character, but this assumption is incorrect because
we also recover Unicode-confusables like `=` as `-=`. In this example,
the suggestion code used a `+ BytePos(1)` to calculate the span of the
`<op>` codepoint that looks like `-` but the mult-byte Unicode
look-alike would cause the suggested removal span to be inside a
multi-byte codepoint boundary, triggering a codepoint boundary
assertion.

The fix is to use `SourceMap::start_point(token_span)` which properly accounts for codepoint boundaries.

Fixes #128845.

cc #128790

r? ````@fmease````
2024-08-09 18:25:00 +02:00
Matthias Krüger
9eb77ac3e0
Rollup merge of #128864 - jieyouxu:funnicode, r=Urgau
Use `SourceMap::end_point` instead of `- BytePos(1)` in arg removal suggestion

Previously, we tried to remove extra arg commas when providing extra arg removal suggestions. One of
the edge cases is having to account for an arg that has a closing delimiter `)` following it.
However, the previous suggestion code assumed that the delimiter is in fact exactly the 1-byte `)`
character. This assumption was proven incorrect, because we recover from Unicode-confusable
delimiters in the parser, which means that the ending delimiter could be a multi-byte codepoint
that looks *like* a `)`. Subtracing 1 byte could land us in the middle of a codepoint, triggering a
codepoint boundary assertion.

This is fixed by using `SourceMap::end_point` which properly accounts for codepoint boundaries.

Fixes #128717.

cc ````@fmease```` and #128790
2024-08-09 18:24:59 +02:00
Matthias Krüger
9f11eb13b8
Rollup merge of #128838 - notriddle:notriddle/invalid-tag-is-not-rust, r=GuillaumeGomez
rustdoc: do not run doctests with invalid langstrings

https://github.com/rust-lang/rust/pull/124577#issuecomment-2276034737

CC ``@decathorpe``
2024-08-09 18:24:58 +02:00
Michael Howell
1d19c2c009 rustdoc: move invalid langstring test to UI 2024-08-09 07:57:46 -07:00
Kyle Huey
9f3376eaf2 Test --compress-debug-sections with rust-lld. 2024-08-09 05:55:39 -07:00
bors
899eb03926 Auto merge of #128703 - compiler-errors:normalizing-tails, r=lcnr
Miscellaneous improvements to struct tail normalization

1. Make checks for foreign tails more accurate by normalizing the struct tail. I didn't write a test for this one.
2. Normalize when computing struct tail for `offset_of` for slice/str. This fixes the new solver only.
3. Normalizing when computing tails for disaligned reference check. This fixes both solvers.

r? lcnr
2024-08-09 11:36:01 +00:00
Ding Xiang Fei
b368dcb246
unconditionally allow shadow call-stack for AArch64 whenever fixed-x18 is applied 2024-08-09 19:35:02 +08:00
许杰友 Jieyou Xu (Joe)
92520a9d4d tests: add regression test for #128845
For codepoint boundary assertion triggered by a let stmt compound
assignment removal suggestion when encountering recovered multi-byte
compound ops.

Issue: <https://github.com/rust-lang/rust/issues/128845>
2024-08-09 05:52:53 +00:00
许杰友 Jieyou Xu (Joe)
b589f86a09 tests: add regression test for incorrect BytePos manipulation triggering assertion
Issue: <https://github.com/rust-lang/rust/issues/128717>
2024-08-09 05:03:55 +00:00
Matthias Krüger
521e75412f
Rollup merge of #128823 - ChrisDenton:staticlib, r=jieyouxu
run-make: enable msvc for staticlib-dylib-linkage

`-Zstaticlib-allow-rdylib-deps` on MSVC returns things like `/LIBPATH:R:\rust\build\x86_64-pc-windows-msvc\test\run-make\staticlib-dylib-linkage\rmake_out`. That is a linker argument rather than a `cc` argument. Which makes sense because rustc interacts directly with the linker on MSVC targets. So we need to tell the C compiler to pass on the arguments to the linker.

try-job: x86_64-msvc
try-job: i686-msvc
2024-08-09 05:52:16 +02:00
Matthias Krüger
408baccd0d
Rollup merge of #128804 - ChrisDenton:redudant, r=jieyouxu
run-make: enable msvc for redundant-libs

The issue here was that `foo` was not exporting any functions therefore creating an import library was unnecessary and elided by the linker.

I fixed it by exporting the functions.

try-job: x86_64-msvc
try-job: i686-msvc
2024-08-09 05:52:15 +02:00
Matthias Krüger
7485f8b9ab
Rollup merge of #128616 - compiler-errors:mir-inline-tainted, r=cjgillot
Don't inline tainted MIR bodies

Don't inline MIR bodies that are tainted, since they're not necessarily well-formed.

Fixes #128601 (I didn't add a new test, just copied one from the crashes, since they're the same root cause).
Fixes #122909.
2024-08-09 05:52:14 +02:00
Michael Goulet
65b029b468 Don't inline tainted MIR bodies 2024-08-08 20:53:25 -04:00
Matthias Krüger
8789b95b67
Rollup merge of #128836 - its-the-shrimp:add_test_for_107278, r=aDotInTheVoid
rustdoc-json: add a test for impls on private & hidden types

Fixes #107278 (or rather just ensures it won't resurface)
r? ``@aDotInTheVoid``
2024-08-09 00:03:38 +02:00
Matthias Krüger
5e388ea48e
Rollup merge of #128834 - its-the-shrimp:fix_101105, r=aDotInTheVoid
rustdoc: strip unreachable modules

Modules are now stripped based on the same logic that's used to strip other item kinds
Fixes #101105
2024-08-09 00:03:37 +02:00
Matthias Krüger
bcf6f9fa76
Rollup merge of #128791 - compiler-errors:async-fn-unsafe, r=lcnr
Don't implement `AsyncFn` for `FnDef`/`FnPtr` that wouldnt implement `Fn`

Due to unsafety, ABI, or the presence of target features, some `FnDef`/`FnPtr` types don't implement `Fn*`. Do the same for `AsyncFn*`.

Noticed this due to #128764, but this isn't really related to that ICE, which is fixed in #128792.
2024-08-09 00:03:36 +02:00
Michael Howell
7c4150fce0 rustdoc: do not run doctests with invalid langstrings 2024-08-08 13:33:34 -07:00
bors
3e9bd8b566 Auto merge of #128835 - matthiaskrgr:rollup-apzlbxy, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128306 (Update NonNull::align_offset quarantees)
 - #128612 (Make `validate_mir` ensure the final MIR for all bodies)
 - #128648 (Add regression test)
 - #128749 (Mark `{f32,f64}::{next_up,next_down,midpoint}` inline)
 - #128795 (Update E0517 message to reflect RFC 2195.)
 - #128825 (rm `declared_features` field in resolver)
 - #128826 (Only suggest `#[allow]` for `--warn` and `--deny` lint level flags)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-08 19:24:26 +00:00
Michael Goulet
ec1c424293 Don't implement AsyncFn for FnDef/FnPtr that wouldnt implement Fn 2024-08-08 14:07:31 -04:00
Matthias Krüger
70dccc2e9b
Rollup merge of #128826 - Alexendoo:lint-override-suggestions, r=compiler-errors
Only suggest `#[allow]` for `--warn` and `--deny` lint level flags

`--force-warn` and `--forbid` cannot be overridden
2024-08-08 18:57:04 +02:00
Matthias Krüger
53f2ac30e4
Rollup merge of #128648 - tiif:issue-125873, r=lcnr
Add regression test

Fixes #125873
2024-08-08 18:57:01 +02:00
Matthias Krüger
2d7075cf00
Rollup merge of #128612 - compiler-errors:validate-mir-opt-mir, r=davidtwco
Make `validate_mir` ensure the final MIR for all bodies

A lot of the crashes tests use `-Zpolymorphize` or `-Zdump-mir` for their side effect of computing the `optimized_mir` for all bodies, which will uncover bugs with late MIR passes like the inliner. I don't like having all these tests depend on `-Zpolymorphize` (or other hacky ways) for no reason, so this PR extends the `-Zvalidate-mir` flag to ensure `optimized_mir`/`mir_for_ctfe` for all body owners during the analysis phase.

Two thoughts:
1. This could be moved later in the compilation pipeline I guess? I don't really think it matters, though.
1. This could alternatively be expressed using a new flag, though I don't necessarily see much value in separating these.

For example, #128171 could have used this flag, in the `tests/ui/polymorphization/inline-incorrect-early-bound.rs`.

r? mir
2024-08-08 18:57:00 +02:00
schvv31n
1bf30eb5aa rustdoc-json: added a test for #107278 2024-08-08 17:55:52 +01:00
schvv31n
c2a0d9ca6e rustdoc: fixed #101105
modules are now stripped based on the same logic that's used to strip other item kinds
2024-08-08 17:13:15 +01:00
Michael Goulet
f81549c9ca Normalize struct tail properly in disalignment check 2024-08-08 11:58:11 -04:00
Michael Goulet
d9dd5509dc Normalize when computing offset_of for slice tail 2024-08-08 11:58:11 -04:00
Alex Macleod
9289f5691b Only suggest #[allow] for --warn and --deny lint level flags 2024-08-08 13:09:58 +00:00
Chris Denton
8725f7ee4c
run-make: enable msvc for staticlib-dylib-linkage 2024-08-08 12:17:15 +00:00
James Barford-Evans
27ca35aa1b const vector passed to codegen 2024-08-08 11:15:03 +01:00
DianQK
b5c453d7a2
Add a set of tests for LLVM 19 2024-08-08 18:08:44 +08:00
Folkert
3e5885f7d2
changes after review 2024-08-08 10:21:47 +02:00
Folkert
ae68b2fc56
migrate thumb-none-qemu to rmake 2024-08-08 10:21:38 +02:00
Trevor Gross
36b9aee947
Rollup merge of #128800 - clarfonthey:core-pattern-type, r=compiler-errors
Add tracking issue to core-pattern-type

While the actual `pattern_types` feature flag has an issue assigned, the exported macro and its module do not.

cc #123646
2024-08-07 20:49:05 -05:00
Trevor Gross
ca5e8a7c4d
Rollup merge of #128702 - yaahc:metrics-flag, r=estebank
Add -Zmetrics-dir=PATH to save diagnostic metadata to disk

r? ``@estebank``
2024-08-07 20:49:03 -05:00
Trevor Gross
6c2e06746d
Rollup merge of #128552 - s7tya:check-no-sanitize-attribute-pos, r=BoxyUwU
Emit an error for invalid use of the `#[no_sanitize]` attribute

fixes #128487.

Currently, the use of the `#[no_sanitize]` attribute for Mod, Impl,... is incorrectly permitted. This PR will correct this issue by generating errors, and I've also added some UI test cases for it.

Referenced #128458. As far as I know, the `#[no_sanitize]` attribute can only be used with functions, so I changed that part to `Fn` and `Method` using `check_applied_to_fn_or_method`. However, I couldn't find explicit documentation on this, so I could be mistaken...
2024-08-07 20:49:02 -05:00
Trevor Gross
2a177c2047
Rollup merge of #128520 - compiler-errors:more-precisely-force-move, r=BoxyUwU
Skip over args when determining if async-closure's inner coroutine consumes its upvars

#125306 implements a strategy for when we have an `async move ||` async-closure that is inferred to be `async FnOnce`, it will force the inner coroutine to also be `move`, since we cannot borrow any upvars from the parent async-closure (since `FnOnce` is not lending):

8e86c95671/compiler/rustc_hir_typeck/src/upvar.rs (L211-L229)

However, when this strategy was implemented, it reused the `ExprUseVisitor` data from visiting the whole coroutine, which includes additional statements due to `async`-specific argument desugaring:

8e86c95671/compiler/rustc_ast_lowering/src/item.rs (L1197-L1228)

Well, it turns out that we don't care about these argument desugaring parameters, because arguments to the async-closure are not the *async-closure*'s captures -- they exist for only one invocation of the closure, and they're always consumed by construction (see the argument desugaring above), so they will force the coroutine's inferred kind to `FnOnce`. (Unless they're `Copy`, because we never consider `Copy` types to be consumed):

8e86c95671/compiler/rustc_hir_typeck/src/expr_use_visitor.rs (L60-L66)

However, since we *were* visiting these arg exprs, this resulted in us too-aggressively applying `move` to the inner coroutine, resulting in regressions. For example, this PR fixes #128516. Fascinatingly, the note above about how we never consume `Copy` types is why this only regressed when the argument types weren't all `Copy`.

I tried to leave some comments inline to make this more clear :)
2024-08-07 20:49:02 -05:00
Chris Denton
599bcb5cf1
run-make: enable msvc for redundant-libs 2024-08-08 01:42:29 +00:00
ltdk
0257f42089 Add tracking issue to core-pattern-type 2024-08-07 20:43:05 -04:00
bors
86e7875c13 Auto merge of #128793 - matthiaskrgr:rollup-ork16t0, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #128363 (Migrate `pdb-buildinfo-cl-cmd` and `pgo-indirect-call-promotion` `run-make` tests to rmake)
 - #128384 (Add tests to ensure MTE tags are preserved across FFI boundaries)
 - #128636 (migrate `thumb-none-cortex-m` to rmake)
 - #128696 (Migrate `staticlib-dylib-linkage` `run-make` test to rmake)

Failed merges:

 - #128407 (Migrate `min-global-align` and `no-alloc-shim` `run-make` tests to rmake)
 - #128639 (migrate `thumb-none-qemu` to rmake)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-07 22:30:29 +00:00
bors
8b3870784f Auto merge of #128796 - matthiaskrgr:rollup-r7l68ph, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128221 (Add implied target features to target_feature attribute)
 - #128261 (impl `Default` for collection iterators that don't already have it)
 - #128353 (Change generate-copyright to generate HTML, with cargo dependencies included)
 - #128679 (codegen: better centralize function declaration attribute computation)
 - #128732 (make `import.vis` is immutable)
 - #128755 (Integrate crlf directly into related test file instead via of .gitattributes)
 - #128772 (rustc_codegen_ssa: Set architecture for object crate for 32-bit SPARC)
 - #128782 (unused_parens: do not lint against parens around &raw)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-07 20:00:29 +00:00
Matthias Krüger
aba506b12a
Rollup merge of #128782 - RalfJung:raw-addr-of-parens, r=compiler-errors
unused_parens: do not lint against parens around &raw

Requested by `@tmandry` in https://github.com/rust-lang/rust/pull/127679: with `&raw` one somewhat regularly has to write code like `(&raw const (*myptr).field).method()`, so parentheses around the expression are often required. To avoid churn between adding and removing parentheses as method calls appear and disappear, the proposal was made to silence the lint for unnecessary parentheses around `&raw` expressions. This PR implements that.
2024-08-07 20:28:20 +02:00
Matthias Krüger
e5a3c32ffa
Rollup merge of #128755 - yaahc:jj-crlf, r=estebank
Integrate crlf directly into related test file instead via of .gitattributes

resolves https://github.com/rust-lang/rust/issues/128708

This PR seeks to resolve a contributor papercut when using jj to manage the git repo locally which does not support .gitattributes. It does so by integrating the crlf characters directly into the related test and disabling Git's end of line normalization logic across platforms for that specific file, instead of configuring git to always check out the files with alternative eol characters.

related documentation: https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Unset-1
2024-08-07 20:28:19 +02:00
Matthias Krüger
904f5795a0
Rollup merge of #128221 - calebzulawski:implied-target-features, r=Amanieu
Add implied target features to target_feature attribute

See [zulip](https://rust-lang.zulipchat.com/#narrow/stream/208962-t-libs.2Fstdarch/topic/Why.20would.20target-feature.20include.20implied.20features.3F) for some context.  Adds implied target features, e.g. `#[target_feature(enable = "avx2")]` acts like `#[target_feature(enable = "avx2,avx,sse4.2,sse4.1...")]`.  Fixes #128125, fixes #128426

The implied feature sets are taken from [the rust reference](https://doc.rust-lang.org/reference/attributes/codegen.html?highlight=target-fea#x86-or-x86_64), there are certainly more features and targets to add.

Please feel free to reassign this to whoever should review it.

r? ``@Amanieu``
2024-08-07 20:28:16 +02:00
Jane Losare-Lusby
5212c75907 Add -Zerror-metrics=PATH to save diagnostic metadata to disk 2024-08-07 11:16:55 -07:00
Matthias Krüger
26787a8c0d
Rollup merge of #128696 - Oneirical:second-linkage-rampage, r=jieyouxu
Migrate `staticlib-dylib-linkage` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

I'm quite sure this has the same issue as the one brought up in [this discussion](https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172), so I elected to keep the ignore MSVC.

try-job: aarch64-apple
try-job: x86_64-gnu-llvm-17
try-job: armhf-gnu
2024-08-07 19:35:07 +02:00
Matthias Krüger
38dc3b2621
Rollup merge of #128636 - folkertdev:rmake-thumb-none-cortex-m, r=jieyouxu
migrate `thumb-none-cortex-m` to rmake

tracking issue: https://github.com/rust-lang/rust/issues/121876

I'll leave some comments/questions inline

r? ```@jieyouxu```

try-job: armhf-gnu
try-job: dist-various-1
try-job: test-various
2024-08-07 19:35:06 +02:00
Matthias Krüger
b817900087
Rollup merge of #128384 - dheaton-arm:mte-test, r=jieyouxu
Add tests to ensure MTE tags are preserved across FFI boundaries

Added run-make tests to verify that, between a Rust-C FFI boundary in both directions, any MTE tags included in a pointer are preserved for the following pointer types, as well as any information stored using TBI:
- int
- float
- string
- function

try-job: aarch64-gnu
2024-08-07 19:35:05 +02:00
bors
ce20e15f01 Auto merge of #126158 - Urgau:disallow-cfgs, r=petrochenkov
Disallow setting some built-in cfg via set the command-line

This PR disallow users from setting some built-in cfg via set the command-line in order to prevent incoherent state, eg. `windows` cfg active but target is Linux based.

This implements MCP https://github.com/rust-lang/compiler-team/issues/610, with the caveat that we disallow cfgs no matter if they make sense or not, since I don't think it's useful to allow users to set a cfg that will be set anyway. It also complicates the implementation.

------

The `explicit_builtin_cfgs_in_flags` lint detects builtin cfgs set via the `--cfg` flag.

*(deny-by-default)*

### Example

```text
rustc --cfg unix
```

```rust,ignore (needs command line option)
fn main() {}
```

This will produce:

```text
error: unexpected `--cfg unix` flag
  |
  = note: config `unix` is only supposed to be controlled by `--target`
  = note: manually setting a built-in cfg can and does create incoherent behaviours
  = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
```

### Explanation

Setting builtin cfgs can and does produce incoherent behaviour, it's better to the use the appropriate `rustc` flag that controls the config. For example setting the `windows` cfg but on Linux based target.

-----

r? `@petrochenkov`
cc `@jyn514`

try-job: aarch64-apple
try-job: test-various
try-job: armhf-gnu
try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-gnu-llvm-17
try-job: dist-various-1
2024-08-07 17:32:16 +00:00
Oneirical
7d1a97fae9 rewrite pgo-indirect-call-promotion to rmake 2024-08-07 12:57:34 -04:00
Oneirical
7e5a2ea583 rewrite pdb-buildinfo-cl-cmd to rmake 2024-08-07 12:57:26 -04:00
tiif
8eaef3eca0 Add test 2024-08-08 00:41:39 +08:00
Guillaume Gomez
c0efd51396
Rollup merge of #128757 - Oneirical:calm-before-the-sltorm, r=jieyouxu
Migrate `pgo-gen-lto` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

This one is so easy, I'm surprised I missed it.

try-job: aarch64-apple
try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-gnu-llvm-17
2024-08-07 15:59:39 +02:00
Guillaume Gomez
888d157417
Rollup merge of #128753 - compiler-errors:arbitrary-upper, r=spastorino
Don't arbitrarily choose one upper bound for hidden captured region error message

You could argue that the error message is objectively worse, even though it's more accurate. I guess we could also add a note explaining like "cannot capture the intersection of two regions" or something, though I'm not sure if that is confusing due to being totally technical jargon.

This addresses the fact that #128752 says "add `+ 'b`" even though it does nothing to fix the issue. It doesn't fix the issue's root cause, though.

r? `@spastorino`
2024-08-07 15:59:38 +02:00
Guillaume Gomez
f739c00f4a
Rollup merge of #128700 - Oneirical:i-ffind-these-tests-quite-simdple, r=jieyouxu
Migrate `simd-ffi` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: armhf-gnu
try-job: test-various
try-job: aarch64-apple
try-job: x86_64-gnu-llvm-17
2024-08-07 15:59:38 +02:00
Guillaume Gomez
a05f187b15
Rollup merge of #128656 - ChrisDenton:rust-lld, r=lqd
Enable msvc for run-make/rust-lld

This is simply a matter of using the right argument for lld-link.

As a bonus, I also fixed a typo.

try-job: i686-msvc
try-job: x86_64-msvc
2024-08-07 15:59:37 +02:00
Guillaume Gomez
493233ce29
Rollup merge of #128527 - estebank:ambiguity-suggestion, r=Nadrieril
More information for fully-qualified suggestion when there are multiple impls

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/E0283.rs:30:21
   |
LL |     fn create() -> u32;
   |     ------------------- `Coroutine::create` defined here
...
LL |     let cont: u32 = Coroutine::create();
   |                     ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     let cont: u32 = <Impl as Coroutine>::create();
   |                     ++++++++          +
LL |     let cont: u32 = <AnotherImpl as Coroutine>::create();
   |                     +++++++++++++++          +
```
2024-08-07 15:59:36 +02:00
Ralf Jung
c1897960c0 unused_parens: do not lint against parens around &raw 2024-08-07 15:29:00 +02:00
Urgau
c0c57b3e29 Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
bors
9bad7ba324 Auto merge of #128196 - Oneirical:poltergeist-manitestation, r=jieyouxu
Migrate `cross-lang-lto-upstream-rlibs`, `long-linker-command-lines` and `long-linker-command-lines-cmd-exe` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

The `long-linker` tests are certainly doing something... interesting - they summon `rustc` calls with obscene quantities of arguments and check that this is appropriately handled. I removed the `RUSTC_ORIGINAL` magic - it's equivalent to `RUSTC` in `tools.mk`, so what is the purpose? Making it so the massive pile of flags doesn't modify rustc itself and start leaking into other tests? Tell me what you think.

Please try:

try-job: x86_64-msvc
try-job: i686-msvc
try-job: x86_64-mingw
try-job: i686-mingw
try-job: aarch64-apple
try-job: test-various
try-job: x86_64-gnu-debug
try-job: x86_64-gnu-llvm-17
2024-08-07 10:58:10 +00:00
carbotaniuman
de9b5c3ea2 Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
Caleb Zulawski
83276f5680 Hide implicit target features from diagnostics when possible 2024-08-07 00:43:52 -04:00
Caleb Zulawski
6b96a60611 Add implied features to non-target-feature functions 2024-08-07 00:41:48 -04:00
Caleb Zulawski
a25da077cf Don't use LLVM to compute -Ctarget-feature 2024-08-07 00:41:48 -04:00
Caleb Zulawski
520a5a535f Fix codegen tests 2024-08-07 00:41:48 -04:00
Caleb Zulawski
22c5952944 Add test to ensure implied target features work with asm, and fix failing tests 2024-08-07 00:41:48 -04:00
Caleb Zulawski
74653b61a6 Add implied target features to target_feature attribute 2024-08-07 00:41:48 -04:00
Trevor Gross
6ccb3569f8
Rollup merge of #128649 - ChrisDenton:param-passing, r=jieyouxu
run-make: Enable msvc for `no-duplicate-libs` and `zero-extend-abi-param-passing`

The common thing between these two tests is to use `#[link(..., kind="static")]` so that it doesn't try to do a DLL import.

`zero-extend-abi-param-passing` also needs to have an optimized static library but there's only helper function for a non-optimized version. Rather than copy/pasting the code (and adding the optimization flag) I reused the same code so that it more easily be kept in sync.

try-job: i686-msvc
try-job: x86_64-msvc
2024-08-06 22:17:34 -05:00
Trevor Gross
0761d2af61
Rollup merge of #128647 - ChrisDenton:link-args-order, r=jieyouxu
Enable msvc for link-args-order

I could not see any reason in #70665 why this test needs to specifically use `ld`. Maybe to provide a consistent linker input line? In any case, the test does work for the MSVC linker.

try-job: i686-msvc
try-job: x86_64-msvc
2024-08-06 22:17:33 -05:00
Trevor Gross
cc42e34391
Rollup merge of #128638 - ChrisDenton:link-dedup, r=jieyouxu
run-make: enable msvc for `link-dedup`

This is just a case of differing style of linker arguments.

I also cleaned up a bit where we were running the same command three times in a row. Instead I reused the output.

One thing that confused me is why we were testing for the same lib three times in a row but not two. After figuring that out I added a note to hopefully save future readers some confusion.

try-job: x86_64-msvc
try-job: i686-msvc
2024-08-06 22:17:33 -05:00
Trevor Gross
10a7f93f12
Rollup merge of #128362 - folkertdev:naked-function-symbol-visibility, r=bjorn3
add test for symbol visibility of `#[naked]` functions

tracking issue: #90957

This test is extracted from https://github.com/rust-lang/rust/pull/128004

That PR attempts to generated naked functions as an extern function declaration, combined with a global asm block that provides the implementation for that declaration.

In order to link declaration and definition together, some flavor of external linking must be used: LLVM will error for other linkage types. Specifically the allowed options are `#[linkage = "external"]` and `#[linkage = "extern_weak"]`. That is kind of an implementation detail though: to the user, a naked function should just behave like a normal function.

Hence it should be visible to the linker under the same circumstances as a normal, vanilla function and have the same attributes (Weak, External). Getting this behavior right will require some care, so I think it's a good idea to lock it in now, before making any changes, to make sure we don't regress.

Are there any interesting cases that I missed here? E.g. is checking on different architectures worth it? I don't think the other binary types (rlib etc) are relevant here, but may be missing something.

r? ``@bjorn3``
2024-08-06 22:17:32 -05:00
Trevor Gross
0aaffdb25f
Rollup merge of #128107 - Oneirical:tomato-hartester, r=jieyouxu
Migrate `raw-dylib-alt-calling-convention`, `raw-dylib-c` and `redundant-libs` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

// try-job: x86_64-msvc
// try-job: x86_64-mingw
// try-job: i686-msvc
try-job: x86_64-gnu-llvm-17
try-job: aarch64-apple
2024-08-06 22:17:31 -05:00
Michael Howell
20c833c632 diagnostics: Box<dyn Trait> suggestion with multiple matching impl
The two altered expectation messages both seem like improvements:

- `coerce-expect-unsized-ascribed.stderr` says you can go
  `Box<char> -> Box<dyn Debug>`, which you can.
- `upcast_soundness_bug.stderr` used to say that you could go
  `Box<dyn Trait<u8, u8>> -> Box<dyn Trait>`, which you can't,
  because the type parameters are missing in the destination
  and the only ones that work aren't what's needed.
2024-08-06 18:24:17 -07:00
bors
6696447f78 Auto merge of #128761 - matthiaskrgr:rollup-5p1mlqq, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #124944 (On trait bound mismatch, detect multiple crate versions in dep tree)
 - #125048 (PinCoerceUnsized trait into core)
 - #128406 (implement BufReader::peek)
 - #128539 (Forbid unused unsafe in vxworks-specific std modules)
 - #128687 (interpret: refactor function call handling to be better-abstracted)
 - #128692 (Add a triagebot mention for `library/Cargo.lock`)
 - #128710 (Don't ICE when getting an input file name's stem fails)
 - #128718 (Consider `cfg_attr` checked by `CheckAttrVisitor`)
 - #128751 (std:🧵 set_name implementation proposal for vxWorks.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-07 00:46:06 +00:00
Matthias Krüger
3158a86b67
Rollup merge of #128718 - jieyouxu:check-cfg_attr, r=nnethercote
Consider `cfg_attr` checked by `CheckAttrVisitor`

I forgor about `cfg_attr` in #128581, it should be treated like `cfg`.

Fixes #128716.
2024-08-07 00:34:14 +02:00
Matthias Krüger
f9325b72d9
Rollup merge of #128710 - ChrisDenton:null, r=jieyouxu
Don't ICE when getting an input file name's stem fails

Fixes #128681

The file stem is only used as a user-friendly prefix on intermediary files. While nice to have, it's not the end of the world if it fails so there's no real reason to emit an error here. We can continue with a fixed name as we do when an anonymous string is used.
2024-08-07 00:34:14 +02:00
Michael Howell
1b587a6e76 alloc: add ToString specialization for &&str
Fixes #128690
2024-08-06 14:37:33 -07:00
Oneirical
0149ba33bb rewrite pgo-gen-lto to rmake 2024-08-06 16:35:08 -04:00
Jane Losare-Lusby
b174cf827b Integrate crlf directly into related test file instead via of .gitattributes 2024-08-06 13:19:48 -07:00
Folkert
201ca3f65c
changes after review 2024-08-06 22:08:28 +02:00
Michael Goulet
c656ce7aeb Don't arbitrarily choose one upper bound for hidden captured region 2024-08-06 15:43:41 -04:00
Esteban Küber
034b73ba54 fix test 2024-08-06 19:09:52 +00:00
Matthias Krüger
47a2f14e49
Rollup merge of #128736 - GuillaumeGomez:fix-remap-path-prefix, r=notriddle
Fix rustdoc missing handling of remap-path-prefix option

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

cc `@weihanglo`
r? `@notriddle`
2024-08-06 20:23:42 +02:00
Matthias Krüger
4b29f42ffc
Rollup merge of #128693 - notriddle:notriddle/impl-disambiguator-2024, r=GuillaumeGomez
rustdoc-search: account for numeric disambiguators on impls

Fixes #128676
2024-08-06 20:23:40 +02:00
Matthias Krüger
333c63b9fc
Rollup merge of #128377 - veera-sivarajan:fix-128249, r=davidtwco
Fix ICE Caused by Incorrectly Delaying E0107

Fixes  #128249

For the following code:
```rust
trait Foo<T> {}
impl Foo<T: Default> for u8 {}
```
#126054 added some logic to delay emitting E0107 as the names of associated type `T` in the impl header and generic parameter `T` in `trait Foo` match.

But it failed to ensure whether such unexpected associated type bounds are coming from a impl block header. This caused an ICE as the compiler was delaying E0107 for code like:
```rust
trait Trait<Type> {
    type Type;

    fn method(&self) -> impl Trait<Type: '_>;
}
```
because it assumed the associated type bound `Type: '_` is for the generic parameter `Type` in `trait Trait` since the names are same.

This PR adds a check to ensure that E0107 is delayed only in the context of impl block header.
2024-08-06 20:23:39 +02:00
Esteban Küber
5e26c8d3c9 Move test to be make instead of ui 2024-08-06 17:58:12 +00:00
Esteban Küber
f4bad4fa39 Change test to be only-linux and ignore-wasm32 2024-08-06 17:54:39 +00:00
Esteban Küber
d8b07718f4 Add help about using cargo tree 2024-08-06 17:54:39 +00:00
Esteban Küber
ba32673215 Add test for mixing types from two incompatible crate versions 2024-08-06 17:54:39 +00:00
Oneirical
fe4cd9aa8d rewrite long-linker-command-lines-cmd-exe to rmake 2024-08-06 11:03:18 -04:00
Oneirical
fe6feb8c6e rewrite long-linker-command-lines to rmake 2024-08-06 11:03:17 -04:00
Oneirical
342b807e1a rewrite cross-lang-lto-upstream-rlibs to rmake 2024-08-06 11:03:17 -04:00
Oneirical
608b322f49 rewrite staticlib-dylib-linkage to rmake 2024-08-06 10:59:14 -04:00
Guillaume Gomez
f43e92b4df Add regression test for #69264 2024-08-06 16:56:48 +02:00
Michael Howell
3a183256ad rustdoc-search: account for numeric disambiguators on impls
Fixes #128676
2024-08-06 07:36:12 -07:00
bors
60d146580c Auto merge of #128245 - Oneirical:total-linkage-ownage, r=jieyouxu
Migrate `cdylib-dylib-linkage` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

~~Those sysroot tests are always fun. I'm getting local errors that don't make a lot of sense about my own sysroot not existing, so I am trying this in CI to see what happens.~~

~~EDIT: I am getting the same error here. The strange thing is, when I try to navigate to `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib` on my personal computer, the directory does exist, but the error message is that the directory does not.~~

EDIT 2: The sysroot path just needed to be trimmed!

Please try:

// try-job: x86_64-msvc // passed previously
try-job: x86_64-mingw
try-job: x86_64-gnu-llvm-18
try-job: i686-msvc
try-job: aarch64-apple
2024-08-06 11:15:31 +00:00
bors
93ea767e29 Auto merge of #126804 - estebank:short-error-primary-label, r=davidtwco
On short error format, append primary span label to message

The `error-format=short` output only displays the path, error code and main error message all in the same line. We now add the primary span label as well after the error message, to provide more context.
2024-08-06 07:06:24 +00:00
许杰友 Jieyou Xu (Joe)
fdb64b9478 tests: add regression test to make sure cfg_attr isn't considered unhandled 2024-08-06 06:12:10 +00:00
Esteban Küber
1bbaf6eb2f On short error format, append primary span label to message
The `error-format=short` output only displays the path, error code and
main error message all in the same line. We now add the primary span label
as well after the error message, to provide more context.
2024-08-06 04:08:10 +00:00
bors
c9687a95a6 Auto merge of #125558 - Amanieu:const-asm-type, r=lcnr
Tweak type inference for `const` operands in inline asm

Previously these would be treated like integer literals and default to `i32` if a type could not be determined. To allow for forward-compatibility with `str` constants in the future, this PR changes type inference to use an unbound type variable instead.

The actual type checking is deferred until after typeck where we still ensure that the final type for the `const` operand is an integer type.

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-08-06 01:20:43 +00:00
Noah Lev
2f4603b715 Test more cases of WF-checking for fields 2024-08-05 17:56:50 -07:00
Noah Lev
9479792cb4 WF-check struct field types at construction site
Rustc of course already WF-checked the field types at the definition
site, but for error tainting of consts to work properly, there needs to
be an error emitted at the use site. Previously, with no use-site error,
we proceeded with CTFE and ran into ICEs since we are running code with
type errors.

Emitting use-site errors also brings struct-like constructors more in
line with fn-like constructors since they already emit use-site errors
for WF issues.
2024-08-05 17:37:12 -07:00
Noah Lev
18906754cc Add test for WF check of implied unsizing in struct fields
Note that the test output is currently *incorrect*. We should be
emitting an error at the use site too, not just at the definition. This
is partly for UI reasons, but mainly to fix a related ICE where a const
generic body is not tainted with an error since no usage error is
reported.
2024-08-05 17:37:11 -07:00
Chris Denton
3fd645e254
Check staticlib name falls back to rust_out 2024-08-05 23:50:15 +00:00
Chris Denton
c8d50ef2ee
Windows: Test if \\.\NUL works as an input file 2024-08-05 22:13:17 +00:00
Matthias Krüger
c53698b399
Rollup merge of #128697 - RalfJung:nullary-op, r=compiler-errors
interpret: move nullary-op evaluation into operator.rs

We call it an operator, so we might as well treat it like one. :)

Also use more consistent naming for the "evaluate intrinsic" functions. "emulate" is really the wrong term, this *is* a genuine implementation of the intrinsic semantics after all.
2024-08-05 23:35:24 +02:00
Matthias Krüger
77f57cbcac
Rollup merge of #128694 - compiler-errors:norm, r=WaffleLapkin
Normalize when equating `dyn` tails in MIR borrowck

See the explanation in the comment.

Fixes #128621
cc `@WaffleLapkin`
2024-08-05 23:35:23 +02:00
Matthias Krüger
83155b3900
Rollup merge of #128688 - RalfJung:custom-mir-tail-calls, r=compiler-errors
custom MIR: add support for tail calls

Cc ``@WaffleLapkin``
2024-08-05 23:35:23 +02:00
Matthias Krüger
9cb3688f1f
Rollup merge of #128580 - compiler-errors:cfi-param-env, r=lcnr
Use `ParamEnv::reveal_all` in CFI

I left a huge comment for why this ICEs in the test I committed.

`typeid_for_instance` should only be called on monomorphic instances during codegen, and we should just be using `ParamEnv::reveal_all()` rather than the param-env of the instance itself. I added an assertion to ensure that we only do this for fully substituted instances (this may break with polymorphization, but I kinda don't care lol).

Fixes #114160
cc `@rcvalle`
2024-08-05 23:35:22 +02:00
Ralf Jung
46896d6f66 interpret: move nullary-op evaluation into operator.rs 2024-08-05 22:42:34 +02:00
Oneirical
1054054a46 rewrite simd-ffi to rmake 2024-08-05 15:07:33 -04:00
Michael Goulet
c6f8672dd5 Normalize when equating dyn tails in MIR borrowck 2024-08-05 14:28:06 -04:00
Folkert
19679510c7
add test for symbol visibility of #[naked] functions 2024-08-05 19:55:35 +02:00
bors
f7eefec4e0 Auto merge of #128689 - matthiaskrgr:rollup-ukyn8wq, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #128385 (rustdoc-json: discard non-local inherent impls for primitives)
 - #128559 (Don't re-elaborated already elaborated caller bounds in method probe)
 - #128631 (handle crates when they are not specified for std docs)
 - #128664 (Add `Debug` impls to API types in `rustc_codegen_ssa`)
 - #128686 (fix the invalid argument type)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-05 17:03:58 +00:00
Matthias Krüger
376a6f9f43
Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoid
rustdoc-json: discard non-local inherent impls for primitives

Fixes #114039
at least it should
r? `@aDotInTheVoid`
2024-08-05 18:36:01 +02:00
Ralf Jung
212417b87f custom MIR: add support for tail calls 2024-08-05 18:23:14 +02:00
bors
2b78d92096 Auto merge of #124336 - compiler-errors:super-outlives, r=lcnr
Enforce supertrait outlives obligations hold when confirming impl

**TL;DR:** We elaborate super-predicates and apply any outlives obligations when proving an impl holds to fix a mismatch between implied bounds.

Bugs in implied bounds (and implied well-formedness) occur whenever there is a mismatch between the assumptions that some code can assume to hold, and the obligations that a caller/user of that code must prove. If the former is stronger than the latter, then unsoundness occurs.

Take a look at the example unsoundness:

```rust
use std::fmt::Display;

trait Static: 'static {}
impl<T> Static for &'static T {}
fn foo<S: Display>(x: S) -> Box<dyn Display>
where
    &'static S: Static,
{
    Box::new(x)
}

fn main() {
    let s = foo(&String::from("blah blah blah"));
    println!("{}", s);
}
```

This specific example occurs because we elaborate obligations in `fn foo`:

* `&'static S: Static`
    * `&'static S: 'static` <- super predicate
        * `S: 'static` <- elaborating outlives bounds

However, when calling `foo`, we only need to prove the direct set of where clauses. So at the call site for some substitution `S = &'not_static str`, that means only proving `&'static &'not_static str: Static`. To prove this, we apply the impl, which itself holds trivially since it has no where clauses.

This is the mismatch -- `foo` is allowed to assume that `S: 'static` via elaborating supertraits, but callers of `foo` never need to prove that `S: 'static`.

There are several approaches to fixing this, all of which have problems due to current limitations in our type system:
1. proving the elaborated set of predicates always - This leads to issues since we don't have coinductive trait semantics, so we easily hit new cycles.
    * This would fix our issue, since callers of `foo` would have to both prove `&'static &'not_static str: Static` and its elaborated bounds, which would surface the problematic `'not_static: 'static` outlives obligation.
    * However, proving supertraits when proving impls leads to inductive cycles which can't be fixed until we get coinductive trait semantics.
2. Proving that an impl header is WF when applying that impl:
    * This would fix our issue, since when we try to prove `&'static &'not_static str: Static`, we'd need to prove `WF(&'static &'not_static str)`, which would surface the problematic `'not_static: 'static` outlives obligation.
    * However, this leads to issues since we don't have higher-ranked implied bounds. This breaks things when trying to apply impls to higher-ranked trait goals.

To get around these limitations, we apply a subset of (1.), which is to elaborate the supertrait obligations of the impl but filter only the (region/type) outlives out of that set, since those can never participate in an inductive cycle. This is likely not sufficient to fix a pathological example of this issue, but it does clearly fill in a major gap that we're currently overlooking.

This can also result in 'unintended' errors due to missing implied-bounds on binders. We did not encounter this in the crater run and don't expect people to rely on this code in practice:
```rust
trait Outlives<'b>: 'b {}
impl<'b, T> Outlives<'b> for &'b T {}
fn foo<'b>()
where
    // This bound will break due to this PR as we end up proving
    // `&'b &'!a (): 'b` without the implied `'!a: 'b`
    // bound.
    for<'a> &'b &'a (): Outlives<'b>,
{}
```

Fixes #98117

---

Crater: https://github.com/rust-lang/rust/pull/124336#issuecomment-2209165320
Triaged: https://github.com/rust-lang/rust/pull/124336#issuecomment-2236321325

All of the fallout is due to generic const exprs, and can be ignored.
2024-08-05 14:39:32 +00:00
Oneirical
20332dae2f rewrite cdylib-dylib-linkage to rmake 2024-08-05 10:39:17 -04:00
Oneirical
011727f14e rewrite redundant-libs to rmake 2024-08-05 10:11:53 -04:00
Oneirical
f31f8c488a rewrite raw-dylib-c to rmake 2024-08-05 10:11:45 -04:00
Oneirical
131d453248 rewrite raw-dylib-alt-calling-conventions to rmake 2024-08-05 10:11:35 -04:00
Michael Goulet
6a891ec4fe Enforce supertrait outlives obligations hold when confirming impl 2024-08-05 09:55:14 -04:00
bors
83e9b93c90 Auto merge of #127095 - Oneirical:testiary-education, r=jieyouxu
Migrate `reproducible-build-2` and `stable-symbol-names` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Needs try-jobs.

try-job: x86_64-msvc
try-job: armhf-gnu
try-job: test-various
try-job: aarch64-apple
try-job: i686-msvc
try-job: x86_64-mingw
2024-08-05 12:16:05 +00:00
schvv31n
7499e21a1e rustdoc-json: discard non-local inherent impls 2024-08-05 11:19:22 +01:00
Shina
61ea488309 Emit an error for invalid use of the #[no_sanitize] attribute 2024-08-05 19:07:32 +09:00
bors
9179d9b334 Auto merge of #117468 - daxpedda:wasm-relaxed-simd, r=alexcrichton
Stabilize Wasm relaxed SIMD

This PR stabilizes [Wasm relaxed SIMD](https://github.com/WebAssembly/relaxed-simd) which has already reached [phase 4](04fa8c810e (phase-4---standardize-the-feature-wg)).

Tracking issue: #111196
Implementation PR: https://github.com/rust-lang/stdarch/pull/1393
Documentation: https://github.com/rust-lang/reference/pull/1421
Stdarch: https://github.com/rust-lang/stdarch/pull/1494

Closes #111196.
2024-08-05 09:25:50 +00:00
Guillaume Gomez
59cb15946d Prevent clicking on a link or on a button to toggle the code example buttons visibility 2024-08-05 11:05:40 +02:00
Guillaume Gomez
e2da2fb387 Update rustdoc tests 2024-08-05 11:04:51 +02:00
Guillaume Gomez
be71bd9cec Update GUI tests for code example buttons 2024-08-05 11:04:51 +02:00
Ralf Jung
28e0907111 nontemporal_store: make sure that the intrinsic is truly just a hint 2024-08-05 10:57:14 +02:00
bors
4d48a6be74 Auto merge of #128673 - matthiaskrgr:rollup-gtvpkm7, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128026 (std:🧵 available_parallelism implementation for vxWorks proposal.)
 - #128471 (rustdoc: Fix handling of `Self` type in search index and refactor its representation)
 - #128607 (Use `object` in `run-make/symbols-visibility`)
 - #128609 (Remove unnecessary constants from flt2dec dragon)
 - #128611 (run-make: Remove cygpath)
 - #128619 (Correct the const stabilization of `<[T]>::last_chunk`)
 - #128630 (docs(resolve): more explain about `target`)
 - #128660 (tests: more crashes)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-05 06:55:50 +00:00
Matthias Krüger
5fa740f613
Rollup merge of #128660 - matthiaskrgr:niceice, r=compiler-errors
tests: more crashes

r? ``@jieyouxu``
2024-08-05 08:22:25 +02:00
Matthias Krüger
f231973941
Rollup merge of #128607 - ChrisDenton:visibility, r=jieyouxu
Use `object` in `run-make/symbols-visibility`

This is another case where we can simply use a rust library instead of wrangling nm.

try-job: x86_64-msvc
try-job: i686-msvc
try-job: test-various
2024-08-05 08:22:22 +02:00
Matthias Krüger
4adefa4334
Rollup merge of #128471 - camelid:rustdoc-self, r=notriddle
rustdoc: Fix handling of `Self` type in search index and refactor its representation

### Summary

- Add enum variant `clean::Type::SelfTy` and use it instead of `clean::Type::Generic(kw::SelfUpper)`.
- Stop treating `Self` as a generic in the search index.
- Remove struct formerly known as `clean::SelfTy` (constructed as representation of function receiver type). We're better off without it.

### Before

![image](https://github.com/user-attachments/assets/d257bdd8-3a62-4c71-84a5-9c950f2e4f00)

### After

![image](https://github.com/user-attachments/assets/8f6d3f22-92c1-41e3-9ab8-a881b66816c0)

r? ```@notriddle```
cc https://github.com/rust-lang/rust/pull/127589#issuecomment-2259715841
2024-08-05 08:22:21 +02:00
Chris Denton
1737845cb4
Enable msvc for run-make/rust-lld
This is simply a matter of using the right argument for lld-link.
2024-08-05 04:38:47 +00:00
Matthias Krüger
20480075bd
Rollup merge of #128623 - jieyouxu:check-attr-ice, r=nnethercote
Do not fire unhandled attribute assertion on multi-segment `AttributeType::Normal` attributes with builtin attribute as first segment

### The Problem

In #128581 I introduced an assertion to check that all builtin attributes are actually checked via
`CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes.
Unfortunately, the assertion had correctness problems as revealed in #128622.

The match on attribute path segments looked like

```rs,ignore
// Normal handler
[sym::should_panic] => /* check is implemented */
// Fallback handler
[name, ..] => match BUILTIN_ATTRIBUTE_MAP.get(name) {
    // checked below
    Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
    Some(_) => {
        if !name.as_str().starts_with("rustc_") {
            span_bug!(
                attr.span,
                "builtin attribute {name:?} not handled by `CheckAttrVisitor`"
            )
        }
    }
    None => (),
}
```

However, it failed to account for edge cases such as an attribute whose:

1. path segments *starts* with a segment matching the name of a builtin attribute such as `should_panic`, and
2. the first segment's symbol does not start with `rustc_`, and
3. the matched builtin attribute is also of `AttributeType::Normal` attribute type upon registration with the builtin attribute map.

These conditions when all satisfied cause the span bug to be issued for e.g.
`#[should_panic::skip]` because the `[sym::should_panic]` arm is not matched (since it's
`[sym::should_panic, sym::skip]`).

### Proposed Solution

This PR tries to remedy that by adjusting all normal/specific handlers to not match exactly on a single segment, but instead match a prefix segment.

i.e.

```rs,ignore
// Normal handler, notice the `, ..` rest pattern
[sym::should_panic, ..] => /* check is implemented */
// Fallback handler
[name, ..] => match BUILTIN_ATTRIBUTE_MAP.get(name) {
    // checked below
    Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
    Some(_) => {
        if !name.as_str().starts_with("rustc_") {
            span_bug!(
                attr.span,
                "builtin attribute {name:?} not handled by `CheckAttrVisitor`"
            )
        }
    }
    None => (),
}
```

### Review Remarks

This PR contains 2 commits:

1. The first commit adds a regression test. This will ICE without the `CheckAttrVisitor` changes.
2. The second commit adjusts `CheckAttrVisitor` assertion logic. Once this commit is applied, the test should no longer ICE and produce the expected bless stderr.

Fixes #128622.

r? ``@nnethercote`` (since you reviewed #128581)
2024-08-05 05:40:21 +02:00
Matthias Krüger
3c8b25905c
Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum
Add test for updating enum discriminant through pointer

Closes #122600
2024-08-05 05:40:21 +02:00
Matthias Krüger
d10f2b32f0
Rollup merge of #127907 - RalfJung:byte_slice_in_packed_struct_with_derive, r=nnethercote
built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack and lint

Fixes https://github.com/rust-lang/rust/issues/107457 by turning the lint into a hard error. The lint has been shown in future breakage reports since Rust 1.69 (released in April 2023).

Let's see (via crater) if enough time has passed since https://github.com/rust-lang/rust/pull/104429, and https://github.com/unicode-org/icu4x/pull/2834 has propagated far enough to let us make this a hard error.

Cc ``@nnethercote`` ``@Manishearth``
2024-08-05 05:40:19 +02:00
Matthias Krüger
cc61dc8b2d
Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=compiler-errors
turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps`

`````@rust-lang/types````` I assume the plan is still to disallow this? It has been a future-compat lint for a long time, seems ripe to go for hard error.

However, turns out that outright removing it right now would lead to [tons of crater regressions](https://github.com/rust-lang/rust/pull/127655#issuecomment-2228285460), so for now this PR just makes this future-compat lint show up in cargo's reports, so people are warned when they use a dependency that is affected by this.

Fixes https://github.com/rust-lang/rust/issues/27336 by removing the feature gate (so there's no way to silence the lint even on nightly)
CC https://github.com/rust-lang/rust/issues/36887
2024-08-05 05:40:19 +02:00
Noah Lev
dac7f20e13 Add test for Self not being a generic in search index 2024-08-04 12:49:28 -07:00
Matthias Krüger
69de294c31 tests: more crashes 2024-08-04 21:25:49 +02:00
bors
176e545209 Auto merge of #128534 - bjorn3:split_stdlib_workspace, r=Mark-Simulacrum
Move the standard library to a separate workspace

This ensures that the Cargo.lock packaged for it in the rust-src component is up-to-date, allowing rust-analyzer to run cargo metadata on the standard library even when the rust-src component is stored in a read-only location as is necessary for loading crates.io dependencies of the standard library.

This also simplifies tidy's license check for runtime dependencies as it can now look at all entries in library/Cargo.lock without having to filter for just the dependencies of runtime crates. In addition this allows removing an exception in check_runtime_license_exceptions that was necessary due to the compiler enabling a feature on the object crate which pulls in a dependency not allowed for the standard library.

While cargo workspaces normally enable dependencies of multiple targets to be reused, for the standard library we do not want this reusing to prevent conflicts between dependencies of the sysroot and of tools that are built using this sysroot. For this reason we already use an unstable cargo feature to ensure that any dependencies which would otherwise be shared get a different -Cmetadata argument as well as using separate build dirs.

This doesn't change the situation around vendoring. We already have several cargo workspaces that need to be vendored. Adding another one doesn't change much.

There are also no cargo profiles that are shared between the root workspace and the library workspace anyway, so it doesn't add any extra work when changing cargo profiles.
2024-08-04 18:40:03 +00:00
Chris Denton
3268b2e18d
Enable msvc for link-args-order 2024-08-04 15:09:21 +00:00
bors
ebd08d8ed5 Auto merge of #128634 - matthiaskrgr:rollup-l5a2v5k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128305 (improve error message when `global_asm!` uses `asm!` operands)
 - #128526 (time.rs: remove "Basic usage text")
 - #128531 (Miri: add a flag to do recursive validity checking)
 - #128578 (rustdoc: Cleanup `CacheBuilder` code for building search index)
 - #128589 (allow setting `link-shared` and `static-libstdcpp` with CI LLVM)
 - #128615 (rustdoc: make the hover trail for doc anchors a bit bigger)
 - #128620 (Update rinja version to 0.3.0)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-04 11:57:59 +00:00
Chris Denton
d8c2b767c6
run-make: enable msvc for link-dedup 2024-08-04 11:25:48 +00:00
Folkert
f71a627073
migrate thumb-none-cortex-m to rmake 2024-08-04 12:59:30 +02:00
Matthias Krüger
b6b8330b9d
Rollup merge of #128305 - folkertdev:asm-parser-unsupported-operand, r=Amanieu
improve error message when `global_asm!` uses `asm!` operands

follow-up to https://github.com/rust-lang/rust/pull/128207

what was

```
error: expected expression, found keyword `in`
 --> src/lib.rs:1:31
  |
1 | core::arch::global_asm!("{}", in(reg));
  |                               ^^ expected expression
```

becomes

```
error: the `in` operand cannot be used with `global_asm!`
  --> $DIR/parse-error.rs:150:19
   |
LL | global_asm!("{}", in(reg));
   |                   ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
```

the span of the error is just the keyword, which means that we can't create a machine-applicable suggestion here. The alternative would be to attempt to parse the full operand, but then if there are syntax errors in the operand those would  be presented to the user, even though the parser already knows that the output won't be valid. Also that would require more complexity in the parser.

So I think this is a nice improvement at very low cost.
2024-08-04 11:32:33 +02:00
bors
58fb508fe3 Auto merge of #127877 - Rejyr:migrate-print-rmake, r=jieyouxu
Migrate `print-target-list` to `rmake` and  `print-calling-convention` to ui-test

Part of #121876.

r? `@jieyouxu`

try-job: x86_64-gnu-llvm-18
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-apple
try-job: i686-mingw
try-job: x86_64-msvc
2024-08-04 09:31:24 +00:00
daxpedda
80b74d397f
Implement a implicit target feature mechanism 2024-08-04 08:44:23 +02:00
daxpedda
90521399b4
Stabilize Wasm relaxed SIMD 2024-08-04 08:44:13 +02:00
Chris Denton
2e5341aecd
Enable msvc for no-duplicate-libs 2024-08-04 02:57:18 +00:00
Chris Denton
b46237bdd7
Enable msvc for zero-extend-abi-param-passing 2024-08-04 02:57:17 +00:00
Jerry Wang
36cf385e88
Ensure Rustc::print use in rmake tests 2024-08-03 22:36:08 -04:00
Jerry Wang
1ca959e3f0
Migrate print-target-list to rmake 2024-08-03 22:36:08 -04:00
bors
b389b0ab72 Auto merge of #128466 - sayantn:stdarch-update, r=tgross35
Update the stdarch submodule

cc `@tgross35` `@Amanieu`
r? `@tgross35`

try-job: dist-various-2
2024-08-04 02:11:27 +00:00
许杰友 Jieyou Xu (Joe)
9e5c9c14c7 tests: add regression test for incorrect "builtin attribute is checked" assertion ICE
See <https://github.com/rust-lang/rust/issues/128622>.
2024-08-04 01:50:55 +00:00
Jerry Wang
3a41a11a8f
Migrate run-make/print-calling-conventions to ui-test 2024-08-03 20:09:42 -04:00
Chris Denton
b94a9c1b12
Remove skipping symbols with the __imp_ prefix 2024-08-03 22:08:39 +00:00
sayantn
2cde11f2d1 Chore: add x86_amx_intrinsics feature flag to core/lib.rs and remove issue-120720-reduce-nan.rs 2024-08-04 03:08:18 +05:30
bors
64ebd39da5 Auto merge of #128614 - matthiaskrgr:rollup-d2fextz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #127921 (Stabilize unsafe extern blocks (RFC 3484))
 - #128283 (bootstrap: fix bug preventing the use of custom targets)
 - #128530 (Implement `UncheckedIterator` directly for `RepeatN`)
 - #128551 (chore: refactor backtrace style in panic)
 - #128573 (Simplify `body` usage in rustdoc)
 - #128581 (Assert that all attributes are actually checked via `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes)
 - #128603 (Update run-make/used to use `any_symbol_contains`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-03 21:19:42 +00:00
Michael Goulet
470ada2de0 Make validate_mir pull optimized/ctfe MIR for all bodies 2024-08-03 15:18:09 -04:00
Matthias Krüger
0655ed234f
Rollup merge of #128603 - ChrisDenton:used, r=jieyouxu
Update run-make/used to use `any_symbol_contains`

This makes it so we don't need `nm` or `llvm-nm`.

I also tested that `BAR` is removed. I'm not sure if this is wanted though.
2024-08-03 20:51:54 +02:00
Matthias Krüger
3a9d432589
Rollup merge of #128581 - jieyouxu:checked-attr, r=nnethercote
Assert that all attributes are actually checked via `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes

``@oli-obk's`` #128444 with unreachable case removed to avoid that PR bitrotting away.
Based on #128402.

This PR will make adding a new attribute ICE on any use of that attribute unless it gets a handler added in `rustc_passes::CheckAttrVisitor`.

r? ``@nnethercote`` (since you were the reviewer of the original PR)
2024-08-03 20:51:54 +02:00
Matthias Krüger
53a56190af
Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet
Implement `UncheckedIterator` directly for `RepeatN`

This just pulls the code out of `next` into `next_unchecked`, rather than making the `Some` and `unwrap_unchecked`ing it.

And while I was touching it, I added a codegen test that `array::repeat` for something that's just `Clone`, not `Copy`, still ends up optimizing to the same thing as `[x; n]`: <https://rust.godbolt.org/z/YY3a5ajMW>.
2024-08-03 20:51:52 +02:00
Matthias Krüger
7d9ed2a864
Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors
Stabilize unsafe extern blocks (RFC 3484)

# Stabilization report

## Summary

This is a tracking issue for the RFC 3484: Unsafe Extern Blocks

We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](https://github.com/rust-lang/rfcs/pull/3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use.

RFC: https://github.com/rust-lang/rfcs/pull/3484
Tracking issue: #123743

## What is stabilized

### Summary of stabilization

We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results.

```rust
unsafe extern {
    // sqrt (from libm) may be called with any `f64`
    pub safe fn sqrt(x: f64) -> f64;

    // strlen (from libc) requires a valid pointer,
    // so we mark it as being an unsafe fn
    pub unsafe fn strlen(p: *const c_char) -> usize;

    // this function doesn't say safe or unsafe, so it defaults to unsafe
    pub fn free(p: *mut core::ffi::c_void);

    pub safe static IMPORTANT_BYTES: [u8; 256];

    pub safe static LINES: SyncUnsafeCell<i32>;
}
```

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`.

## History

- https://github.com/rust-lang/rust/pull/124482
- https://github.com/rust-lang/rust/pull/124455
- https://github.com/rust-lang/rust/pull/125077
- https://github.com/rust-lang/rust/pull/125522
- https://github.com/rust-lang/rust/issues/126738
- https://github.com/rust-lang/rust/issues/126749
- https://github.com/rust-lang/rust/issues/126755
- https://github.com/rust-lang/rust/pull/126757
- https://github.com/rust-lang/rust/pull/126758
- https://github.com/rust-lang/rust/issues/126756
- https://github.com/rust-lang/rust/pull/126973
- https://github.com/rust-lang/rust/pull/127535
- https://github.com/rust-lang/rustfmt/pull/6204

## Unresolved questions

I am not aware of any unresolved questions.
2024-08-03 20:51:51 +02:00
bors
bbf60c897e Auto merge of #127324 - DianQK:match-br, r=cjgillot
Simplify match based on the cast result of `IntToInt`

Continue to complete #124150. The condition in #120614 is wrong, e.g. `-1i8` cannot be converted to `255i16`. I've rethought the issue and simplified the conditional judgment for a more straightforward approach. The new approach is to check **if the case value after the `IntToInt` conversion equals the target value**.

In different types, `IntToInt` uses different casting methods. This rule is as follows:

- `i8`/`u8` to `i8`/`u8`: do nothing.
- `i8` to `i16`/`u16`: sign extension.
- `u8` to `i16`/`u16`: zero extension.
- `i16`/`u16` to `i8`/`u8`: truncate to the target size.

The previous error was a mix of zext and sext.

r? mir-opt
2024-08-03 18:48:30 +00:00
clubby789
8497800abd Add test for updating enum discriminant through pointer 2024-08-03 16:41:49 +00:00
Chris Denton
f28d157091
Update rmake.rs 2024-08-03 16:04:37 +00:00
Chris Denton
c2523c9543
Use object in run-make/symbols-visibility 2024-08-03 14:56:16 +00:00
bors
1f47624f9a Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix
Revert recent changes to dead code analysis

This is a revert to recent changes to dead code analysis, namely:
* efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
* a70dc297a8 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix
* 31fe9628cf Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix
* 2724aeaaeb Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
* 977c5fd419 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
* 13314df21b Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix

There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153.

Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs?

I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way.

cc `@mu001999`
r? `@pnkfelix`

Fixes #128272
Fixes #126169
2024-08-03 13:04:30 +00:00
Chris Denton
eb451464a7
Remove BAR for run-make/used.rs 2024-08-03 13:02:32 +00:00
Chris Denton
b564b70d1c
Update run-make/used to use any_symbol_contains 2024-08-03 12:40:53 +00:00
Michael Goulet
a57b8b91db Bless test fallout 2024-08-03 07:57:31 -04:00
Michael Goulet
ac56007ea7 Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit 13314df21b, reversing
changes made to 6e534c73c3.
2024-08-03 07:57:31 -04:00
Michael Goulet
d29818c9f5 Revert "Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov"
This reverts commit 977c5fd419, reversing
changes made to 24c94f0e4f.
2024-08-03 07:57:31 -04:00
Michael Goulet
22da616245 Revert "Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit 2724aeaaeb, reversing
changes made to d929a42a66.
2024-08-03 07:57:31 -04:00
Michael Goulet
5f5b4ee128 Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"
This reverts commit 31fe9628cf, reversing
changes made to f20307851e.
2024-08-03 07:57:31 -04:00
Michael Goulet
c6b6c1270a Revert "Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit a70dc297a8, reversing
changes made to ceae37188b.
2024-08-03 07:57:31 -04:00
Michael Goulet
361ab1af0c Revert "Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov"
This reverts commit 91b18a058c, reversing
changes made to 9aedec9313.
2024-08-03 07:57:30 -04:00
bors
ad0a2b7180 Auto merge of #128595 - matthiaskrgr:rollup-7a4qa8b, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #126704 (Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate)
 - #127586 (Add `#[must_use]` to some `into_raw*` functions.)
 - #128161 (nested aux-build in tests/rustdoc/ tests)
 - #128303 (Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`)
 - #128368 (Formatting tweaks)
 - #128483 (Still more `cfg` cleanups)
 - #128557 (chore: use shorthand initializer)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-03 10:40:36 +00:00
Matthias Krüger
47a795bbd3
Rollup merge of #128161 - EtomicBomb:just-compiletest, r=notriddle
nested aux-build in tests/rustdoc/ tests

* Fixes bug that prevented using nested aux-build in `tests/rustdoc/` tests. Before, `fn document` and the auxiliary builder disagreed about where to find the nested aux-build source file (`auxiliary/auxiliary/aux.rs` vs `auxiliary/aux.rs`), preventing them from building. Picked the latter in line with other builders in compiletest.
* Adds `//@ doc-flags` header, which forwards flags to rustdoc and not rustc.
* Adds `//@ unique-doc-out-dir` header, which sets the --out-dir for the rustdoc invocation to a unique directory: `<root out dir>/docs/<test name>/doc`
* Changes working directory of the rustdoc invocation to the root out directory (common among all aux-builds). Prior art: exec_compiled_test in runtest.rs
* Adds tests that use nested aux builds and new headers

These changes provide useful capabilities for writing rustdoc tests on their own. They are also needed to test the implementation for the [mergable-rustdoc-cross-crate-info](https://github.com/rust-lang/rfcs/pull/3662) RFC.

try-job: x86_64-msvc
2024-08-03 11:17:42 +02:00
Matthias Krüger
8aa18290a4
Rollup merge of #126704 - sayantn:sha, r=Amanieu
Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate

This is an effort towards #126624. This adds support for these 3 target-features and introduces the feature flag `sha512_sm_x86`, which would gate these target-features and the yet-to-be-implemented detection and intrinsics in stdarch.
2024-08-03 11:17:41 +02:00
bors
a6043039ad Auto merge of #128356 - Oneirical:real-estate-reaLTOr, r=jieyouxu
Migrate `cross-lang-lto-clang` and `cross-lang-lto-pgo-smoketest` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

This has the same problem outlined by #126180, where the tests do not actually run as no test-running CI enviroment has `RUSTBUILD_FORCE_CLANG_BASED_TESTS` set.

However, I still find it interesting to turn the Makefiles into the rmake format until the Clang issue is fixed.

This should technically be tested on MSVC... if MSVC actually ran Clang tests.

try-job: x86_64-gnu-debug
2024-08-03 08:07:00 +00:00
Michael Goulet
b0beb64830 Use ParamEnv::reveal_all in CFI 2024-08-02 23:24:50 -04:00
DianQK
1f9d9603c0
Re-enable SimplifyToExp in match_branches. 2024-08-03 10:55:46 +08:00
DianQK
8b9d7b1489
Simplify match based on the cast result of IntToInt. 2024-08-03 10:55:43 +08:00
Oli Scherer
33cb33441d Add test for coroutine attribute 2024-08-03 02:28:59 +00:00
Michael Goulet
2e52d61807 Stop doing weird index stuff in ElaborateBoxDerefs 2024-08-02 17:45:55 -04:00
Folkert
eb726a50e6 add needs-asm-support to invalid-sym-operand 2024-08-02 19:59:34 +01:00
bors
fd8d6fbe50 Auto merge of #128361 - Oneirical:testle-deforestation, r=jieyouxu
Migrate `link-cfg` and `rustdoc-default-output` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: aarch64-apple
try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: x86_64-gnu-llvm-18
try-job: i686-msvc
2024-08-02 18:24:21 +00:00
Oneirical
290a260721 run cross-lang-lto-pgo-smoketest in CI by renaming it 2024-08-02 11:54:20 -04:00
Oneirical
560e86d753 rewrite cross-lang-lto-pgo-smoketest to rmake 2024-08-02 11:53:32 -04:00
Oneirical
c0d9357a4c rewrite cross-lang-lto-clang to rmake 2024-08-02 11:53:32 -04:00
Oneirical
c27fa5c332 rewrite rustdoc-default-output to rmake 2024-08-02 11:50:19 -04:00
Oneirical
46b4083e6f rewrite foreign-exceptions to rmake 2024-08-02 10:06:20 -04:00
Oneirical
5b44f800f3 rewrite and rename issue-36710 to rmake 2024-08-02 10:06:07 -04:00
Oneirical
8f641b1b95 rewrite foreign-double-unwind to rmake 2024-08-02 10:05:55 -04:00
bjorn3
feeeb5c48e Bless tests 2024-08-02 11:34:54 +00:00
bors
5367673014 Auto merge of #128352 - Oneirical:daLTOnist-vision, r=jieyouxu
Migrate `cross-lang-lto` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: x86_64-msvc
try-job: i686-mingw
try-job: x86_64-mingw
try-job: armhf-gnu
try-job: test-various
try-job: aarch64-apple
try-job: x86_64-gnu-llvm-18
2024-08-02 10:59:19 +00:00
beetrees
b1493ba519
Move ZST ABI handling to rustc_target 2024-08-02 11:45:32 +01:00
Scott McMurray
77ca30f195 Implement UncheckedIterator directly for RepeatN 2024-08-01 21:58:34 -07:00
bors
2cec7a85ed Auto merge of #128529 - matthiaskrgr:rollup-gzq2slo, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #126818 (Better handle suggestions for the already present code and fix some suggestions)
 - #128436 (Update sysinfo version to 0.31.2)
 - #128453 (raw_eq: using it on bytes with provenance is not UB (outside const-eval))
 - #128491 ([`macro_metavar_expr_concat`] Dogfooding)
 - #128494 (MIR required_consts, mentioned_items: ensure we do not forget to fill these lists)
 - #128521 (rustdoc: Remove dead opaque_tys rendering logic)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-02 04:53:45 +00:00
Matthias Krüger
67fcb58347
Rollup merge of #128453 - RalfJung:raw_eq, r=saethlin
raw_eq: using it on bytes with provenance is not UB (outside const-eval)

The current behavior of raw_eq violates provenance monotonicity. See https://github.com/rust-lang/rust/pull/124921 for an explanation of provenance monotonicity. It is violated in raw_eq because comparing bytes without provenance is well-defined, but adding provenance makes the operation UB.

So remove the no-provenance requirement from raw_eq. However, the requirement stays in-place for compile-time invocations of raw_eq, that indeed cannot deal with provenance.

Cc `@rust-lang/opsem`
2024-08-02 06:43:43 +02:00
Matthias Krüger
d1d57bd104
Rollup merge of #126818 - estebank:suggestions-fix, r=wesleywiser
Better handle suggestions for the already present code and fix some suggestions

When a suggestion part is for code that is already present, skip it. If all the suggestion parts for a suggestion are for code that is already there, do not emit the suggestion.

Fix two suggestions that treat `span_suggestion` as if it were `span_help`.
2024-08-02 06:43:41 +02:00
Esteban Küber
2c83c99058 More information for fully-qualified suggestion when there are multiple impls
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/E0283.rs:30:21
   |
LL |     fn create() -> u32;
   |     ------------------- `Coroutine::create` defined here
...
LL |     let cont: u32 = Coroutine::create();
   |                     ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     let cont: u32 = <Impl as Coroutine>::create();
   |                     ++++++++          +
LL |     let cont: u32 = <AnotherImpl as Coroutine>::create();
   |                     +++++++++++++++          +
```
2024-08-02 03:22:56 +00:00
bors
05e692ae02 Auto merge of #128147 - lolbinarycat:fmt-write-bloat-rmake, r=jieyouxu
migrate fmt-write-bloat to rmake

try-job: aarch64-apple
try-job: x86_64-gnu-llvm-18
try-job: dist-x86_64-linux
2024-08-02 02:28:59 +00:00
bors
425ae69588 Auto merge of #127624 - Oneirical:a-test-of-lime, r=jieyouxu
Migrate and rename `issue-47551`, `issue-35164` and `issue-69368` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: dist-x86_64-msvc
2024-08-02 00:03:42 +00:00
Michael Goulet
5138586678 Skip over args when determining if coroutine-closure's inner coroutine consumes its upvars 2024-08-01 18:46:26 -04:00
sayantn
41b017ec99 Add the sha512, sm3 and sm4 target features
Add the feature in `core/lib.rs`
2024-08-02 02:29:15 +05:30
bors
8e86c95671 Auto merge of #127276 - aDotInTheVoid:no-opaque, r=camelid
rustdoc: Remove OpaqueTy

r? `@ghost`

Apparently this works lol?!?

try-job: aarch64-apple
2024-08-01 19:45:25 +00:00
Folkert
47e6db542e separate test file for invalid const operand 2024-08-01 20:13:05 +01:00
Folkert
b73077e3d8 separate test file for invalid sym operand 2024-08-01 20:13:05 +01:00
Esteban Küber
8ce8c42e0b Do not underline suggestions for code that is already there
When a suggestion part is for already present code, do not highlight it. If after that there are no highlights left, do not show the suggestion at all.

Fix clippy lint suggestion incorrectly treated as `span_help`.
2024-08-01 18:53:42 +00:00
Matthias Krüger
29cd3103a1
Rollup merge of #128496 - clubby789:box-syntax-multipart, r=compiler-errors
Fix removed `box_syntax` diagnostic if source isn't available

Fix #128442
2024-08-01 18:43:41 +02:00
Matthias Krüger
8671b0bfbd
Rollup merge of #128482 - RalfJung:ptr-signed-offset, r=oli-obk
interpret: on a signed deref check, mention the right pointer in the error

When a negative offset (like `ptr.offset(-10)`) goes out-of-bounds, we currently show an error saying that we expect the *resulting* pointer to be inbounds for 10 bytes. That's confusing, so this PR makes it so that instead we say that we expect the *original* pointer `ptr` to have 10 bytes *to the left*.

I also realized I can simplify the pointer arithmetic logic and handling of "staying inbounds of a target `usize`" quite a bit; the second commit does that.
2024-08-01 18:43:40 +02:00
Alona Enraght-Moony
52a49d94c7 rustdoc: Add test for impl_trait_in_accos_type 2024-08-01 15:48:22 +00:00
Oneirical
94da7b157a rewrite stable-symbol-names to rmake 2024-08-01 11:07:04 -04:00
Oneirical
b485dd1495 rewrite reproducible-build-2 to rmake 2024-08-01 10:56:48 -04:00
clubby789
e157954cce Fix removed box_syntax diagnostic if source isn't available 2024-08-01 13:11:24 +00:00
Ralf Jung
db1652e07b fix the way we detect overflow for inbounds arithmetic (and tweak the error message) 2024-08-01 14:38:58 +02:00
Ralf Jung
5d5c97aad7 interpret: simplify pointer arithmetic logic 2024-08-01 14:25:19 +02:00
Ralf Jung
de78cb56b2 on a signed deref check, mention the right pointer in the error 2024-08-01 14:25:19 +02:00
bors
c0e32983f5 Auto merge of #127543 - carbotaniuman:more_unsafe_attr_verification, r=estebank,traviscross
More unsafe attr verification

This code denies unsafe on attributes such as `#[test]` and `#[ignore]`, while also changing the `MetaItem` parsing so `unsafe` in args like `#[allow(unsafe(dead_code))]` is not accidentally allowed.

Tracking:

- https://github.com/rust-lang/rust/issues/123757
2024-08-01 10:40:45 +00:00
bors
97ac52f579 Auto merge of #128481 - matthiaskrgr:rollup-efa706r, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128416 (android: Remove libstd hacks for unsupported Android APIs)
 - #128437 (improve bootstrap to allow selecting llvm tools individually)
 - #128450 (Create COFF archives for non-LLVM backends)
 - #128458 (Emit an error if `#[optimize]` is applied to an incompatible item)
 - #128477 (Finish blessing `coverage/mcdc` tests after LLVM 19 upgrade)
 - #128478 (Ignore `use` declaration reformatting in `.git-blame-ignore-revs`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-01 08:09:31 +00:00
Matthias Krüger
5dc8d49ba5
Rollup merge of #128477 - Zalathar:bless-mcdc-19, r=cuviper
Finish blessing `coverage/mcdc` tests after LLVM 19 upgrade

Context: https://github.com/rust-lang/rust/pull/127513#issuecomment-2260887708

These changes aren't needed for Rust CI, because after the LLVM 19 upgrade we have no jobs that run these tests in `coverage-run` mode against LLVM 18. But they might help external builds.

The longer-term plan is to completely drop (unstable) MC/DC support on LLVM 18, as part of getting it working on LLVM 19 in #126733.

cc `@cuviper`
2024-08-01 08:33:30 +02:00
Matthias Krüger
7c60525877
Rollup merge of #128458 - clubby789:optimize-unused-attr, r=compiler-errors
Emit an error if `#[optimize]` is applied to an incompatible item

#54882

The RFC specifies that this should emit a lint. I used the same allow logic as the `coverage` attribute (also allowing modules and impl blocks) - this should possibly be changed depending on if it's decided to allow 'propogation' of the attribute.
2024-08-01 08:33:29 +02:00
bors
70591dc15d Auto merge of #127060 - Oneirical:testificate, r=jieyouxu
Migrate `symbol-visibility` `run-make` test to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Pretty scary!

- The expected number of symbols on each check has been changed slightly to reflect the differences between `llvm_readobj` and `nm`, as I think the former will print hidden symbols once and visible symbols twice, while the latter will only print visible symbols.
- The original test ran the same exact checks on `cdylib` twice, for seemingly no reason. I have removed it.
- This may be possible to optimize some more? `llvm_readobj` could get called only once for each library type, and the regex could avoid being created repeatedly. I am not sure if these kinds of considerations are important for a `run-make` test.

Demands a Windows try-job.

try-job: x86_64-mingw
2024-08-01 05:42:09 +00:00
Zalathar
68df46c4c2 Finish blessing coverage/mcdc tests after LLVM 19 upgrade 2024-08-01 13:36:50 +10:00
bors
e485266c67 Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #123813 (Add `REDUNDANT_IMPORTS` lint for new redundant import detection)
 - #126697 ([RFC] mbe: consider the `_` in 2024 an expression)
 - #127159 (match lowering: Hide `Candidate` from outside the lowering algorithm)
 - #128244 (Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks)
 - #128431 (Add myself as VxWorks target maintainer for reference)
 - #128438 (Add special-case for [T, 0] in dropck_outlives)
 - #128457 (Fix docs for OnceLock::get_mut_or_init)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-01 02:26:32 +00:00
Matthias Krüger
cf900ab62d
Rollup merge of #128452 - dingxiangfei2009:smart-ptr-require-maybe-sized, r=compiler-errors
derive(SmartPointer): require pointee to be maybe sized

cc ``@Darksonn``

So `#[pointee]` has to be `?Sized` in order for deriving `SmartPointer` to be meaningful.

cc ``@compiler-errors`` for suggestions in #127681
2024-08-01 00:50:13 +02:00
Matthias Krüger
046664bdea
Rollup merge of #128449 - Urgau:tmp-allow-negative-lit-lint, r=compiler-errors
Temporarily switch `ambiguous_negative_literals` lint to allow

This PR temporarily switch the `ambiguous_negative_literals` lint to `allow-by-default`, as asked by T-lang in https://github.com/rust-lang/rust/issues/128287#issuecomment-2260902036.
2024-08-01 00:50:12 +02:00
Matthias Krüger
ac67d10050
Rollup merge of #128443 - compiler-errors:async-unreachable, r=fmease
Properly mark loop as diverging if it has no breaks

Due to specifics about the desugaring of the `.await` operator, HIR typeck doesn't recognize that `.await`ing an `impl Future<Output = !>` will diverge in the same way as calling a `fn() -> !`.

This is because the await operator desugars to approximately:

```rust
loop {
    match future.poll(...) {
        Poll::Ready(x) => break x,
        Poll::Pending => {}
    }
}
```

We know that the value of `x` is `!`, however since `break` is a coercion site, we coerce `!` to some `?0` (the type of the loop expression). Then since the type of the `loop {...}` expression is `?0`, we will not detect the loop as diverging like we do with other expressions that evaluate to `!`:

0b5eb7ba7b/compiler/rustc_hir_typeck/src/expr.rs (L240-L243)

We can technically fix this in two ways:
1. Make coercion of loop exprs more eagerly result in a type of `!` when the only break expressions have type `!`.
2. Make loops understand that all of that if they have only diverging break values, then the loop diverges as well.

(1.) likely has negative effects on inference, and seems like a weird special case to drill into coercion. However, it turns out that (2.) is very easy to implement, we already record whether a loop has any break expressions, and when we do so, we actually skip over any break expressions with diverging values!:

0b5eb7ba7b/compiler/rustc_hir_typeck/src/expr.rs (L713-L716)

Thus, we can consider the loop as diverging if we see that it has no breaks, which is the change implemented in this PR.

This is not usually a problem in regular code for two reasons:
1. In regular code, we already mark `break diverging()` as unreachable if `diverging()` is unreachable. We don't do this for `.await`, since we suppress unreachable errors within `.await` (#64930). Un-suppressing this code will result in spurious unreachable expression errors pointing to internal await machinery.
3. In loops that truly have no breaks (e.g. `loop {}`), we already evaluate the type of the loop to `!`, so this special case is kinda moot. This only affects loops that have `break`s with values of type `!`.

Thus, this seems like a change that may affect more code than just `.await`, but it likely does not in meaningful ways; if it does, it's certainly correct to apply.

Fixes #128434
2024-08-01 00:50:12 +02:00
Matthias Krüger
b22c48ed6e
Rollup merge of #128438 - Bryanskiy:empty-array-dropck, r=lcnr
Add special-case for [T, 0] in dropck_outlives

implements/fixes #110288.

r? `@lcnr`
2024-07-31 23:20:12 +02:00
Matthias Krüger
52f7d33109
Rollup merge of #128244 - compiler-errors:move-clone-sugg, r=estebank
Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks

Also remove a heck of a lot of weird hacks in `suggest_cloning` that I don't think we should have around.

I know this regresses tests, but I don't believe most of these suggestions were accurate, b/c:
1. They either produced type errors (e.g. turning `&x` into `x.clone()`)
2. They don't fix the issue
3. They fix the issue ostensibly, but introduce logic errors (e.g. cloning a `&mut Option<T>` to then `Option::take` out...)

Most of the suggestions are still wrong, but they're not particularly *less* wrong IMO.

Stacked on top of #128241, which is an "obviously worth landing" subset of this PR.

r? estebank
2024-07-31 23:20:11 +02:00
Matthias Krüger
19f6ff0655
Rollup merge of #127159 - Nadrieril:hide-candidate, r=matthewjasper
match lowering: Hide `Candidate` from outside the lowering algorithm

The internals of `Candidate` are tricky and a source of confusion. This PR makes it so we don't expose `Candidate`s outside the lowering algorithm. Now:
- false edges are handled in `lower_match_tree`;
- `lower_match_tree` takes a list of patterns as input;
- `lower_match_tree` returns a flat datastructure that contains only the necessary information.

r? ```@matthewjasper```
2024-07-31 23:20:10 +02:00
Matthias Krüger
3acd910036
Rollup merge of #126697 - vincenzopalazzo:macros/find_the_expression_tok, r=eholk,compiler-errors
[RFC] mbe: consider the `_` in 2024 an expression

This commit is adding the possibility to parse the `_` as an expression inside the esition 2024.

Link: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/supporting.20.60_.60.20expressions

Issue https://github.com/rust-lang/rust/issues/123742

r? `@eholk`
2024-07-31 23:20:09 +02:00
Matthias Krüger
20379e4d4e
Rollup merge of #123813 - compiler-errors:redundant-lint, r=petrochenkov
Add `REDUNDANT_IMPORTS` lint for new redundant import detection

Defaults to Allow for now. Stacked on #123744 to avoid merge conflict, but much easier to review all as one.

r? petrochenkov
2024-07-31 23:20:09 +02:00