1
Fork 0

Store the laziness of type aliases in the DefKind

This commit is contained in:
León Orell Valerian Liehr 2023-08-06 23:02:27 +02:00
parent 34ccd04859
commit 5468336d6b
No known key found for this signature in database
GPG key ID: D17A07215F68E713
49 changed files with 208 additions and 93 deletions

View file

@ -700,7 +700,10 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
// These items live in the type namespace.
ItemKind::TyAlias(..) => {
let res = Res::Def(DefKind::TyAlias, def_id);
let res = Res::Def(
DefKind::TyAlias { lazy: self.r.tcx.features().lazy_type_alias },
def_id,
);
self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion));
}
@ -948,7 +951,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
DefKind::Struct
| DefKind::Union
| DefKind::Variant
| DefKind::TyAlias
| DefKind::TyAlias { .. }
| DefKind::ForeignTy
| DefKind::OpaqueTy
| DefKind::TraitAlias

View file

@ -470,7 +470,7 @@ impl<'a> PathSource<'a> {
| DefKind::Enum
| DefKind::Trait
| DefKind::TraitAlias
| DefKind::TyAlias
| DefKind::TyAlias { .. }
| DefKind::AssocTy
| DefKind::TyParam
| DefKind::OpaqueTy
@ -509,7 +509,7 @@ impl<'a> PathSource<'a> {
DefKind::Struct
| DefKind::Union
| DefKind::Variant
| DefKind::TyAlias
| DefKind::TyAlias { .. }
| DefKind::AssocTy,
_,
) | Res::SelfTyParam { .. }
@ -1734,7 +1734,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
Res::Def(DefKind::Struct, def_id)
| Res::Def(DefKind::Union, def_id)
| Res::Def(DefKind::Enum, def_id)
| Res::Def(DefKind::TyAlias, def_id)
| Res::Def(DefKind::TyAlias { .. }, def_id)
| Res::Def(DefKind::Trait, def_id)
if i + 1 == proj_start =>
{

View file

@ -1422,7 +1422,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
err.span_label(span, fallback_label.to_string());
}
(Res::Def(DefKind::TyAlias, def_id), PathSource::Trait(_)) => {
(Res::Def(DefKind::TyAlias { .. }, def_id), PathSource::Trait(_)) => {
err.span_label(span, "type aliases cannot be used as traits");
if self.r.tcx.sess.is_nightly_build() {
let msg = "you might have meant to use `#![feature(trait_alias)]` instead of a \
@ -1591,7 +1591,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
err.span_label(span, fallback_label.to_string());
err.note("can't use `Self` as a constructor, you must use the implemented struct");
}
(Res::Def(DefKind::TyAlias | DefKind::AssocTy, _), _) if ns == ValueNS => {
(Res::Def(DefKind::TyAlias { .. } | DefKind::AssocTy, _), _) if ns == ValueNS => {
err.note("can't use a type alias as a constructor");
}
_ => return false,