mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Lower const params with a bad id
This commit is contained in:
parent
68bdf609f3
commit
a481e004b0
38 changed files with 475 additions and 184 deletions
|
@ -42,9 +42,9 @@ use triomphe::Arc;
|
|||
|
||||
use crate::{
|
||||
db::HirDatabase, fold_tys, infer::coerce::CoerceMany, lower::ImplTraitLoweringMode,
|
||||
static_lifetime, to_assoc_type_id, traits::FnTrait, AliasEq, AliasTy, ClosureId, DomainGoal,
|
||||
GenericArg, Goal, ImplTraitId, InEnvironment, Interner, ProjectionTy, RpitId, Substitution,
|
||||
TraitEnvironment, TraitRef, Ty, TyBuilder, TyExt,
|
||||
static_lifetime, to_assoc_type_id, traits::FnTrait, utils::UnevaluatedConstEvaluatorFolder,
|
||||
AliasEq, AliasTy, ClosureId, DomainGoal, GenericArg, Goal, ImplTraitId, InEnvironment,
|
||||
Interner, ProjectionTy, RpitId, Substitution, TraitEnvironment, TraitRef, Ty, TyBuilder, TyExt,
|
||||
};
|
||||
|
||||
// This lint has a false positive here. See the link below for details.
|
||||
|
@ -102,6 +102,10 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer
|
|||
},
|
||||
});
|
||||
}
|
||||
DefWithBodyId::InTypeConstId(_) => {
|
||||
// FIXME: We should know the expected type here.
|
||||
ctx.return_ty = ctx.table.new_type_var();
|
||||
}
|
||||
}
|
||||
|
||||
ctx.infer_body();
|
||||
|
@ -684,7 +688,7 @@ impl<'a> InferenceContext<'a> {
|
|||
|
||||
fn collect_fn(&mut self, func: FunctionId) {
|
||||
let data = self.db.function_data(func);
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver, func.into())
|
||||
.with_impl_trait_mode(ImplTraitLoweringMode::Param);
|
||||
let mut param_tys =
|
||||
data.params.iter().map(|type_ref| ctx.lower_ty(type_ref)).collect::<Vec<_>>();
|
||||
|
@ -708,7 +712,7 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
let return_ty = &*data.ret_type;
|
||||
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver, self.owner.into())
|
||||
.with_impl_trait_mode(ImplTraitLoweringMode::Opaque);
|
||||
let return_ty = ctx.lower_ty(return_ty);
|
||||
let return_ty = self.insert_type_vars(return_ty);
|
||||
|
@ -823,7 +827,7 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
|
||||
fn make_ty(&mut self, type_ref: &TypeRef) -> Ty {
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver, self.owner.into());
|
||||
let ty = ctx.lower_ty(type_ref);
|
||||
let ty = self.insert_type_vars(ty);
|
||||
self.normalize_associated_types_in(ty)
|
||||
|
@ -850,7 +854,21 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
|
||||
fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
|
||||
self.table.unify(ty1, ty2)
|
||||
let ty1 = ty1
|
||||
.clone()
|
||||
.try_fold_with(
|
||||
&mut UnevaluatedConstEvaluatorFolder { db: self.db },
|
||||
DebruijnIndex::INNERMOST,
|
||||
)
|
||||
.unwrap();
|
||||
let ty2 = ty2
|
||||
.clone()
|
||||
.try_fold_with(
|
||||
&mut UnevaluatedConstEvaluatorFolder { db: self.db },
|
||||
DebruijnIndex::INNERMOST,
|
||||
)
|
||||
.unwrap();
|
||||
self.table.unify(&ty1, &ty2)
|
||||
}
|
||||
|
||||
/// Attempts to returns the deeply last field of nested structures, but
|
||||
|
@ -973,7 +991,7 @@ impl<'a> InferenceContext<'a> {
|
|||
Some(path) => path,
|
||||
None => return (self.err_ty(), None),
|
||||
};
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
|
||||
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver, self.owner.into());
|
||||
let (resolution, unresolved) = if value_ns {
|
||||
match self.resolver.resolve_path_in_value_ns(self.db.upcast(), path) {
|
||||
Some(ResolveValueResult::ValueNs(value)) => match value {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue