Commit Graph

2416 Commits

Author SHA1 Message Date
GnomedDev
8de8f46f78 Swap PredicateObligation to ThinVec 2024-10-12 15:17:16 +01:00
GnomedDev
7ec06b0d1d Swap Vec<PredicateObligation> to type alias 2024-10-12 15:17:08 +01:00
Michael Goulet
8715bfbf0e Make super combine into fns 2024-10-10 06:07:52 -04:00
Michael Goulet
a4cd2202ef Use SolverRelating in favor of TypeRelating in the old solver where possible 2024-10-10 06:07:52 -04:00
Michael Goulet
30a2ecddb4 Remove unnecessary StructurallyRelateAliases from CombineFields/TypeRelating 2024-10-10 06:07:52 -04:00
Michael Goulet
3da257a98d Use SolverRelating in new solver 2024-10-10 06:07:52 -04:00
Michael Goulet
efb1c23ff6 Introduce SolverRelating 2024-10-10 06:07:51 -04:00
Michael Goulet
ce7a61b9d0 Uplift super_combine 2024-10-10 06:07:51 -04:00
Michael Goulet
09da2ebd63 Move ty::Error branch into super_combine_tys 2024-10-10 06:07:51 -04:00
Nicholas Nethercote
3b1eee7755 Remove unnecessary return keyword. 2024-10-08 16:28:58 +11:00
Nicholas Nethercote
1dac23f6fe Use Default more in InferCtxtInner. 2024-10-08 16:28:58 +11:00
Nicholas Nethercote
4df21f2ca0 Downgrade a &mut self to &self. 2024-10-08 16:28:58 +11:00
Nicholas Nethercote
8b05df44f9 Remove Deref/DerefMut impls for RegionConstraintCollector.
`Deref`/`DerefMut` can be useful, but they can also obfuscate. I don't
think they're worth it for `RegionConstraintCollector`. They're also not
present on the similar types `OpaqueTypeTable` and `TypeVariableTable`.
2024-10-08 16:28:58 +11:00
Nicholas Nethercote
e8a0bd6549 Remove unnecessary lifetime from LeakCheck.
`LeakCheck` can own `mini_graph` and `rcc` instead of holding references
to them. This requires inlining `assign_scc_value` to avoid a borrowck
error, but that's fine because it has a single call site.
2024-10-08 16:28:58 +11:00
Nicholas Nethercote
85507cffc3 Inline and remove RegionConstraintStorage::remove_constraint_entry.
It has a single call site.
2024-10-08 16:28:58 +11:00
Nicholas Nethercote
2b57a785a9 Inline and remove RegionConstraintCollector::into_infos_and_data.
It's a weird method, and used weirdly:
- It's on `RegionConstraintCollector` but operates on
  `RegionConstraintStorage`. So at both call sites we create a temporary
  `RegionConstraintCollector`, using `with_log`, to call it.
- It `take`s just two of the six fields in `RegionConstraintStorage`.
  At one of the two call sites we unnecessarily clone the entire
  `RegionConstraintStorage` just to take those two fields.

This commit just inlines and removes it. We no longer need to `take` the
two fields, we can just use them directly.
2024-10-08 16:28:58 +11:00
Nicholas Nethercote
0293827e09 Improve formatting of some comments.
I.e. fixing comments lines that are too long or too short.
2024-10-08 16:28:58 +11:00
Nicholas Nethercote
27dad009c6 Add a useful comment about InferOk.
Prompted by #131134, which tried to remove `InferOk<'tcx, ()>`
occurrences.
2024-10-08 16:27:44 +11:00
Nicholas Nethercote
abf212c16c Remove OutlivesEnvironmentBuilder.
`OutlivesEnvironment::new` can call `OutlivesEnvironment::with_bounds`
with an empty `extra_bounds`. And once that's done,
`OutlivesEnvironmentBuilder` has a single use and can be inlined and
removed into `OutlivesEnvironment::with_bounds`.
2024-10-08 16:27:44 +11:00
bors
3ae715c8c6 Auto merge of #131343 - compiler-errors:remove-combine-fields, r=lcnr
Remove `CombineFields`

This conflicts with #131263, but if this one lands first then perhaps #131263 could then go ahead and remove all the branching on solver in `TypeRelating`. We could perhaps then rename `TypeRelating` to `OldSolverRelating` or something, idk.

r? lcnr
2024-10-07 21:23:06 +00:00
Matthias Krüger
df61a0b1b2
Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errors
Avoid `&Lrc<T>` in various places

Seeing `&Lrc<T>` is a bit suspicious, and `&T` or `Lrc<T>` is often better.

