Commit graph

43374 commits

Author SHA1 Message Date
Michael Goulet
739ef83f31 Normalize vtable entries before walking and deduplicating them 2025-01-30 15:34:00 +00:00
Michael Goulet
fdc4bd22b7 Do not treat vtable supertraits as distinct when bound with different bound vars 2025-01-30 15:33:58 +00:00
Michael Goulet
37a430e6ea Remove print_vtable_sizes 2025-01-30 15:30:04 +00:00
Michael Goulet
08d7e9dfe5 Rework rustc_dump_vtable 2025-01-30 15:30:04 +00:00
Matthias Krüger
9b7af17d5b
Rollup merge of #136251 - hkBst:opt_imports, r=estebank
use impl Into<String> instead of explicit type args with bounds
2025-01-30 12:45:38 +01:00
Matthias Krüger
aab61ad663
Rollup merge of #136179 - oli-obk:push-vxvyttorquxw, r=BoxyUwU
Allow transmuting generic pattern types to and from their base

Pattern types always have the same size as their base type, so we can just ignore the pattern and look at the base type for figuring out whether transmuting is possible.
2025-01-30 12:45:32 +01:00
Matthias Krüger
78ded09912
Rollup merge of #135882 - hkBst:master, r=estebank
simplify `similar_tokens` from `Option<Vec<_>>` to `&[_]`

All uses immediately invoke contains, so maybe a further simplification is possible.
2025-01-30 12:45:27 +01:00
Matthias Krüger
aedc0a34a8
Rollup merge of #135739 - wesleywiser:dwarf_version_handling, r=lqd
Clean up uses of the unstable `dwarf_version` option

- Consolidate calculation of the effective value.
- Check the target `DebuginfoKind` instead of using `is_like_msvc`.
- Add the tracking issue to the unstable book page for this feature.

cc #103057
2025-01-30 12:45:21 +01:00
Matthias Krüger
a3663577f2
Rollup merge of #135434 - dianne:match-2024-for-edition-2024, r=Nadrieril
Match Ergonomics 2024: update edition 2024 behavior of feature gates

