Commit Graph

1929 Commits

Author SHA1 Message Date
Matthias Krüger
464f4057c2 fix some manual_map 2024-10-23 22:22:56 +02:00
Ralf Jung
ad3991d303 nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
bors
f2ba41113d Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwU
Continue to get rid of `ty::Const::{try_}eval*`

This PR mostly does:

* Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`.
* Remove `ty::Const::eval`.
* Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself.
* Fix some weirdness around the `TransmuteFrom` goal.

I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools.

r? BoxyUwU

Part of https://github.com/rust-lang/rust/issues/130704
2024-10-21 03:46:28 +00:00
Matthias Krüger
268fa31596
Rollup merge of #127675 - chenyukang:yukang-fix-127562-addr, r=petrochenkov
Remove invalid help diagnostics for const pointer

Partially addresses #127562
2024-10-19 22:00:55 +02:00
Michael Goulet
e83e4e8112 Get rid of const eval_* and try_eval_* helpers 2024-10-19 18:07:35 +00:00
lcnr
3360c1773a move defining_opaque_types out of Canonical 2024-10-17 10:22:52 +02:00
lcnr
f3ce557fcd DropckOutlives to rustc_middle 2024-10-17 09:53:27 +02:00
lcnr
9334d85e69 remove type_op constructors 2024-10-17 09:53:27 +02:00
lcnr
401f9b4e0a ImpliedOutlivesBounds to rustc_middle 2024-10-17 09:53:27 +02:00
VulnBandit
e3029abfae Improve duplicate derive Copy/Clone diagnostics 2024-10-16 16:49:31 +02:00
bors
d829780c4e Auto merge of #131481 - nnethercote:rm-GenKillSet, r=cjgillot
Remove `GenKillAnalysis`

There are two kinds of dataflow analysis in the compiler: `Analysis`, which is the basic kind, and `GenKillAnalysis`, which is a more specialized kind for gen/kill analyses that is intended as an optimization. However, it turns out that `GenKillAnalysis` is actually a  pessimization! It's faster (and much simpler) to do all the gen/kill analyses via `Analysis`. This lets us remove `GenKillAnalysis`, and `GenKillSet`, and a few other things, and also merge `AnalysisDomain` into `Analysis`. The PR removes 500 lines of code and improves performance.

r? `@tmiasko`
2024-10-16 09:45:05 +00:00
bors
9618da7c99 Auto merge of #131422 - GnomedDev:smallvec-predicate-obligations, r=compiler-errors
Use `ThinVec` for PredicateObligation storage

~~I noticed while profiling clippy on a project that a large amount of time is being spent allocating `Vec`s for `PredicateObligation`, and the `Vec`s are often quite small. This is an attempt to optimise this by using SmallVec to avoid heap allocations for these common small Vecs.~~

This PR turns all the `Vec<PredicateObligation>` into a single type alias while avoiding referring to `Vec` around it, then swaps the type over to `ThinVec<PredicateObligation>` and fixes the fallout. This also contains an implementation of `ThinVec::extract_if`, copied from `Vec::extract_if` and currently being upstreamed to https://github.com/Gankra/thin-vec/pull/66.

This leads to a small (0.2-0.7%) performance gain in the latest perf run.
2024-10-16 04:06:14 +00:00
Michael Goulet
7500e09b8b Move trait bound modifiers into hir::PolyTraitRef 2024-10-14 09:20:38 -04:00
Nicholas Nethercote
33abf6a0c8 Add defaults for Analysis::apply_{call_return_effect,terminator_effect}.
To avoid some low-value boilerplate code.
2024-10-14 16:35:47 +11:00
Nicholas Nethercote
ba13775319 Merge AnalysisDomain into Analysis.
With `GenKillAnalysis` gone, there is no need for them to be separate.
2024-10-14 16:35:47 +11:00
Nicholas Nethercote
4dc1b4d0b1 Remove GenKillAnalysis.
It's now functionally identical to `Analysis`.
2024-10-14 16:35:42 +11:00
Nicholas Nethercote
525f655866 Minimize use of GenKill.
Thanks to the previous couple of commits, many uses of the `GenKill`
trait can be replaced with a concrete type.
2024-10-14 16:35:28 +11:00
Nicholas Nethercote
13968b4a70 Tweak GenKillAnalysis method arguments.
`GenKillAnalysis` has very similar methods to `Analysis`, but the first
two have a notable difference: the second argument is `&mut impl
GenKill<Self::Idx>` instead of `&mut Self::Domain`. But thanks to the
previous commit, this difference is no longer necessary.
2024-10-14 16:35:28 +11:00
Trevor Gross
39071fdc58
Rollup merge of #131626 - matthiaskrgr:dont_string, r=lqd
remove a couple of redundant String to String conversion
2024-10-12 21:38:38 -05:00
Matthias Krüger
4bc21e318c remove a couple of redundant String to String conversion 2024-10-12 22:07:46 +02:00
GnomedDev
7ec06b0d1d Swap Vec<PredicateObligation> to type alias 2024-10-12 15:17:08 +01:00
Matthias Krüger
e5906e1591 yeet some clones 2024-10-12 10:59:12 +02:00
bors
249df9e791 Auto merge of #131444 - onur-ozkan:hotfix-ci, r=Kobzol
stabilize `ci_rustc_if_unchanged_logic` test

Makes `ci_rustc_if_unchanged_logic` test more stable and re-enables it. Previously, it was expecting CI-rustc to be used all the time when there were no changes, which wasn’t always the case. Purpose of this test is making sure we don't use CI-rustc while there are changes in compiler and/or library, but we don't really need to cover cases where CI-rustc is not enabled.

Second commit was pushed for making a change in the compiler tree, so `ci_rustc_if_unchanged_logic` can be tested properly in merge CI.
2024-10-10 23:51:17 +00:00
Michael Goulet
8715bfbf0e Make super combine into fns 2024-10-10 06:07:52 -04:00
Michael Goulet
ce7a61b9d0 Uplift super_combine 2024-10-10 06:07:51 -04:00
onur-ozkan
de744eafe1 update rustc_borrowck::places_conflict doc-comment
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-10-10 10:33:29 +03:00
Jubilee
9c4732a77d
Rollup merge of #131225 - nnethercote:rustc_borrowck-mm, r=lqd
`rustc_borrowck` memory management tweaks

Minor cleanups in `rustc_borrowck` relating to memory management.

r? `@lqd`
2024-10-07 11:10:54 -07:00
Folkert de Vries
5fc60d1e52 various fixes for naked_asm! implementation
- fix for divergence
- fix error message
- fix another cranelift test
- fix some cranelift things
- don't set the NORETURN option for naked asm
- fix use of naked_asm! in doc comment
- fix use of naked_asm! in run-make test
- use `span_bug` in unreachable branch
2024-10-06 19:00:09 +02:00
bors
5a4ee43c38 Auto merge of #129244 - cjgillot:opaque-hir, r=compiler-errors
Make opaque types regular HIR nodes

Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead.

I haven't gone through all the test changes yet, so there may be a few surprises.

Many thanks to `@camelid` for the first draft.
Fixes https://github.com/rust-lang/rust/issues/129023

Fixes #129099
Fixes #125843
Fixes #119716
Fixes #121422
2024-10-05 06:19:35 +00:00
Noah Lev
d6f247f3d5 rm ItemKind::OpaqueTy
This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
2024-10-04 23:28:22 +00:00
Jubilee
4778893968
Rollup merge of #131264 - compiler-errors:fix-pub-crate, r=jieyouxu
Fix some `pub(crate)` that were undetected bc of `#[instrument]`

