summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/sty.rs
AgeCommit message (Collapse)AuthorLines
2023-05-14Erase ReError properlyMichael Goulet-1/+3
2023-05-13Rollup merge of #110454 - oli-obk:limited_impl_trait_in_assoc_type, ↵Dylan DPC-1/+1
r=compiler-errors Require impl Trait in associated types to appear in method signatures This implements the limited version of TAIT that was proposed in https://github.com/rust-lang/rust/issues/107645#issuecomment-1477899536 Similar to `impl Trait` in return types, `impl Trait` in associated types may only be used within the impl block which it is a part of. To make everything simpler and forward compatible to getting desugared to a plain type alias impl trait in the future, we're requiring that any associated functions or constants that want to register hidden types must be using the associated type in their signature (type of the constant or argument/return type of the associated method. Where bounds mentioning the associated type are ignored). We have preexisting tests checking that this works transitively across multiple associated types in situations like ```rust impl Foo for Bar { type A = impl Trait; type B = impl Iterator<Item = Self::A>; fn foo() -> Self::B { ...... } } ```
2023-05-12Use the opaque_types_defined_by query to cheaply check for whether a hidden ↵Oli Scherer-1/+1
type may be registered for an opaque type
2023-05-12Don't ICE in layout computation for placeholder typesMichael Goulet-4/+2
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-10/+41
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-21/+53
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-03Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3Manish Goregaokar-0/+7
Add cross-language LLVM CFI support to the Rust compiler This PR adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto). Thank you again, ``@bjorn3,`` ``@nikic,`` ``@samitolvanen,`` and the Rust community for all the help!
2023-05-03Add cross-language LLVM CFI support to the Rust compilerRamon de C Valle-0/+7
This commit adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-04-27Rollup merge of #110838 - nnethercote:more-Folder-Visitable-cleanups, r=lcnrMatthias Krüger-1/+1
More `Typefoldable`/`TypeVisitable` cleanups r? ``@lcnr``
2023-04-26Don't return a `Binder` from `TraitRef::identity`Maybe Waffle-6/+2
2023-04-26Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle-0/+12
`ty::Binber::dummy` calls
2023-04-26Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle-4/+4
a `Span`
2023-04-26Remove unused `TypeFoldable`/`TypeVisitable` impls.Nicholas Nethercote-1/+1
2023-04-25vars are ?Michael Goulet-1/+1
2023-04-25Rename `TraitRef::{_use_mk_trait_ref_instead => _use_trait_ref_new_instead}`Maybe Waffle-3/+3
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-8/+13
2023-04-25Move `TraitRef` constructors to the topMaybe Waffle-14/+14
In rust `new`-ish functions are usually the first ones in an `impl` block
2023-04-25Add `ty::TraitRef::{new, from_lang_item}`Maybe Waffle-0/+19
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-13Remove some unused type folders.Nicholas Nethercote-77/+2
I'm surprised the compiler doesn't warn about these. It appears having an `impl` on a struct is enough to avoid a warning about it never being constructed.
2023-04-13Make `Region::as_var` infallible.Nicholas Nethercote-3/+3
It's what all the call sites require.
2023-04-11Add `sym::anon`.Nicholas Nethercote-1/+1
2023-04-11Introduce `Region::get_name_or_anon`.Nicholas Nethercote-5/+10
For a common pattern.
2023-04-10Auto merge of #108698 - IntQuant:issue-100717-infer-6, r=davidtwcobors-8/+24
Migrating rustc_infer to session diagnostics (part 5) `@rustbot` label +A-translation cc https://github.com/rust-lang/rust/issues/100717
2023-04-10Call `into_diagnostic_arg` on Binder's contained value directly.IQuant-3/+21
2023-04-09Remove identity castsNilstrieb-1/+1
2023-04-07Add a size assertion for `RegionKind`.Nicholas Nethercote-4/+11
2023-04-06Remove u32 on BoundTyKind::AnonJack Huey-2/+2
2023-04-06Remove index from BrAnonJack Huey-1/+1
2023-04-06Remove expect_anon and expect_anon_placeholder in favor of varJack Huey-18/+0
2023-04-06Use BoundTy and BoundRegion instead of kind of PlaceholderTy and ↵Jack Huey-2/+2
PlaceholderRegion
2023-04-04A more general implementation of `IntoDiagnosticArg` for `Binder` (Also ↵IQuant-13/+11
removes `DiagArg`, as it's no longer necessary)
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-2/+2
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-3/+2
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-22Rollup merge of #109378 - MU001999:master, r=scottmcmMatthias Krüger-6/+1
Remove Ty::is_region_ptr Fixes #109372
2023-03-21Deduplicate fn trait compatibility checksOli Scherer-1/+13
2023-03-20Remove Ty::is_region_ptrMu42-6/+1
2023-03-15Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fnSantiago Pastorino-1/+1
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-1/+1
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-03canonicalizationlcnr-0/+9
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-24Rename many interner functions.Nicholas Nethercote-8/+8
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obkMatthias Krüger-1/+1
Use associated type bounds in some places in the compiler Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think? Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-22Remove type-traversal trait aliasesAlan Egerton-11/+12
2023-02-21address reviewb-naber-1/+1
2023-02-21Associated type bounds in some places in the compilerMichael Goulet-1/+1
2023-02-19collect region contexts during mir renumberingb-naber-0/+7
2023-02-17Don't eagerly convert principal to stringclubby789-0/+6
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-1/+1
in metadata
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-1/+1
Much like there are specialized variants of `mk_ty`. This will enable some optimization in the next commit. Also rename the existing `re_error*` functions as `mk_re_error*`, for consistency.