From 51cbcc53468a4f9fbeae8b11f1b1b0f09a9d3454 Mon Sep 17 00:00:00 2001 From: cynecx Date: Sun, 30 May 2021 18:37:02 +0200 Subject: hir_ty: don't pass where clauses of associated types down to chalk (temp. fix #9052) --- crates/hir_ty/src/chalk_db.rs | 8 +++++--- crates/hir_ty/src/tests/traits.rs | 31 +++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index b108fd559..4e042bf42 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs @@ -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, diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 7c0ff2170..49add4ab9 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -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 { - type Output; - type Residual; + mod try_trait { + pub trait Try: FromResidual { + type Output; + type Residual; + } + pub trait FromResidual::Residual> {} } + + pub use self::try_trait::FromResidual; + pub use self::try_trait::Try; +} + +mov convert { + pub trait From {} + impl From for T {} } #[prelude_import] use result::*; mod result { - enum Infallible {} - enum Result { + use crate::convert::From; + use crate::ops::{Try, FromResidual}; + + pub enum Infallible {} + pub enum Result { Ok(O), Err(E) } - impl crate::ops::Try for Result { + impl Try for Result { type Output = O; type Error = Result; } + + impl> FromResidual> for Result {} } "#, ); -- cgit v1.2.3