Self-explanatory, minor clean up.
2024-10-04 14:11:39 -07:00
Jubilee
5a8fcab713
Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnay
Stabilize the `map`/`value` methods on `ControlFlow`

And fix the stability attribute on the `pub use` in `core::ops`.

libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP.

Summary:
```rust
impl<B, C> ControlFlow<B, C> {
    pub fn break_value(self) -> Option<B>;
    pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>;
    pub fn continue_value(self) -> Option<C>;
    pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>;
}
```

Resolves #75744

``@rustbot`` label +needs-fcp +t-libs-api -t-libs

---

Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04 14:11:34 -07:00
Michael Goulet
be2540a1f0 Fix some pub(crate) that were undetected bc of instrument 2024-10-04 14:02:09 -04:00
Nicholas Nethercote
c69d174311 Remove unnecessary lifetime in ConditionVisitor.
By making it own two of its fields.
2024-10-04 16:48:51 +10:00
Nicholas Nethercote
56e849ca21 Avoid &Rc<T> arguments.
Either `&T` or `Rc<T>` is preferable.
2024-10-04 16:48:19 +10:00
Nicholas Nethercote
d9975ce2b4 Avoid Rc in BodyWithBorrowckFacts.
It can own these two fields.
2024-10-04 16:48:16 +10:00
Nicholas Nethercote
3d7fe9e7dd Use Box instead of Rc for polonius_output.
Refcounting isn't needed.
2024-10-04 16:48:14 +10:00
Nicholas Nethercote
89e84c053d Use Rc less in MirBorrowckCtxt.
The `regioncx` and `borrow_set` fields can be references instead of
`Rc`. They use the existing `'a` lifetime. This avoids some heap
allocations and is a bit simpler.
2024-10-04 16:46:20 +10:00
Michael Goulet
7cd466a036 Move in_trait into OpaqueTyOrigin 2024-10-02 22:48:26 -04:00
Michael Goulet
cb7e3695e8 Use named fields for OpaqueTyOrigin 2024-10-02 22:04:18 -04:00
Michael Goulet
f95bdf453e Remove redundant in_trait from hir::TyKind::OpaqueDef 2024-10-02 21:59:55 -04:00
Rémy Rakic
98d6fdb242 make Borrows dataflow dumps about its loan domain 2024-10-02 00:30:50 +00:00
Lukas Markeffsky
53f45c4332 borrowck: use subtyping instead of equality for ptr-to-ptr casts 2024-09-27 21:04:32 +02:00
Scott McMurray
fd5aa07f4f Stabilize the map/value methods on ControlFlow
And fix the stability attribute on the `pub use` in `core::ops`.
2024-09-25 19:00:17 -07:00
bors
4c62024cd5 Auto merge of #130803 - cuviper:file-buffered, r=joshtriplett
Add `File` constructors that return files wrapped with a buffer

In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers.

ACP: https://github.com/rust-lang/libs-team/issues/446
Tracking Issue: #130804
2024-09-25 04:57:12 +00:00
Josh Stone
0999b019f8 Dogfood feature(file_buffered) 2024-09-24 14:25:16 -07:00
Lukas Markeffsky
bd31e3ed70 be even more precise about "cast" vs "coercion" 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
5e60d1f87e replace "cast" with "coercion" where applicable
This changes the remaining span for the cast, because the new `Cast`
category has a higher priority (lower `Ord`) than the old `Coercion`
category, so we no longer report the region error for the "unsizing"
coercion from `*const Trait` to itself.
2024-09-24 22:20:46 +02:00
Lukas Markeffsky
46ecb23198 unify dyn* coercions with other pointer coercions 2024-09-24 22:17:55 +02:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Eric Holk
7b7992fbcf
Begin experimental support for pin reborrowing
This commit adds basic support for reborrowing `Pin` types in argument
position. At the moment it only supports reborrowing `Pin<&mut T>` as
`Pin<&mut T>` by inserting a call to `Pin::as_mut()`, and only in
argument position (not as the receiver in a method call).
2024-09-18 12:36:31 -07:00
León Orell Valerian Liehr
03e8b6bbfa
Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr
Lifetime cleanups

The last commit is very opinionated, let's see how we go.

r? `@oli-obk`
2024-09-14 18:12:13 +02:00
Matthias Krüger
c5e0f9ae42
Rollup merge of #130297 - nnethercote:dataflow-cleanups, r=cjgillot
Dataflow cleanups

r? `@cjgillot`
2024-09-13 18:25:45 +02:00
Nicholas Nethercote
bb943f93ff Rename FlowState as Domain.
Because that's what it is; no point having a different name for it.
2024-09-13 16:27:24 +10:00
Nicholas Nethercote
8d32578fe1 Rename and reorder lots of lifetimes.
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and
  'me with vanilla 'a. These are cases where the original name isn't
  really any more informative than 'a.
- Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime
  applies to multiple fields and so the original lifetime name isn't
  really accurate.
- Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-13 15:46:20 +10:00
Nicholas Nethercote
606b9cb406 Rename some lifetimes.
Giving them more typical names.
2024-09-13 15:36:55 +10:00
bors
a5efa01895 Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxu
Rescope temp lifetime in if-let into IfElse with migration lint

Tracking issue #124085

This PR shortens the temporary lifetime to cover only the pattern matching and consequent branch of a `if let`.

At the expression location, means that the lifetime is shortened from previously the deepest enclosing block or statement in Edition 2021. This warrants an Edition change.

Coming with the Edition change, this patch also implements an edition lint to warn about the change and a safe rewrite suggestion to preserve the 2021 semantics in most cases.

Related to #103108.
Related crater runs: https://github.com/rust-lang/rust/pull/129466.
2024-09-13 03:47:30 +00:00
Stuart Cook
3ba12756d3
Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister
Simplify some nested `if` statements

Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if`

Review with whitespace disabled please.
2024-09-12 20:37:16 +10:00
Jubilee
a31a8fe0cf
Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errors
Remove needless returns detected by clippy in the compiler
2024-09-11 15:53:22 -07:00
Michael Goulet
af8d911d63 Also fix if in else 2024-09-11 17:24:01 -04:00
Michael Goulet
954419aab0 Simplify some nested if statements 2024-09-11 13:45:23 -04:00
Ding Xiang Fei
89682a5313
downgrade borrowck suggestion level due to possible span conflict 2024-09-11 04:10:04 +08:00
Ding Xiang Fei
f93df1f7dc
rescope temp lifetime in let-chain into IfElse
apply rules by span edition
2024-09-11 04:10:00 +08:00
Eduardo Sánchez Muñoz
0b20ffcb63 Remove needless returns detected by clippy in the compiler 2024-09-09 13:32:22 +02:00
Nicholas Nethercote
28a6dc4d1e Rename some lifetimes.
Give them the names used in most places.
2024-09-09 16:25:44 +10:00
Nicholas Nethercote
3fe7dd6893 Remove unnecessary lifetimes in dataflow structs.
There are four related dataflow structs: `MaybeInitializedPlaces`,
`MaybeUninitializedPlaces`, and `EverInitializedPlaces`,
`DefinitelyInitializedPlaces`. They all have a `&Body` and a
`&MoveData<'tcx>` field. The first three use different lifetimes for the
two fields, but the last one uses the same lifetime for both.

This commit changes the first three to use the same lifetime, removing
the need for one of the lifetimes. Other structs that also lose a
lifetime as a result of this are `LivenessContext`, `LivenessResults`,
`InitializationData`.

It then does similar things in various other structs.
2024-09-09 16:14:18 +10:00
Matthias Krüger
0180b8fff0
Rollup merge of #129969 - GrigorenkoPV:boxed-ty, r=compiler-errors
Make `Ty::boxed_ty` return an `Option`

Looks like a good place to use Rust's type system.

---

Most of 4ac7bcbaad/compiler/rustc_middle/src/ty/sty.rs (L971-L1963) looks like it could be moved to `TyKind` (then I guess  `Ty` should be made to deref to `TyKind`).
2024-09-06 07:33:58 +02:00
Matthias Krüger
e903b29dc3
Rollup merge of #129021 - compiler-errors:ptr-cast-outlives, r=lcnr
Check WF of source type's signature on fn pointer cast

This PR patches the implied bounds holes slightly for #129005, #25860.

Like most implied bounds related unsoundness fixes, this isn't complete w.r.t. higher-ranked function signatures, but I believe it implements a pretty good heuristic for now.

### What does this do?

This PR makes a partial patch for a soundness hole in a `FnDef` -> `FnPtr` "reifying" pointer cast where we were never checking that the signature we are casting *from* is actually well-formed. Because of this, and because `FnDef` doesn't require its signature to be well-formed (just its predicates must hold), we are essentially allowed to "cast away" implied bounds that are assumed within the body of the `FnDef`:

