Commit graph

42526 commits

Author SHA1 Message Date
Jubilee Young
e5ba20b0ef Revert "Stabilize extended_varargs_abi_support"
This reverts commit 685f189b43.
2025-02-13 08:52:53 -08:00
Lukas Markeffsky
a061e7eb65 fix ensure_monomorphic_enough
(cherry picked from commit c1da4f1d3c)
2025-02-13 08:52:47 -08:00
dianne
c8e8068fe9 peace of mind: be absolutely sure we don't try to emit a 0-part suggestion
(cherry picked from commit 8dcdb3eb3c)
2025-02-10 23:40:11 -08:00
dianne
909010ebe6 try to suggest eliding redundant binding modifiers
(cherry picked from commit b32a5331dc)
2025-02-10 23:40:02 -08:00
dianne
2f295779ee peace of mind: remove a call to Option::expect
(cherry picked from commit 060cc37f32)
2025-02-10 23:39:51 -08:00
dianne
ee0838fcab reword default binding mode notes
(cherry picked from commit a5cc4cbe64)
2025-02-10 23:39:29 -08:00
dianne
215bfdd07d separate labels for default binding mode spans into their own notes
(cherry picked from commit 767f82039c)
2025-02-10 23:38:56 -08:00
dianne
97cb2d553a don't include trailing open parens in labels for reference patterns
(cherry picked from commit a064e78663)
2025-02-10 23:33:10 -08:00
dianne
6ff2d19d1c experimentally label the spans for default binding modes
(cherry picked from commit 203d3109d8)
2025-02-10 23:32:54 -08:00
dianne
2ee601ced6 highlight the whole problem subpattern when pointing out the default binding mode
(cherry picked from commit 4331f55b72)
2025-02-10 23:21:22 -08:00
dianne
a9465deb4b use more specific wording for subpatterns from macro expansions
(cherry picked from commit bbe40acb9a)
2025-02-10 23:20:14 -08:00
dianne
1a18daac77 reword pattern migration diagnostic to make sense in all editions
This aligns the main error message a bit more with the phrasing in the
Edition Guide and provides a bit more information on the labels to
(hopefully!) aid in understanding.

(cherry picked from commit bdc6c4d07b)
2025-02-10 23:19:28 -08:00
dianne
acec5868ec pattern migration: move labels out of the suggestion struct
(cherry picked from commit 724b885b4e)
2025-02-10 23:08:35 -08:00
Jubilee Young
bf24cade3e Enable kernel sanitizers for aarch64-unknown-none-softfloat
We want kernels to be able to use this bare metal target, so
let's enable the sanitizers that kernels want to use.

(cherry picked from commit 6b06aa6192)
2025-02-06 09:53:26 -08:00
Rémy Rakic
01283c450e ensure sufficient stack in unsafety check
(cherry picked from commit 94562ee1ea)
2025-02-06 09:53:26 -08:00
Rémy Rakic
741fa9e39f ensure sufficient stack in tail call check
(cherry picked from commit 2c778c1e4c)
2025-02-06 09:53:26 -08:00
Rémy Rakic
197b416baf Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, r=davidtwco,RalfJung"
This reverts commit b57d93d8b9, reversing
changes made to 0aeaa5eb22.

(cherry picked from commit 122a55bb44)
2025-02-06 09:53:26 -08:00
Rémy Rakic
c6063d45b7 Revert "Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obk"
This reverts commit 7c301ecdf5, reversing
changes made to dffaad8332.

(cherry picked from commit 0bb4880581)
2025-02-06 09:53:26 -08:00
Rémy Rakic
7302b302d0 Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"
This reverts commit e108481f74, reversing
changes made to 303e8bd768.

(cherry picked from commit ca1c17c88d)
2025-02-06 09:53:26 -08:00
Esteban Küber
e98d52408c Add check for missing fields in enum variant pattern
(cherry picked from commit d44f021904)
2025-02-06 09:53:26 -08:00
Esteban Küber
887965ddb9 Ensure that we don't try to access fields on a non-struct pattern type in diagnostic
Fix #135209.

