Commit Graph

122 Commits

Author SHA1 Message Date
Michael Goulet 9a1c5eb5b3 Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
Ralf Jung e023590de4 make no-variant types a dedicated Variants variant 2024-12-18 11:01:54 +01:00
Ben Kimock 711c8cc690 Remove polymorphization 2024-12-06 16:42:09 -05:00
lcnr 9cba14b95b use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current
assumptions, but also the currentnphase of the compiler. This is
mostly necessary as we need to decide whether and how to reveal
opaque types. We track this via the `TypingMode`.
2024-11-18 10:38:56 +01:00
Jubilee Young b895bf4fdc compiler: Directly use rustc_abi in codegen 2024-11-03 12:30:32 -08:00
Deadbeef f6fea83342 Effects cleanup
- removed extra bits from predicates queries that are no longer needed in the new system
- removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-26 10:19:07 +08:00
Michael Goulet e83e4e8112 Get rid of const eval_* and try_eval_* helpers 2024-10-19 18:07:35 +00:00
Michael Goulet 914193c8f4 Do not unnecessarily eval consts in codegen 2024-09-20 20:38:11 -04:00
Nicholas Nethercote ae1f092307 Streamline coroutine_kind_label. 2024-09-17 16:24:35 +10:00
Nicholas Nethercote cd3da000c0 Clean up formatting.
Reflow overly long comments, plus some minor whitespace improvements.
2024-09-17 16:24:35 +10:00
Nicholas Nethercote bdacdfe95f Minimize visibilities.
This makes it much clearer which things are used outside the crate.
2024-09-17 16:24:33 +10:00
Michael Goulet af8d911d63 Also fix if in else 2024-09-11 17:24:01 -04:00
Alexander Cyon ac69544a17 chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
bors 026e9ed3f0 Auto merge of #128037 - beetrees:repr128-c-style-use-natvis, r=michaelwoerister
Use the `enum2$` Natvis visualiser for repr128 C-style enums

Use the preexisting `enum2$` Natvis visualiser to allow PDB debuggers to display fieldless `#[repr(u128)]]`/`#[repr(i128)]]` enums correctly.

Tracking issue: #56071

try-job: x86_64-msvc
2024-08-15 09:17:24 +00:00
beetrees fe4fa2f1da Use the enum2$ Natvis visualiser for repr128 C-style enums 2024-08-13 19:53:21 +01:00
Nicholas Nethercote c4717cc9d1 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.
2024-08-09 14:33:25 +10:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Jubilee Young ce7b069fd8 compiler: Never debug_assert in codegen
The gains in performance are not worth the costs in correctness.
This is partly because the gains are zero and the costs are unknown.
2024-07-20 00:16:44 -07:00
Boxy a9702a6668 Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
Boxy 58feec9b85 Basic removal of Ty from places (boring) 2024-06-05 22:25:38 +01:00
Michael Goulet 273b990554 Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
Santiago Pastorino 6b46a919e1 Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
Nicholas Nethercote 99e036bd21 Remove extern crate rustc_middle from numerous crates. 2024-04-29 14:50:45 +10:00
Oli Scherer 84acfe86de Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
Michael Goulet ff0c31e6b9 Programmatically convert some of the pat ctors 2024-03-22 11:13:29 -04:00
Oli Scherer adda9da604 Avoid various uses of Option<Span> in favor of using DUMMY_SP in the few cases that used None 2024-03-18 09:34:08 +00:00
Michael Goulet c567eddec2 Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
bors 1ab783112a Auto merge of #119258 - compiler-errors:closure-kind, r=eholk
Make closures carry their own ClosureKind

Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant.

This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine".

r? eholk
2023-12-26 04:25:53 +00:00
Michael Goulet 3320c09eab Only regular coroutines have movability 2023-12-25 21:13:41 +00:00
Nicholas Nethercote 99472c7049 Remove Session methods that duplicate DiagCtxt methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
2023-12-24 08:05:28 +11:00
Michael Goulet 004450506e Split coroutine desugaring kind from source 2023-12-22 23:58:29 +00:00
Michael Goulet 96bb542a31 Implement async gen blocks 2023-12-08 17:23:25 +00:00
Vadim Petrochenkov 17e799c270 rustc: Harmonize DefKind and DefPathData
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`.

`DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`.
It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change.

Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values.

`DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-03 16:24:56 +03:00
Nilstrieb 21a870515b Fix clippy::needless_borrow in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01:00
lcnr 40b154e53c rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`
- `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17 09:29:48 +00:00
Oli Scherer 14423080f1 Add hir::GeneratorKind::Gen 2023-10-26 07:10:25 +00:00
Oli Scherer af8a998b1e Rename AsyncCoroutineKind to CoroutineSource
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-25 16:14:05 +00:00
Oli Scherer 2d91c76d5d Rename CoroutineKind::Gen to ::Coroutine 2023-10-20 21:14:01 +00:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer 60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Camille GILLOT 44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Ralf Jung a2374e65aa the Const::eval_bits methods don't need to be given the Ty 2023-09-20 07:27:21 +02:00
bors 5e71913156 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
Deadbeef a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Ralf Jung 6e4779ab17 make the eval() functions on our const types return the resulting value 2023-09-13 07:29:34 +02:00
Matthias Krüger 3ce90b1649 inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
Mahdi Dibaiee e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Deadbeef 4f83717cf7 Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
Nicholas Nethercote 6b62f37402 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
Ben Kimock 0445fbdd83 Store hashes in special types so they aren't accidentally encoded as numbers 2023-04-18 10:52:47 -04:00