```
fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v }

fn bad<'short, T>(x: &'short T) -> &'static T {
    let f: fn(_, &'short T) -> &'static T = foo;
    f(&&(), x)
}
```

In this example, subtyping ends up casting the `_` type (which should be `&'static &'short ()`) to some other type that no longer serves as a "witness" to the lifetime relationship `'short: 'static` which would otherwise be required for this call to be WF. This happens regardless of if `foo`'s lifetimes are early- or late-bound.

This PR implements two checks:
1. We check that the signature of the `FnDef` is well-formed *before* casting it. This ensures that there is at least one point in the MIR where we ensure that the `FnDef`'s implied bounds are actually satisfied by the caller.
2. Implements a special case where if we're casting from a higher-ranked `FnDef` to a non-higher-ranked, we instantiate the binder of the `FnDef` with *infer vars* and ensure that it is a supertype of the target of the cast.

The (2.) is necessary to validate that these pointer casts are valid for higher-ranked `FnDef`. Otherwise, the example above would still pass even if `help`'s `'a` lifetime were late-bound.

### Further work

The WF checks for function calls are scattered all over the MIR. We check the WF of args in call terminators, we check the WF of `FnDef` when we create a `const` operand referencing it, and we check the WF of the return type in #115538, to name a few.

One way to make this a bit cleaner is to simply extend #115538 to always check that the signature is WF for `FnDef` types. I may do this as a follow-up, but I wanted to keep this simple since this leads to some pretty bad NLL diagnostics regressions, and AFAICT this solution is *complete enough*.

### Crater triage

Done here: https://github.com/rust-lang/rust/pull/129021#issuecomment-2297702647

r? lcnr
2024-09-06 07:33:56 +02:00
Pavel Grigorenko
f6e8a84eea Make Ty::boxed_ty return an Option 2024-09-06 00:30:36 +03:00
Michael Goulet
e8472e84e3 Check unnormalized signature on pointer cast 2024-09-05 06:37:38 -04:00
Folkert de Vries
49e3b9a2d2 fix ICE when asm_const and const_refs_to_static are combined 2024-09-04 20:06:38 +02:00
Folkert de Vries
f7679d0507 propagate tainted_by_errors in MirBorrowckCtxt::emit_errors 2024-09-04 20:06:33 +02:00
Alexander Cyon
ac69544a17
chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
Matthias Krüger
7d025bb63d
Rollup merge of #129767 - nnethercote:rm-extern-crate-tracing-4, r=jieyouxu
Remove `#[macro_use] extern crate tracing`, round 4

Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via #[macro_use]. Continuing the work from #124511, #124914, and #125434. After this PR no `rustc_*` crates use `#[macro_use] extern crate tracing` except for `rustc_codegen_gcc` which is a special case and I will do separately.

r? ```@jieyouxu```
2024-08-31 14:46:11 +02:00
Nicholas Nethercote
67556eca99 Remove #[macro_use] extern crate tracing from rustc_borrowck. 2024-08-30 17:14:53 +10:00
Rémy Rakic
dff3d3588d add borrows to NLL MIR dumps
explicitly disable `-Zmir-include-spans` in mir-opt tests

This will override the NLL default of true, and keep the blessed dumps
easier to work with.
2024-08-30 07:14:31 +00:00
Rémy Rakic
f3f5b4dcf2 refactor NLL MIR dump entry point 2024-08-30 07:14:31 +00:00
Rémy Rakic
92e1046502 enable extra comments in NLL MIR dumps 2024-08-30 07:14:31 +00:00
Matthias Krüger
53f5294c0f
Rollup merge of #129340 - stephen-lazaro:u/slazaro/issue-129274, r=compiler-errors
Remove Duplicate E0381 Label

Aims to resolve https://github.com/rust-lang/rust/issues/129274, and adds a test for the case.

Essentially, we are duplicating this span for some reason. For now, I'm just using a set to collect the spans rather than the vec. I imagine there's probably no real reason to inspect duplicates in this area, but if I'm wrong I can adjust to collect "seen spans" in just the point where this label is applied.