(cherry picked from commit 5f04f98c9a)
2025-02-06 09:53:26 -08:00
Josh Stone
f05d305f5a Only assert the Parser size on specific arches
The size of this struct depends on the alignment of `u128`, for example
powerpc64le and s390x have align-8 and end up with only 280 bytes. Our
64-bit tier-1 arches are the same though, so let's just assert on those.

(cherry picked from commit aef640a613)
2025-01-25 16:48:11 -08:00
Kyle Huey
4595e112d0 When LLVM's location discriminator value limit is exceeded, emit locations with dummy spans instead of dropping them entirely
Revert most of #133194 (except the test and the comment fixes). Then refix
not emitting locations at all when the correct location discriminator value
exceeds LLVM's capacity.

(cherry picked from commit 45ef92731b)
2025-01-23 08:45:35 -08:00
lcnr
e35db4245b add cache to AmbiguityCausesVisitor
(cherry picked from commit 94bf8f04f4)
2025-01-23 08:45:25 -08:00
lcnr
953a1a0031 avoid running the overlap check twice
(cherry picked from commit ebbcfd4e77)
2025-01-23 08:45:25 -08:00
Esteban Küber
a41d236a6e Always force non-trimming of path in unreachable_patterns lint
Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`.

This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite.

Fix #135289.

(cherry picked from commit 93a19501c2)
2025-01-23 08:44:57 -08:00
Michael Goulet
e126c8d50e Make sure to mark IMPL_TRAIT_REDUNDANT_CAPTURES as Allow in edition 2024
(cherry picked from commit 1b068a0dea)
2025-01-16 17:50:08 -08:00
Michael Goulet
18d3153837 Try to explain borrow for tail expr temporary drop order change in 2024
(cherry picked from commit c55eefe8bc)
2025-01-10 16:17:51 -08:00
Michael Goulet
1b8413e296 Don't do AccessDepth::Drop for types with no drop impl
(cherry picked from commit 4a099b29cd)
2025-01-10 15:54:24 -08:00
Michael Goulet
273873a671 Don't create cycles by normalizing opaques defined in the body we're checking
(cherry picked from commit 197f6d8081)
2025-01-10 15:54:24 -08:00
wieDasDing
61c0bcfff3 remove an extraneous comment
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
(cherry picked from commit 13c7122df8)
2025-01-10 15:54:24 -08:00
Ding Xiang Fei
e39842814c apply suggestions on fn name
(cherry picked from commit 34edb21f0b)
2025-01-10 15:54:24 -08:00
Ding Xiang Fei
44755086c8 run borrowck tests on BIDs and emit tail-expr-drop-order lints for
potential violations

(cherry picked from commit 045271cccc)
2025-01-10 15:54:24 -08:00
Noratrieb
031ad72d4d
Pass objcopy args for stripping on OSX
When `-Cstrip` was changed to use the bundled rust-objcopy instead of
/usr/bin/strip on OSX, strip-like arguments were preserved.

But strip and objcopy are, while being the same binary, different, they
have different defaults depending on which binary they are.
Notably, strip strips everything by default, and objcopy doesn't strip
anything by default.

Additionally, `-S` actually means `--strip-all`, so debuginfo stripped
everything and symbols didn't strip anything.

We now correctly pass `--strip-debug` and `--strip-all`.
2025-01-07 20:22:48 +01:00
Pietro Albini
c09561c7f0
update version placeholders 2025-01-07 20:22:42 +01:00
Matthias Krüger
0053aa4e9d
Rollup merge of #135049 - cramertj:rmunused, r=compiler-errors
Remove unused fields from RepeatElementCopy obligation
2025-01-03 07:57:27 +01:00
Matthias Krüger
e0f4dc955a
Rollup merge of #135042 - lukas-code:taint-dyn-incompat, r=compiler-errors
taint fcx on selection errors during unsizing

With `feature(dyn_compatible_for_dispatch)` we only check for dyn-compatibility by checking the `T: Unsize<dyn Trait>` predicate during the unsizing coercions checks. If the predicate doesn't hold, we emit an error, but pretend the coercion succeeded to prevent further errors. To prevent const eval from attempting to actually perform this coercion, we need to taint the fcx after reporting the trait errors in the coercion check.

fixes https://github.com/rust-lang/rust/issues/135021
fixes https://github.com/rust-lang/rust/issues/130521
2025-01-03 07:57:26 +01:00
Matthias Krüger
8439ae7422
Rollup merge of #131729 - Urgau:check-cfg-test-userspace, r=petrochenkov
Make the `test` cfg a userspace check-cfg

This PR implements MCP https://github.com/rust-lang/compiler-team/issues/785, which makes the `test` cfg a "userspace" check-cfg, i.e. no longer included in the well known cfg list.

Things to do:

- [x] Accept the MCP (https://github.com/rust-lang/compiler-team/issues/785#issuecomment-2424121886)
- [x] Mark `test` in Cargo (https://github.com/rust-lang/cargo/pull/14963)

`@rustbot` labels +S-waiting-on-MCP +F-check_cfg
r? `@petrochenkov`
2025-01-03 07:57:24 +01:00
Taylor Cramer
9281be94b5 Remove unused fields from RepeatElementCopy obligation 2025-01-02 14:46:36 -08:00
Lukas Markeffsky
93bb639ad6 taint fcx on selection errors during unsizing 2025-01-02 19:16:00 +01:00
Urgau
e8a4792b3e Make the test cfg a "userspace" check-cfg 2025-01-02 16:49:55 +01:00
Flakebi
56bf673f0a
Remove range-metadata amdgpu workaround
Range metadata was disabled for amdgpu due to a backend bug. I did not
encounter any problems when removing the workaround to enable range
metadata (tried compiling `core` and `alloc`), so I assume this has
been fixed in LLVM in the last years.

Remove the workaround to re-enable range metadata.
2025-01-02 15:45:04 +01:00
bors
504f4f5275 Auto merge of #130060 - EnzymeAD:enzyme-cg-llvm, r=oli-obk
Autodiff Upstreaming - rustc_codegen_llvm changes

Now that the autodiff/Enzyme backend is merged, this is an upstream PR for the `rustc_codegen_llvm` changes.
It also includes small changes to three files under `compiler/rustc_ast`, which overlap with my frontend PR (https://github.com/rust-lang/rust/pull/129458).
Here I only include minimal definitions of structs and enums to be able to build this backend code.
The same goes for minimal changes to `compiler/rustc_codegen_ssa`, the majority of changes there will be in another PR, once either this or the frontend gets merged.

We currently have 68 files left to merge, 19 in the frontend PR, 21 (+3 from the frontend) in this PR, and then ~30 in the middle-end.

This PR is large because it includes two of my three large files (~800 loc each). I could also first only upstream enzyme_ffi.rs, but I think people might want to see some use of these bindings in the same PR?

To already highlight the things which reviewers might want to discuss:

1) `enzyme_ffi.rs`: I do have a fallback module to make sure that we don't link rustc against Enzyme when we build rustc without autodiff support.

2) `add_panic_msg_to_global` was a pain to write and I currently can't even use it. Enzyme writes gradients into shadow memory. Pass in one float scalar? We'll allocate and return an extra float telling you how this float affected the output. Pass in a slice of floats? We'll let you allocate the vector and pass in a mutable reference to a float slice, we'll then write the gradient into that slice. It should be at least as large as your original slice, so we check that and panic if not. Currently we panic silently, but I already generate a nicer panic message with this function. I just don't know how to print it to the user. yet. I discussed this with a few rustc devs and the best we could come up with (for now), was to look for mangled panic calls in the IR and pick one, which works surprisingly reliably. If someone knows a good way to clean this up and print the panic message I'm all in, otherwise I can remove the code that writes the nicer panic message and keep the silent panic, since it's enough for soundness. Especially since this PR is already a bit larger.

3) `SanitizeHWAddress`: When differentiating C++, Enzyme can use TBAA to "understand" enums/unions, but for Rust we don't have this information. LLVM might to speculative loads which (without TBAA) confuse Enzyme, so we disable those with this attribute. This attribute is only set during the first opt run before Enzyme differentiates code. We then remove it again once we are done with autodiff and run the opt pipeline a second time. Since enums are everywhere in Rust, support for them is crucial, but if this looks too cursed I can remove these ~100 lines and keep them in my fork for now, we can then discuss them separately to make this PR simpler?

4) Duplicated llvm-opt runs: Differentiating already optimized code (and being able to do additional optimizations on the fly, e.g. for GPU code) is _the_ reason why Enzyme is so fast, so the compile time is acceptable for autodiff users:  https://enzyme.mit.edu/talks/Publications/ (There are also algorithmic issues in Enzyme core which are more serious than running opt twice).

5) I assume that if we merge these minimal cg_ssa changes here already, I also need to fix the other backends (GCC and cliff) to have dummy implementations, correct?

6) *I'm happy to split this PR up further if reviewers have recommendations on how to.*

For the full implementation, see: https://github.com/rust-lang/rust/pull/129175

Tracking:

- https://github.com/rust-lang/rust/issues/124509
2025-01-02 00:20:57 +00:00
Matthias Krüger
92dbfcc2c0
Rollup merge of #135000 - compiler-errors:opaque-captures-dupe, r=lqd
Fix ICE when opaque captures a duplicated/invalid lifetime

See description on test.

Fixes #132766
Fixes #133693
Fixes #134780
2025-01-01 22:04:18 +01:00
Matthias Krüger
fa5acdc36f
Rollup merge of #134984 - compiler-errors:obligation-tweaks, r=lqd
`ObligationCause` construction tweaks in typeck

Mostly just consolidating the way we construct obligations in `FnCtxt`.
2025-01-01 22:04:17 +01:00
Manuel Drehwald
d753cbf779 upstream rustc_codegen_llvm changes for enzyme/autodiff 2025-01-01 21:42:45 +01:00
Michael Goulet
d3c6067275 Fix ICE when opaque captures a duplicated/invalid lifetime 2025-01-01 19:32:51 +00:00
Stuart Cook
65cb7c66d0
Rollup merge of #134979 - estebank:default-lint-sugg, r=compiler-errors
Provide structured suggestion for `impl Default` of type where all fields have defaults

```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:28:1
   |
