TypeNs contain module

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
Hayashi Mikihiro 2025-03-28 17:51:27 +09:00
parent a7dc60a2c4
commit 1b471ebfd5
5 changed files with 71 additions and 88 deletions

View file

@ -1648,7 +1648,8 @@ impl<'a> InferenceContext<'a> {
TypeNs::AdtId(AdtId::EnumId(_))
| TypeNs::BuiltinType(_)
| TypeNs::TraitId(_)
| TypeNs::TraitAliasId(_) => {
| TypeNs::TraitAliasId(_)
| TypeNs::ModuleId(_) => {
// FIXME diagnostic
(self.err_ty(), None)
}

View file

@ -10,7 +10,7 @@ use hir_def::{
expr_store::HygieneId,
generics::{TypeParamProvenance, WherePredicate, WherePredicateTypeTarget},
path::{GenericArg, GenericArgs, GenericArgsParentheses, Path, PathSegment, PathSegments},
resolver::{ModuleOrTypeNs, ResolveValueResult, TypeNs, ValueNs},
resolver::{ResolveValueResult, TypeNs, ValueNs},
type_ref::{TypeBound, TypeRef, TypesMap},
};
use smallvec::SmallVec;
@ -285,7 +285,9 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
TypeNs::BuiltinType(it) => self.lower_path_inner(it.into(), infer_args),
TypeNs::TypeAliasId(it) => self.lower_path_inner(it.into(), infer_args),
// FIXME: report error
TypeNs::EnumVariantId(_) => return (TyKind::Error.intern(Interner), None),
TypeNs::EnumVariantId(_) | TypeNs::ModuleId(_) => {
return (TyKind::Error.intern(Interner), None);
}
};
self.skip_resolved_segment();
@ -316,6 +318,9 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
TypeNs::BuiltinType(_) => {
prohibit_generics_on_resolved(GenericArgsProhibitedReason::PrimitiveTy)
}
TypeNs::ModuleId(_) => {
prohibit_generics_on_resolved(GenericArgsProhibitedReason::Module)
}
TypeNs::AdtId(_)
| TypeNs::EnumVariantId(_)
| TypeNs::TypeAliasId(_)
@ -338,10 +343,6 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
.resolver
.resolve_path_in_type_ns_with_prefix_info(self.ctx.db.upcast(), self.path)?;
let ModuleOrTypeNs::TypeNs(resolution) = resolution else {
return None;
};
let segments = self.segments;
if segments.is_empty() || matches!(self.path, Path::LangItem(..)) {
// `segments.is_empty()` can occur with `self`.