This updates the edition 2024 behavior of the feature gates `ref_pat_eat_one_layer_2024_structural` and `ref_pat_eat_one_layer_2024` to correspond to the left and right typing rules compared [here](https://nadrieril.github.io/typing-rust-patterns/?compare=true&opts2=AQEBAAABAQABAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=rules&do_cmp=true&ty_d=3&style=SequentBindingMode), respectively. I'll implement the proposed new behavior for editions ≤ 2021 in another PR.

The tests are split up a bit awkwardly for practical reasons, but I've added new tests from 3 places:
- I got tests for where the typing rules differ from the "Compare" tab of the page linked above. These had to be split up based on where the errors are emitted and how rustfixable they are, so they've ended up in different files to keep tidy. Within each file, though, the order of the tests matches the order the typing differences appear in that comparison (as of when this was written).
- I used [this other comparison](https://nadrieril.github.io/typing-rust-patterns/?q=%5B%26mut+%26%28mut+x%29%5D%3A+%26mut+%5B%26CT%5D&compare=true&opts2=AQEBAgABAQEBAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=compare&do_cmp=true&ty_d=3&style=SequentBindingMode) to test the `Deref(EatInner, FallbackToOuter)` rule of the left/"structural"/eat-inner ruleset. These are all in `well-typed-edition-2024.rs`.
- I added some select tests for cases where the new typing rules differ from current stable Rust. I had to be pickier about what I included here, but I tried to make sure each typing rule got some coverage. That said, my approach for these tests was a bit ad-hoc, so I may have missed something.

Relevant tracking issue: #123076

r? ````@ghost````
2025-01-30 12:45:18 +01:00
bors
5a45ab9738 Auto merge of #136038 - compiler-errors:outlives, r=lcnr
Simplify and consolidate the way we handle construct `OutlivesEnvironment` for lexical region resolution

This is best reviewed commit-by-commit. I tried to consolidate the API for lexical region resolution *first*, then change the API when it was finally behind a single surface.

r? lcnr or reassign
2025-01-30 11:40:32 +00:00
Hans Wennborg
6e457b88eb use Attribute::getWithCaptureInfo 2025-01-30 12:30:14 +01:00
Hans Wennborg
23fb08bb53 LLVM changed the nocapture attribute to captures(none)
This updates RustWrapper.cpp and tests after
https://github.com/llvm/llvm-project/pull/123181
2025-01-30 11:22:46 +01:00
Bastian Kersting
851322b74d Refactor PointerFinder into a separate module
This also parameterize the "excluded pointee types" and exposes a
general method for inserting checks on pointers.

This is a preparation for adding a NullCheck that makes use of the same
code.
2025-01-30 10:08:37 +00:00
Rémy Rakic
d781933812 add constraint graph to polonius MIR dump 2025-01-30 06:17:53 +00:00
Wesley Wiser
51eaa0d56a Clean up uses of the unstable dwarf_version option
- Consolidate calculation of the effective value.
- Check the target `DebuginfoKind` instead of using `is_like_msvc`.
2025-01-29 21:44:21 -06:00
Manuel Drehwald
1f30517d40 upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiff 2025-01-29 21:31:13 -05:00
bors
5e5567993d Auto merge of #136035 - SpecificProtagonist:miri-zeroed-alloc, r=oli-obk
miri: optimize zeroed alloc

When allocating zero-initialized memory in MIR interpretation, rustc allocates zeroed memory, marks it as initialized and then re-zeroes it. Remove the last step.

I don't expect this to have much of an effect on performance normally, but in my case in which I'm creating a large allocation via mmap it gets in the way.
2025-01-30 01:27:21 +00:00
Nicholas Nethercote
022c0ce947 Remove NamedVarMap.
`NamedVarMap` is extremely similar to `ResolveBoundVars`. The former
contains two `UnordMap<ItemLocalId, T>` fields (obscured behind
`ItemLocalMap` typedefs). The latter contains two
`SortedMap<ItemLocalId, T>` fields. We construct a `NamedVarMap` and
then convert it into a `ResolveBoundVars` by sorting the `UnordMap`s,
which is unnecessary busywork.

This commit removes `NamedVarMap` and constructs a `ResolveBoundVars`
directly. `SortedMap` and `NamedVarMap` have slightly different
perf characteristics during construction (e.g. speed of insertion) but
this code isn't hot enough for that to matter.

A few details to note.
- A `FIXME` comment is removed.
- The detailed comments on the fields of `NamedVarMap` are copied to
  `ResolveBoundVars` (which has a single, incorrect comment).
- `BoundVarContext::map` is renamed.
- `ResolveBoundVars` gets a derived `Default` impl.
2025-01-30 09:39:52 +11:00
bors
ae5de6c759 Auto merge of #134248 - oli-obk:patkind-path-removal, r=BoxyUwU
Merge `PatKind::Path` into `PatKind::Expr`

Follow-up to #134228

We always had a duplication where `Path`s could be represented as `PatKind::Path` or `PatKind::Lit(ExprKind::Path)`. We had to handle both everywhere, and still do after #134228, so I'm removing it now.
2025-01-29 19:16:29 +00:00
bors
0cc4f4f7b8 Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #133382 (Suggest considering casting fn item as fn pointer in more cases)
 - #136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - #136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - #136192 (ci: remove unused windows runner)
 - #136205 (Properly check that array length is valid type during built-in unsizing in index)
 - #136211 (Update mdbook to 0.4.44)
 - #136212 (Tweak `&mut self` suggestion span)
 - #136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 16:18:29 +00:00
Oli Scherer
559648a0a4 Handle all PatExprs in dead code analysis 2025-01-29 15:45:13 +00:00
Oli Scherer
f47ad71059 Eliminate PatKind::Path 2025-01-29 15:45:13 +00:00
Matthias Krüger
c941b1c5fc
Rollup merge of #136214 - momvart:driver_callback_crate_mut, r=bjorn3
Make crate AST mutation accessible for driver callback

Following  #134130, this brings back the ability to mutate AST before lowering.
2025-01-29 15:29:51 +01:00
Matthias Krüger
1f6a9aacee
Rollup merge of #136212 - estebank:span-tweak, r=petrochenkov
Tweak `&mut self` suggestion span

```
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
  --> $DIR/issue-38147-1.rs:17:9
   |
LL |         self.s.push('x');
   |         ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: consider changing this to be a mutable reference
   |
LL |     fn f(&mut self) {
   |           +++
```

Note the suggestion to add `mut` instead of replacing the entire `&self` with `&mut self`.
2025-01-29 15:29:49 +01:00
Matthias Krüger
e8289d801c
Rollup merge of #136205 - compiler-errors:len-3, r=BoxyUwU
Properly check that array length is valid type during built-in unsizing in index

This results in duplicated errors, but this class of errors is not new; in general, we aren't really equipped to detect cases where a WF error due to a field type would be shadowed by the parent struct of that field also not being WF.

This also adds a note for these types of mismatches to make it clear that this is due to an array type.

Fixes #134352

r? boxyuwu
2025-01-29 15:29:41 +01:00
Matthias Krüger
f8d103df43
Rollup merge of #133382 - mu001999-contrib:diag/fnitem, r=lcnr
Suggest considering casting fn item as fn pointer in more cases

Fixes #132648
2025-01-29 15:29:27 +01:00
bors
a1d7676d6a Auto merge of #136227 - fmease:rollup-ewpvznh, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #136121 (Deduplicate operand creation between scalars, non-scalars and string patterns)
 - #136134 (Fix SIMD codegen tests on LLVM 20)
 - #136153 (Locate asan-odr-win with other sanitizer tests)
 - #136161 (rustdoc: add nobuild typescript checking to our JS)
 - #136166 (interpret: is_alloc_live: check global allocs last)
 - #136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items)
 - #136170 (Reject unsound toggling of Arm atomics-32 target feature)
 - #136176 (Render pattern types nicely in mir dumps)
 - #136186 (uefi: process: Fix args)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 11:27:18 +00:00
Oli Scherer
a639e276f3 Allow transmuting generic pattern types to and from their base 2025-01-29 10:25:55 +00:00
Marijn Schouten
57cfcd228d use impl Into<String> 2025-01-29 09:48:08 +01:00
León Orell Valerian Liehr
f49ad60fee
Rollup merge of #136176 - oli-obk:pattern-type-mir-opts, r=compiler-errors
Render pattern types nicely in mir dumps

avoid falling through to the fallback rendering that just does a hex dump

r? ``@scottmcm``

best reviewed commit by commit
2025-01-29 06:03:24 +01:00
León Orell Valerian Liehr
0b1d717758
Rollup merge of #136170 - taiki-e:atomics-32, r=workingjubilee
Reject unsound toggling of Arm atomics-32 target feature

This target feature has the same semantics as RISC-V `forced-atomics` target feature that already marked as Forbidden  (f5ed0cb217) and toggling it can cause ABI incompatibility.

2f348cb7ce/compiler/rustc_target/src/target_features.rs (L479-L483)

[Comment on feature definition in LLVM](7109f52197/llvm/lib/Target/ARM/ARMFeatures.td (L572-L574)) also says:

> Code built with this feature is not ABI-compatible with code built without this feature, if atomic variables are exposed across the ABI boundary.

r? `@workingjubilee` or `@RalfJung`

`@rustbot` label +O-Arm
2025-01-29 06:03:24 +01:00
León Orell Valerian Liehr
e37b744bae
Rollup merge of #136168 - fmease:gci-fix-mono, r=compiler-errors
GCI: Don't try to eval / collect mono items inside overly generic free const items

Fixes #136156. Thanks for the pointers, errs!

There's one (preexisting) thing of note (maybe?). There's a difference between `const _: () = panic!();` and `const _<'a>: () = panic!();`: The former is a pre-mono error, the latter is a post-mono error. For comparison, both `fn _f() { const { panic!() } }` and `fn _f<'a: 'a>() { const { panic!() } }` are post-mono errors.

cc `@oli-obk`
r? compiler-errors or reassign
2025-01-29 06:03:23 +01:00
León Orell Valerian Liehr
bde47b7ae8
Rollup merge of #136166 - RalfJung:interpet-is-alloc-live, r=compiler-errors
interpret: is_alloc_live: check global allocs last

See https://github.com/rust-lang/rust/pull/136105#discussion_r1930609553.

(A perf run makes no sense as this is only used by Miri.)
2025-01-29 06:03:23 +01:00
León Orell Valerian Liehr
8d183d2b86
Rollup merge of #136121 - oli-obk:push-zzvxlynmnqpp, r=estebank
Deduplicate operand creation between scalars, non-scalars and string patterns

just something that felt duplicated and would make pattern type handling a bit more roundabout.
2025-01-29 06:03:20 +01:00
bors
ccc9ba5c30 Auto merge of #136225 - fmease:rollup-fm7m744, r=fmease
Rollup of 7 pull requests

Successful merges:

 - #135625 ([cfg_match] Document the use of expressions.)
 - #135902 (Do not consider child bound assumptions for rigid alias)
 - #135943 (Rename `Piece::String` to `Piece::Lit`)
 - #136104 (Add mermaid graphs of NLL regions and SCCs to polonius MIR dump)
 - #136143 (Update books)
 - #136147 (ABI-required target features: warn when they are missing in base CPU)
 - #136164 (Refactor FnKind variant to hold &Fn)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-29 05:00:20 +00:00
León Orell Valerian Liehr
28393070ab
Rollup merge of #136164 - celinval:chores-fnkind, r=oli-obk
Refactor FnKind variant to hold &Fn

Pulling the change suggested in #128045 to reduce the impact of changing `Fn` item.

r? `@oli-obk`
2025-01-29 03:12:22 +01:00
León Orell Valerian Liehr
7e123e4940
Rollup merge of #136147 - RalfJung:required-target-features-check-not-add, r=workingjubilee
ABI-required target features: warn when they are missing in base CPU

Part of https://github.com/rust-lang/rust/pull/135408:
instead of adding ABI-required features to the target we build for LLVM, check that they are already there. Crucially we check this after applying `-Ctarget-cpu` and `-Ctarget-feature`, by reading `sess.unstable_target_features`. This means we can tweak the ABI target feature check without changing the behavior for any existing user; they will get warnings but the target features behave as before.

The test changes here show that we are un-doing the "add all required target features" part. Without the full #135408, there is no way to take a way an ABI-required target feature with `-Ctarget-cpu`, so we cannot yet test that part.

Cc ``@workingjubilee``
2025-01-29 03:12:21 +01:00
León Orell Valerian Liehr
ee96bf2a94
Rollup merge of #136104 - lqd:polonius-debugger-episode-2, r=matthewjasper
Add mermaid graphs of NLL regions and SCCs to polonius MIR dump

This PR expands the polonius MIR dump again with a couple of mermaid charts ported from the graphviz version:
- the NLL region graph
- and the NLL SCCs

I still have done zero visual design on this until now, but [here's](https://gistpreview.github.io/?fbbf900fed2ad21108c7ca0353456398) how it looks (i.e. still bad) just to give an idea of the result.

r? `````@matthewjasper````` (feel free to reassign) or anyone
2025-01-29 03:12:20 +01:00
León Orell Valerian Liehr
dbb092b671
Rollup merge of #135943 - hkBst:opt_imports, r=estebank
Rename `Piece::String` to `Piece::Lit`

This renames Piece::String to Piece::Lit to avoid shadowing std::string::String and removes "pub use Piece::*;".
2025-01-29 03:12:19 +01:00
León Orell Valerian Liehr
42f46437ba
Rollup merge of #135902 - compiler-errors:item-non-self-bound-in-new-solver, r=lcnr
Do not consider child bound assumptions for rigid alias

r? lcnr

See first commit for the important details. For second commit, I also stacked a somewhat opinionated name change, though I can separate that if needed.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/149
2025-01-29 03:12:19 +01:00
bors
122fb29eb6 Auto merge of #136011 - compiler-errors:query-norm-vaniquishes-us, r=jackh726
Revert #135914: Remove usages of `QueryNormalizer` in the compiler

Reverts #135914.

r? jackh726
2025-01-29 02:12:12 +00:00
bors
bf1b174e7d Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #135869 (Make docs for AtomicUsize::from_mut platform-independent)
 - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`)
 - #136055 (Implement MIR const trait stability checks)
 - #136066 (Pass spans to `perform_locally_in_new_solver`)
 - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items)
 - #136124 (Arbitrary self types v2: explain test.)
 - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order)
 - #136173 (Update comments and sort target_arch in c_char_definition)
 - #136178 (Update username in build helper example)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-28 20:15:51 +00:00
Mohammad Omidvar
5dfe0f8cf4 Make crate AST mutation accessible for driver callback 2025-01-28 19:45:20 +00:00
Esteban Küber
130b0d294a Tweak &mut self suggestion span
```
error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference
  --> $DIR/issue-38147-1.rs:17:9
   |
LL |         self.s.push('x');
   |         ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: consider changing this to be a mutable reference
   |
LL |     fn f(&mut self) {
   |           +++
```

Note the suggestion to add `mut` instead of replacing the entire `&self` with `&mut self`.
2025-01-28 19:35:51 +00:00
Celina G. Val
c22a27130d Refactor FnKind variant to hold &Fn 2025-01-28 11:22:25 -08:00
Michael Goulet
8e0909d98a Move param env bound deep normalization to OutlivesEnvironment building 2025-01-28 19:11:05 +00:00
Michael Goulet
009d68740f Make item self/non-self bound naming less whack 2025-01-28 19:08:50 +00:00
Michael Goulet
3f8ce7c973 Do not assume child bound assumptions for rigid alias 2025-01-28 19:08:50 +00:00
Michael Goulet
48b7e38c06 Move outlives env computation into methods 2025-01-28 18:55:03 +00:00
Michael Goulet
2b8930c71c Consolidate OutlivesEnv construction with resolve_regions 2025-01-28 18:55:03 +00:00