I'm not sure why it's producing duplicate spans. Looks like this has been this way for a while? I think it gives the duplicate label on 1.75.0 for example.
2024-08-27 00:42:00 +02:00
Matthias Krüger
110c3df7fd
Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates

By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal.

There are plenty more crates to do but this seems like enough for a first PR.

r? `@compiler-errors`
2024-08-27 00:41:57 +02:00
Matthias Krüger
d6a3aa4fc4
Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmease
Avoid taking reference of &TyKind

It's already a ref anyways. Just a tiny cleanup here.
2024-08-26 01:49:04 +02:00
Michael Goulet
48f43fa0ed Avoid taking reference of &TyKind 2024-08-25 16:02:29 -04:00
Stephen Lazaro
e91f32829c Deduplicate Spans in Uninitialized Check
Prevents reporting labels or diagnostics on spans that are produced
multiple times.
2024-08-22 09:36:14 -07:00
Michael Goulet
a97b41f188 Use subtyping for UnsafeFnPointer coercion, too 2024-08-19 21:26:10 -04:00
Ralf Jung
35709be02d rename AddressOf -> RawBorrow inside the compiler 2024-08-18 19:46:53 +02:00
Nicholas Nethercote
0685c97843 Add warn(unreachable_pub) to rustc_borrowck. 2024-08-16 08:46:57 +10:00
许杰友 Jieyou Xu (Joe)
2200910659
Rollup merge of #129059 - compiler-errors:subtyping-correct-type, r=lcnr
Record the correct target type when coercing fn items/closures to pointers

Self-explanatory. We were previously not recording the *target* type of a coercion as the output of an adjustment. This should remedy that.

We must also modify the function pointer casts in MIR typeck to use subtyping, since those broke since #118247.

r? lcnr
2024-08-14 21:43:08 +08:00
bors
e9c965df7b Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors
Shrink `TyKind::FnPtr`.

By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.

r? `@compiler-errors`
2024-08-14 00:56:53 +00:00
Michael Goulet
5df13af56f Use the right type when coercing fn items to pointers 2024-08-13 16:23:20 -04:00
Matthias Krüger
4c49418472
Rollup merge of #128712 - compiler-errors:normalize-borrowck, r=lcnr
Normalize struct tail properly for `dyn` ptr-to-ptr casting in new solver

Realized that the new solver didn't handle ptr-to-ptr casting correctly.

r? lcnr

Built on #128694
2024-08-12 23:10:50 +02:00
Guillaume Gomez
7c6dca9050
Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxu
Use `assert_matches` around the compiler more

It's a useful assertion, especially since it actually prints out the LHS.
2024-08-12 17:09:19 +02:00
Guillaume Gomez
ea74eff55c
Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote
Get rid of some `#[allow(rustc::untranslatable_diagnostic)]`

`@rustbot` label +A-translation
cc https://github.com/rust-lang/rust/issues/100717
2024-08-12 17:09:17 +02:00
Michael Goulet
b5d2079fb9 Rename normalization functions to raw 2024-08-11 19:40:03 -04:00
Michael Goulet
c5205e9d56 Normalize struct tail properly in borrowck and hir typeck 2024-08-11 19:40:03 -04:00
Michael Goulet
c361c924a0 Use assert_matches around the compiler 2024-08-11 12:25:39 -04:00
Matthias Krüger
32e0fe129d
Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler

Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'.

r? ghost
2024-08-11 07:51:51 +02:00
Pavel Grigorenko
f43cdcea22 rustc_borrowck: fmt 2024-08-10 14:32:56 +03:00
Pavel Grigorenko
1481ab3f75 rustc_borrowck: make "implicit static" suff translatable 2024-08-10 14:32:55 +03:00
Pavel Grigorenko
1b6cc24c20 rustc_borrowck: make some suggestion about static lifetimes translatable 2024-08-10 14:32:55 +03:00
Pavel Grigorenko
446e03e3c9 rustc_borrowck: make suggestion to move closure translatable 2024-08-10 14:32:55 +03:00