rust/compiler/rustc_middle/src/ty
bors 0cc541e4b2 Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errors
Add `AliasKind::Weak` for type aliases.

`type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a

```rust
trait Identity {
    type Identity;
}
impl<T: Debug> Identity for T {
    type Identity = T;
}
<NotDebug as Identity>::Identity
```

type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer.

Similarly:

* a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes
* rustdoc expands the type alias, even though often times users use them for documentation purposes
* diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about.

For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident.

To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition.

Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds.

As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did.

fixes https://github.com/rust-lang/rust/issues/108617
2023-06-17 00:33:29 +00:00
..
consts Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
context Don't leak the function that is called on drop 2023-05-23 14:53:36 +00:00
inhabitedness EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
print Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
_match.rs Rename super_relate_* to structurally_relate_* 2023-05-15 16:40:42 +00:00
abstract_const.rs Rename const error methods for consistency 2023-05-14 20:32:51 +00:00
adjustment.rs Update ty::VariantDef to use IndexVec<FieldIdx, FieldDef> 2023-03-30 09:23:40 -07:00
adt.rs EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
assoc.rs Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
binding.rs Refactor and re-use BindingAnnotation 2022-09-02 12:55:05 -05:00
cast.rs Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
closure.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
codec.rs Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
consts.rs EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
context.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
diagnostics.rs change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
erase_regions.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
error.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
fast_reject.rs Spelling - compiler 2023-04-17 16:09:18 -04:00
flags.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
fold.rs Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
generics.rs Rollup merge of #112060 - lcnr:early-binder, r=jackh726 2023-05-30 12:57:40 +02:00
impls_ty.rs Derive HashStable on GenericArgKind instead of implementing it by hand 2023-04-20 19:52:37 +00:00
instance.rs cleanup some skip_binder -> subst_identity 2023-06-05 18:40:36 -06:00
layout.rs Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
list.rs correct literals for dyn thread safe 2023-05-06 09:34:53 +08:00
mod.rs Make assumption functions in new solver take clause 2023-06-15 16:18:38 +00:00
normalize_erasing_regions.rs Require impl Trait in associated types to appear in method signatures 2023-05-12 10:24:03 +00:00
opaque_types.rs Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
parameterized.rs Remember names of cfg-ed out items to mention them in diagnostics 2023-06-01 19:17:19 +02:00
relate.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
rvalue_scopes.rs rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
structural_impls.rs better TyKind::Debug 2023-05-26 18:55:02 +01:00
sty.rs Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
subst.rs EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
trait_def.rs Remove find_map_relevant_impl 2023-04-19 02:01:55 +00:00
typeck_results.rs Check that RPITs are compatible with the opaques inferred during HIR typeck too 2023-05-31 17:45:45 +00:00
util.rs Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin 2023-06-08 12:36:17 +02:00
visit.rs IAT: Introduce AliasKind::Inherent 2023-05-04 16:59:10 +02:00
vtable.rs Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
walk.rs Remove as_substs usage 2023-04-18 17:38:28 +00:00