Commit Graph

265823 Commits

Author SHA1 Message Date
bors
c8dff289a0 Auto merge of #130456 - matthiaskrgr:rollup-h2qvk1f, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #130380 (coverage: Clarify some parts of coverage counter creation)
 - #130427 (run_make_support: rectify symlink handling)
 - #130447 (rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…)
 - #130448 (fix: Remove duplicate `LazyLock` example.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-17 03:40:29 +00:00
Matthias Krüger
558b302af7
Rollup merge of #130448 - alilleybrinker:master, r=workingjubilee
fix: Remove duplicate `LazyLock` example.

The top-level docs for `LazyLock` included two lines of code, each with an accompanying comment, that were identical and with nearly- identical comments. This looks like an oversight from a past edit which was perhaps trying to rewrite an existing example but ended up duplicating rather than replacing, though I haven't gone back through the Git history to check.

This commit removes what I personally think is the less-clear of the two examples.
2024-09-17 03:58:47 +02:00
Matthias Krüger
264597d86c
Rollup merge of #130447 - durin42:llvm-20-fix-instrumentation-hdr, r=cuviper
rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…

…4c82dd0ed8b5

Just a simple header move.

`@rustbot` label: +llvm-main
2024-09-17 03:58:47 +02:00
Matthias Krüger
07ca905420
Rollup merge of #130427 - jieyouxu:rmake-symlink, r=Kobzol
run_make_support: rectify symlink handling

Avoid confusing Unix symlinks and Windows symlinks. Since their
semantics are quite different, we should avoid trying to make it
automagic in how symlinks are created and deleted. Notably, the tests
should reflect what type of symlinks are to be created to match what std
does to make it less surprising for test readers.
2024-09-17 03:58:46 +02:00
Matthias Krüger
1a7fdc7d5d
Rollup merge of #130380 - Zalathar:counters, r=jieyouxu
coverage: Clarify some parts of coverage counter creation

This is a series of semi-related changes that are trying to make the `counters` module easier to read, understand, and modify.

For example, the existing code happens to avoid ever using the count for a `TerminatorKind::Yield` node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures.

This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read.

There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.
2024-09-17 03:58:46 +02:00
bors
e2dc1a1c0f Auto merge of #129970 - lukas-code:LayoutCalculator, r=compiler-errors
layout computation: gracefully handle unsized types in unexpected locations

This PR reworks the layout computation to eagerly return an error when encountering an unsized field where a sized field was expected, rather than delaying a bug and attempting to recover a layout. This is required, because with trivially false where clauses like `[T]: Sized`, any field can possible be an unsized type, without causing a compile error.

Since this PR removes the `delayed_bug` method from the `LayoutCalculator` trait, it essentially becomes the same as the `HasDataLayout` trait, so I've also refactored the `LayoutCalculator` to be a simple wrapper struct around a type that implements `HasDataLayout`.

The majority of the diff is whitespace changes, so viewing with whitespace ignored is advised.

implements https://github.com/rust-lang/rust/pull/123169#issuecomment-2025788480

r? `@compiler-errors` or compiler

fixes https://github.com/rust-lang/rust/issues/123134
fixes https://github.com/rust-lang/rust/issues/124182
fixes https://github.com/rust-lang/rust/issues/126939
fixes https://github.com/rust-lang/rust/issues/127737
2024-09-17 01:17:48 +00:00
Augie Fackler
1e68f05109 rustc_llvm: update for llvm/llvm-project@2ae968a0d9
Just a simple header move.

@rustbot label: +llvm-main
2024-09-16 19:53:13 -04:00
bors
bde6bf2b07 Auto merge of #127633 - SamuelMarks:eq-exit-code, r=dtolnay
[library/std/src/process.rs] `PartialEq` for `ExitCode`

Converting a third-party CLI to a library so started passing around [`std::process::ExitCode`](https://doc.rust-lang.org/std/process/struct.ExitCode.html) in an `Either`. Then I realised the tests can't be modified to compare equality of `ExitCode`s.

This PR fixes this oversight.
2024-09-16 22:55:33 +00:00
Lukas Markeffsky
20d2414925 get rid of an old hack
For structs that cannot be unsized, the layout algorithm sometimes moves
unsized fields to the end of the struct, which circumvented the error
for unexpected unsized fields and returned an unsized layout anyway.

This commit makes it so that the unexpected unsized error is always
returned for structs that cannot be unsized, allowing us to remove an
old hack and fixing some old ICE.
2024-09-17 00:09:21 +02:00
Lukas Markeffsky
3db930a463 assert that unexpectedly unsized fields are sized in the param env 2024-09-17 00:06:56 +02:00
Andrew Lilley Brinker
23e4e98d2c fix: Remove duplicate LazyLock example.
The top-level docs for `LazyLock` included two lines of code, each
with an accompanying comment, that were identical and with nearly-
identical comments. This looks like an oversight from a past edit
which was perhaps trying to rewrite an existing example but ended
up duplicating rather than replacing, though I haven't gone back
through the Git history to check.

This commit removes what I personally think is the less-clear of
the two examples.

Signed-off-by: Andrew Lilley Brinker <alilleybrinker@gmail.com>
2024-09-16 14:21:05 -07:00
bors
c52c23b6f4 Auto merge of #130444 - matthiaskrgr:rollup-onlrjva, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #130033 (Don't call `fn_arg_names` query for non-`fn` foreign items in resolver)
 - #130282 (Do not report an excessive number of overflow errors for an ever-growing deref impl)
 - #130437 (Avoid crashing on variadic functions when producing arg-mismatch errors)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-16 20:01:52 +00:00
Matthias Krüger
14ee69c250
Rollup merge of #130437 - jder:issue-130372, r=compiler-errors
Avoid crashing on variadic functions when producing arg-mismatch errors

Fixes #130372 by accommodating how variadic functions change the argument list length between HIR body and FnDecls.

Also degrades the zip_eq to a debug_assert! to match other asserts in the area to avoid being disruptive to users. There is at least one other crash in this area I am working on in #130400 and also considering how we might refactor some of this code to hoist some of this logic up higher.

r? `@compiler-errors`
2024-09-16 21:53:07 +02:00
Matthias Krüger
852e08e9bc
Rollup merge of #130282 - compiler-errors:over-overflow, r=BoxyUwU
Do not report an excessive number of overflow errors for an ever-growing deref impl

Check that we don't first hit the recursion limit in `get_field_candidates_considering_privacy` before probing for methods when we have a method lookup failure and we want to see if `.field.method()` exists. We also silence overflow error messages if we're probing for methods for diagnostics.

Also renames some functions to make it clearer that they're only for diagnostics, and sprinkle some `Autoderef::silence_errors` around to silence unnecessary overflow errors that come from diagnostics.

Fixes #130224.
2024-09-16 21:53:07 +02:00
Matthias Krüger
7be15b850f
Rollup merge of #130033 - compiler-errors:foreign-fn-types, r=BoxyUwU
Don't call `fn_arg_names` query for non-`fn` foreign items in resolver

Fixes #130015
2024-09-16 21:53:06 +02:00
Jesse Rusak
45eceb2c57 Avoid crashing on variadic functions when producing arg-mismatch errors 2024-09-16 14:51:56 -04:00
bors
fd2c811d25 Auto merge of #130439 - matthiaskrgr:rollup-1lkzo74, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #123436 (linker: Allow MSVC to use import libraries following the Meson/MinGW convention)
 - #130410 (Don't ICE when generating `Fn` shim for async closure with borrowck error)
 - #130412 (Don't ICE when RPITIT captures more method args than trait definition)
 - #130436 (Ignore reduce-fadd-unordered on SGX platform)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-16 17:41:17 +00:00
Matthias Krüger
1807fdadb4
Rollup merge of #130436 - fortanix:raoul/fix_reduce_add_unordered_test, r=RalfJung
Ignore reduce-fadd-unordered on SGX platform

#130325 added the `tests/assembly/simd/reduce-fadd-unordered.rs` test. Unfortunately, the use of `CHECK: ret` makes that this test is not compatible with LVI mitigations applied for the SGX target. This PR makes sure this test is ignored for the SGX target, until a nicer solution is available.
2024-09-16 18:34:02 +02:00
Matthias Krüger
4e68d06b52
Rollup merge of #130412 - compiler-errors:rpitit-overcapture, r=jieyouxu
Don't ICE when RPITIT captures more method args than trait definition

Make sure we don't ICE when an RPITIT captures more method args than the trait definition, which is not allowed. This was because we were using the wrong def id for error reporting.

Due to the default lifetime capture rules of RPITITs (capturing everything in scope), this is only doable if we use precise capturing, which isn't currently allowed for RPITITs anyways but we still end up reaching the relevant codepaths.

Fixes #129850
2024-09-16 18:34:01 +02:00
Matthias Krüger
9a1004c259
Rollup merge of #130410 - compiler-errors:shim-borrowck-err, r=jieyouxu
Don't ICE when generating `Fn` shim for async closure with borrowck error

Turn an assumption that I had originally written as an assert into a delayed bug, because this shim code is reachable even if we have borrowck errors via the MIR inliner.

Fixes #129262.
2024-09-16 18:34:01 +02:00
Matthias Krüger
eac6f07380
Rollup merge of #123436 - amyspark:allow-msvc-to-use-meson-and-mingw-import-libraries, r=petrochenkov
linker: Allow MSVC to use import libraries following the Meson/MinGW convention

Hi all,

This PR implements support for `MsvcLinker` to use import libraries following Meson and the MinGW toolchain's naming convention. Meson [follows the `libfoo.dll.a` naming convention](https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa) to disambiguate between static and import libraries.

This support already existed for static libraries (see #100101), but not for dynamic libraries. The latter case was added by duplicating the logic in `native_libs::find_native_static_library`, but a separate case was added in `link_dylib_by_name` for the Windows CRT libraries which must be handled by the linker itself.

See for prerequisites #129366, #126094, and #128370.

All feedback is appreciated!

Fixes #122455

cc `@sdroege` `@nirbheek`
2024-09-16 18:34:00 +02:00
bors
3a22be33db Auto merge of #130414 - compiler-errors:precise-capturing-arg-valid, r=jieyouxu
Do precise capturing arg validation in resolve

Moves the validation of precise capturing args (`use<T, N>`) out of `resolve_bound_vars` and into `rustc_resolve`. This both simplifies the impl and fixes a bug when we have `use<arg>` where `arg` is one of the function args.

This also introduces new error codes specifically for precise capturing, to avoid reusing the other error codes which are not as accurate.

Fixes #130399
2024-09-16 14:59:29 +00:00
Michael Goulet
57a7e514a4 Don't ICE when generating Fn shim for async closure with borrowck error 2024-09-16 10:57:58 -04:00
Michael Goulet
1e9fa7eb79 Don't ICE when RPITIT captures more method args than trait definition 2024-09-16 10:57:06 -04:00
Michael Goulet
ae8b4607c6 Introduce distinct error codes for precise capturing 2024-09-16 10:56:22 -04:00
Michael Goulet
26bdfefae1 Do precise capturing arg validation in resolve 2024-09-16 10:56:22 -04:00
Raoul Strackx
11b42d2763 Ignore reduce-fadd-unordered on SGX platform 2024-09-16 16:54:48 +02:00
Lukas Markeffsky
697450151c layout computation: eagerly error for unexpected unsized fields 2024-09-16 15:53:21 +02:00
Lukas Markeffsky
16be6666d4 make LayoutCx not generic 2024-09-16 15:53:17 +02:00
许杰友 Jieyou Xu (Joe)
7d764283b4 tests/run-make: update for symlink helper changes 2024-09-16 21:31:41 +08:00
许杰友 Jieyou Xu (Joe)
1b86340218 run_make_support: rectify symlink handling
Avoid confusing Unix symlinks and Windows symlinks, and since their
semantics are quite different we should avoid trying to make it to
automagic in how symlinks are created and deleted. Notably, the tests
should reflect what type of symlinks are to be created to match what std
does to make it less surprising for test readers.
2024-09-16 12:57:44 +00:00
bors
13b5a4e43b Auto merge of #129716 - compiler-errors:closure-debuginfo, r=cjgillot
Don't use `typeck_root_def_id` in codegen for finding closure's root

Generating debuginfo in codegen currently peels off all the closure-specific generics (which presumably is done because they're redundant). This doesn't currently work correctly for the bodies we synthesize for async closures's returned coroutines (#128506), leading to #129702.

Specifically, `typeck_root_def_id` for some `DefKind::SyntheticCoroutineBody` just returns itself (because it loops while `is_typeck_child` is `true`, and that returns `false` for this defkind), which means we don't end up peeling off the coroutine-specific generics, and we end up encountering an otherwise unreachable `CoroutineWitness` type leading to an ICE.

This PR fixes `is_typeck_child` to consider `DefKind::SyntheticCorotuineBody` to be a typeck child, fixing `typeck_root_def_id` and suppressing this debuginfo bug.

Fixes #129702
2024-09-16 10:16:32 +00:00
bors
170d6cb845 Auto merge of #130426 - workingjubilee:rollup-63xnjry, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #127879 (Document futility of printing temporary pointers)
 - #130325 (Use -0.0 in `intrinsics::simd::reduce_add_unordered`)
 - #130336 (simplify `Build::update_existing_submodule`)
 - #130398 (Add system libs for LLVM when cross compiling for Windows)
 - #130420 (Register tool docs for `src/tools/build_helper`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-16 07:14:55 +00:00
Jubilee
f64d1c1f8f
Rollup merge of #130420 - jieyouxu:build_helpers_docs, r=onur-ozkan
Register tool docs for `src/tools/build_helper`

Fixes #130355.
2024-09-15 23:51:26 -07:00
Jubilee
7142e0db60
Rollup merge of #130398 - ChrisDenton:win-cross, r=jieyouxu
Add system libs for LLVM when cross compiling for Windows

Windows uses "import libraries" to link to system libraries. These are a kind of static lib that are distributed with the Windows SDK and therefore they don't rely on the host. All that matters is you have the right SDK installed for the target.
2024-09-15 23:51:26 -07:00
Jubilee
9025fe9e64
Rollup merge of #130336 - onur-ozkan:simple-improvement, r=albertlarsan68
simplify `Build::update_existing_submodule`

`Build::update_existing_submodule` is already doing the same thing..
2024-09-15 23:51:25 -07:00
Jubilee
68758c0560
Rollup merge of #130325 - workingjubilee:plus-minus-zero-redux, r=RalfJung,jieyouxu
Use -0.0 in `intrinsics::simd::reduce_add_unordered`

-0.0 is the actual neutral additive float, not +0.0, and this matters to codegen.

try-job: aarch64-gnu
2024-09-15 23:51:25 -07:00
Jubilee
0151cbe6e8
Rollup merge of #127879 - kornelski:bad-pointer-printf, r=workingjubilee
Document futility of printing temporary pointers

In the user forum I've seen a few people trying to understand how borrowing and moves are implemented by peppering their code with printing of `{:p}` of references to variables and expressions. This is a bad idea. It gives misleading and confusing results, because of autoderef magic, printing pointers of temporaries on the stack, and/or causes LLVM to optimize code differently when values had their address exposed.
2024-09-15 23:51:24 -07:00
bors
39b7669347 Auto merge of #130220 - RalfJung:float-classify, r=workingjubilee
simplify float::classify logic

I played around with the float-classify test in the hope of triggering x87 bugs by strategically adding `black_box`, and still the exact expression `@beetrees` suggested [here](https://github.com/rust-lang/rust/pull/129835#issuecomment-2325661597) remains the only case I found where we get the wrong result on x87. Curiously, this bug only occurs when MIR optimizations are enabled -- probably the extra inlining that does is required for LLVM to hit the right "bad" case in the backend. But even for that case, it makes no difference whether `classify` is implemented in the simple bit-pattern-based version or the more complicated version we had before.

Without even a single testcase that can distinguish our `classify` from the naive version, I suggest we switch to the naive version.
2024-09-16 03:36:03 +00:00
bors
c16ff44537 Auto merge of #130377 - weihanglo:update-cargo, r=weihanglo
Update cargo

25 commits in c1fa840a85eca53818895901a53fae34247448b2..a9a418d1a22f29e7dfd034e3b93f15657e608a29
2024-08-29 21:03:53 +0000 to 2024-09-15 19:13:12 +0000
- chore: revert change to Cargo.lock in f25806c (rust-lang/cargo#14547)
- Disable the shell_completions tests (rust-lang/cargo#14546)
- fix(vendor): trust crate version only when coming from registries (rust-lang/cargo#14530)
- docs: Feature resolver version 2: clarify use of 'target' (rust-lang/cargo#14540)
- Update docs for how cargo is published (rust-lang/cargo#14539)
- feat: Add native comlpetion with CompleteEnv under the nightly (rust-lang/cargo#14493)
- fix(new): Add to workspace relative to manifest, not current-dir (rust-lang/cargo#14505)
- Fix parsing of comma separated values in --crate-type flag (rust-lang/cargo#14499)
- Include public/private dependency status in `cargo metadata` (rust-lang/cargo#14504)
- Remove unnecessary symbols (rust-lang/cargo#14519)
- docs: bin source can be `src/main.rs` and/or in `src/bin/` (rust-lang/cargo#14515)
- fix(toml): Don't require MSRV bump for pub/priv (rust-lang/cargo#14507)
- bail before packaging on same version (rust-lang/cargo#14448)
- Implement path-bases (RFC 3529) 2/n: `cargo [add|remove|update]` support (rust-lang/cargo#14427)
- Publish workspace (rust-lang/cargo#14433)
- Bump ci's version of cargo-semver-version (rust-lang/cargo#14503)
- Document -Zpackage-workspace (rust-lang/cargo#14496)
- uplift windows gnullvm import libraries (rust-lang/cargo#14451)
- Bump to 0.84.0; update changelog (rust-lang/cargo#14495)
- Fix cargo add behaving different when translating package name (rust-lang/cargo#13765)
- chore(deps): update rust crate core-foundation to 0.10.0 (rust-lang/cargo#14475)
- feat(resolve): Report MSRV compatible version instead of incomptible (rust-lang/cargo#14471)
- Don't automatically include the current crate when packaging (rust-lang/cargo#14488)
- Fix elided lifetime (rust-lang/cargo#14487)
- chore(deps): update rust crate pasetors to 0.7.0 (rust-lang/cargo#14478)
2024-09-16 01:00:19 +00:00
许杰友 Jieyou Xu (Joe)
1f48a67a25 bootstrap: register tool docs for src/tools/build_helper 2024-09-16 00:33:33 +00:00
Jubilee Young
ab8c202527 Use -0.0 in intrinsics::simd::reduce_add_unordered
-0.0 is the actual neutral additive float, not +0.0, and this matters to codegen.
2024-09-15 16:40:23 -07:00
bors
d696a27c13 Auto merge of #130415 - matthiaskrgr:rollup-xhsu9oq, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #130151 (Use a small runner for msvc-ext2 job)
 - #130394 (const: don't ICE when encountering a mutable ref to immutable memory)
 - #130409 (tests: more ice tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-15 22:37:06 +00:00
Matthias Krüger
0406f12af9
Rollup merge of #130409 - matthiaskrgr:ccccrashes, r=compiler-errors
tests: more ice tests

r? `@jieyouxu`
2024-09-15 23:56:35 +02:00
Matthias Krüger
62445f1ec8
Rollup merge of #130394 - RalfJung:mut-ref-to-immut, r=saethlin
const: don't ICE when encountering a mutable ref to immutable memory

Turns out that this can actually happen -- thanks to `@matthiaskrgr` for producing a testcase. :)

Fixes https://github.com/rust-lang/rust/issues/130392
2024-09-15 23:56:35 +02:00
Matthias Krüger
21df3ff19e
Rollup merge of #130151 - ChrisDenton:slow-ci, r=Mark-Simulacrum
Use a small runner for msvc-ext2 job

Hopefully this should eliminate the errors from this job. The only question is how long it takes.

try-job: x86_64-msvc-ext2
2024-09-15 23:56:34 +02:00
Ralf Jung
7dfffe7e70 const: don't ICE when encountering a mutable ref to immutable memory 2024-09-15 22:53:04 +02:00
Weihang Lo
db19d43e42
Update cargo 2024-09-15 15:50:49 -04:00
bors
04a318787b Auto merge of #130407 - matthiaskrgr:rollup-vo2gmf4, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #129897 (deprecate -Csoft-float because it is unsound (and not fixable))
 - #130339 (Add `core::panic::abort_unwind`)
 - #130384 (compiler: Document AbiAndPrefAlign)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-15 19:35:19 +00:00
Matthias Krüger
9d761eac40 tests: more ice tests 2024-09-15 21:18:41 +02:00