r? `@oli-obk`
2024-10-07 12:23:54 +02:00
Michael Goulet
0c5d2f98d1 Remove At methods that are unused 2024-10-07 05:29:13 -04:00
Michael Goulet
5d62afd2ba Remove unnecessary DefineOpaqueTypes from lub 2024-10-07 05:29:13 -04:00
Michael Goulet
da71dfbc51 Inline CombineFields 2024-10-07 05:29:13 -04:00
Nicholas Nethercote
860cbccad9 Convert a &Lrc<T> argument to Lrc<T>.
It's slightly simpler.
2024-10-07 13:58:10 +11:00
Nicholas Nethercote
3fdcde76d9 Remove out-of-date comment. 2024-10-07 09:50:51 +11:00
Nicholas Nethercote
afbff05c84 Move a use statement so it's with the other use statements. 2024-10-07 09:50:51 +11:00
Nicholas Nethercote
e800967478 Simplify two matches.
Matches involving `GenericArgKind` pairs typically use a single `_` for
the impossible case. This commit shortens two verbose matches in this
way.
2024-10-07 09:50:51 +11:00
Nicholas Nethercote
3386530c91 Streamline next_*_var* methods.
Inline and remove `next_const_var_id`, `next_int_var_id`,
`next_float_var_id`, all of which have a single call site.
2024-10-07 09:50:51 +11:00
Nicholas Nethercote
deeb0c5cf3 Inline and remove InferCtxtBuilder::with_defining_opaque_types.
It has a single use.
2024-10-07 09:50:51 +11:00
Nicholas Nethercote
0ca4784c45 Fix FIXME comment on FixupError.
`FixupError` is isomorphic with `TyOrConstInferVar`, so this commit
changes it to just be a wrapper around `TyOrConstInferVar`.

Also, move the `Display` impl for `FixupError` next to `FixupError`.
2024-10-07 09:50:51 +11:00
Nicholas Nethercote
25d1ef1993 Remove InferCtxt::err_count_on_creation.
It's no longer used meaningfully.

This also means `DiagCtxtHandle::err_count_excluding_lint_errs` can be
removed.
2024-10-07 09:50:50 +11:00
Nicholas Nethercote
2d2755ff97 Reduce visibilities some more.
It helps people reading the code understand how widely things are used.
2024-10-07 09:50:50 +11:00
Nicholas Nethercote
5c015eed47 Remove unused UnitResult type. 2024-10-07 09:50:50 +11:00
Nicholas Nethercote
5486d72e77 Reduce visibilities.
Three of the modules don't need to be `pub`, and then
`warn(unreachable_pub)` identifies a bunch more things that also
shouldn't be `pub`, plus a couple of things that are unused.
2024-10-07 09:50:50 +11:00
Nicholas Nethercote
7a9bbd05c4 Rename errors/mod.rs as errors.rs.
It's simpler, for this tiny module.
2024-10-07 09:50:50 +11:00
Nicholas Nethercote
cfeee7bcbf Remove unused features. 2024-10-07 09:50:49 +11: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
bors
7067e4aee4 Auto merge of #131191 - nnethercote:lattice_op, r=lcnr
Merge `glb` and `lub` modules

Tons of code is duplicated across them, and it's easy to factor that out.

r? `@lcnr`
2024-10-04 01:20:08 +00:00
Nicholas Nethercote
ee227dec8c Remove LatticeDir trait.
It's no longer necessary now that the `glb` and `lub` modules have been
merged.
2024-10-04 06:56:42 +10:00
Nicholas Nethercote
0aab10135d Merge rustc_infer::infer::relate::{glb,lub}.
Most of the code in these two modules is duplicated in the other module.
This commit eliminates the duplication by replacing them with a new
module `lattice_op`. The new `LatticeOpKind` enum is used to distinguish
between glb and lub in the few places where the behaviour differs.
2024-10-04 06:56:37 +10:00
bors
18b1161ec9 Auto merge of #130821 - lcnr:nalgebra-hang-2, r=compiler-errors
add caching to most type folders, rm region uniquification

Fixes the new minimization of the hang in nalgebra and nalgebra itself :3

this is a bit iffy, especially the cache in `TypeRelating`. I believe all the caches are correct, but it definitely adds some non-local complexity in places. The first commit removes region uniquification, reintroducing the ICE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/27. This does not affect coherence and I would like to fix this by introducing OR-region constraints

r? `@compiler-errors`
2024-10-02 19:21:44 +00:00
lcnr
1a04a317c4 review 2024-10-02 14:49:36 +02:00
lcnr
13881f5404 add caches to multiple type folders 2024-10-01 17:20:31 +02:00
Michael Goulet
d753aba3b3 Get rid of a_is_expected from ToTrace 2024-09-27 15:43:18 -04:00
Michael Goulet
4fb097a5de Instantiate binders when checking supertrait upcasting 2024-09-27 15:43:18 -04: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
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04: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
lcnr
7a57a74bf5 generalize: track relevant info in cache key 2024-09-10 15:21:57 +02:00