hir_ty: don't pass where clauses of associated types down to chalk (temp. fix #9052)

This commit is contained in:
cynecx 2021-05-30 18:37:02 +02:00
parent f1d163ba51
commit 51cbcc5346
2 changed files with 28 additions and 11 deletions

View File

@ -383,7 +383,7 @@ pub(crate) fn associated_ty_data_query(
// Lower bounds -- we could/should maybe move this to a separate query in `lower`
let type_alias_data = db.type_alias_data(type_alias);
let generic_params = generics(db.upcast(), type_alias.into());
let bound_vars = generic_params.bound_vars_subst(DebruijnIndex::INNERMOST);
// let bound_vars = generic_params.bound_vars_subst(DebruijnIndex::INNERMOST);
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
let ctx = crate::TyLoweringContext::new(db, &resolver)
.with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable);
@ -396,8 +396,10 @@ pub(crate) fn associated_ty_data_query(
.filter_map(|pred| generic_predicate_to_inline_bound(db, &pred, &self_ty))
.collect();
let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses };
// FIXME: Re-enable where clauses on associated types when an upstream chalk bug is fixed.
// (rust-analyzer#9052)
// let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses: vec![] };
let datum = AssociatedTyDatum {
trait_id: to_chalk_trait_id(trait_),
id,

View File

@ -161,7 +161,7 @@ mod result {
}
#[test]
fn infer_tryv2() {
fn infer_try_trait_v2() {
check_types(
r#"
//- /main.rs crate:main deps:core
@ -172,26 +172,41 @@ fn test() {
} //^ i32
//- /core.rs crate:core
#[prelude_import] use ops::*;
mod ops {
trait Try {
mod try_trait {
pub trait Try: FromResidual {
type Output;
type Residual;
}
pub trait FromResidual<R = <Self as Try>::Residual> {}
}
pub use self::try_trait::FromResidual;
pub use self::try_trait::Try;
}
mov convert {
pub trait From<T> {}
impl<T> From<T> for T {}
}
#[prelude_import] use result::*;
mod result {
enum Infallible {}
enum Result<O, E> {
use crate::convert::From;
use crate::ops::{Try, FromResidual};
pub enum Infallible {}
pub enum Result<O, E> {
Ok(O),
Err(E)
}
impl<O, E> crate::ops::Try for Result<O, E> {
impl<O, E> Try for Result<O, E> {
type Output = O;
type Error = Result<Infallible, E>;
}
impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Result<T, F> {}
}
"#,
);