LL | / impl Default for B {
LL | |     fn default() -> Self {
LL | |         B {
LL | |             x: s(),
   | |                --- this field has a default value
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
help: to avoid divergence in behavior between `Struct { .. }` and `<Struct as Default>::default()`, derive the `Default`
   |
LL ~ #[derive(Default)] struct B {
   |
```

Note that above the structured suggestion also includes completely removing the manual `impl`, but the rendering doesn't.
2025-01-01 16:35:32 +11:00
Stuart Cook
f91bfd97bf
Rollup merge of #134945 - compiler-errors:map-mutate-nits, r=estebank
Some small nits to the borrowck suggestions for mutating a map through index

1. Suggesting users to either use `.insert` or `.get_mut` (which do totally different things) can be a bit of a footgun, so let's make that a bit more nuanced.
2. I find the suggestion of `.get_mut(|val| { *val = whatever; })` to be a bit awkward. I changed this to be an if-let instead.
3. Fix a bug which was suppressing the structured suggestion for some mutations via the index operator on `HashMap`/`BTreeMap`.

r? estebank or reassign
2025-01-01 16:35:31 +11:00
Stuart Cook
1ea1db5b08
Rollup merge of #134877 - DavisRayM:129966-format-string-help-message, r=estebank
add suggestion for wrongly ordered format parameters

Add suggestion for wrongly ordered format parameters like `?#`.

Supersedes #131004
Fix #129966
2025-01-01 16:35:30 +11:00