Skip to content

Commit 51cbcc5

Browse files
committed
hir_ty: don't pass where clauses of associated types down to chalk (temp. fix rust-lang#9052)
1 parent f1d163b commit 51cbcc5

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

crates/hir_ty/src/chalk_db.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub(crate) fn associated_ty_data_query(
383383
// Lower bounds -- we could/should maybe move this to a separate query in `lower`
384384
let type_alias_data = db.type_alias_data(type_alias);
385385
let generic_params = generics(db.upcast(), type_alias.into());
386-
let bound_vars = generic_params.bound_vars_subst(DebruijnIndex::INNERMOST);
386+
// let bound_vars = generic_params.bound_vars_subst(DebruijnIndex::INNERMOST);
387387
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
388388
let ctx = crate::TyLoweringContext::new(db, &resolver)
389389
.with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable);
@@ -396,8 +396,10 @@ pub(crate) fn associated_ty_data_query(
396396
.filter_map(|pred| generic_predicate_to_inline_bound(db, &pred, &self_ty))
397397
.collect();
398398

399-
let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
400-
let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses };
399+
// FIXME: Re-enable where clauses on associated types when an upstream chalk bug is fixed.
400+
// (rust-analyzer#9052)
401+
// let where_clauses = convert_where_clauses(db, type_alias.into(), &bound_vars);
402+
let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses: vec![] };
401403
let datum = AssociatedTyDatum {
402404
trait_id: to_chalk_trait_id(trait_),
403405
id,

crates/hir_ty/src/tests/traits.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ mod result {
161161
}
162162

163163
#[test]
164-
fn infer_tryv2() {
164+
fn infer_try_trait_v2() {
165165
check_types(
166166
r#"
167167
//- /main.rs crate:main deps:core
@@ -172,26 +172,41 @@ fn test() {
172172
} //^ i32
173173
174174
//- /core.rs crate:core
175-
#[prelude_import] use ops::*;
176175
mod ops {
177-
trait Try {
178-
type Output;
179-
type Residual;
176+
mod try_trait {
177+
pub trait Try: FromResidual {
178+
type Output;
179+
type Residual;
180+
}
181+
pub trait FromResidual<R = <Self as Try>::Residual> {}
180182
}
183+
184+
pub use self::try_trait::FromResidual;
185+
pub use self::try_trait::Try;
186+
}
187+
188+
mov convert {
189+
pub trait From<T> {}
190+
impl<T> From<T> for T {}
181191
}
182192
183193
#[prelude_import] use result::*;
184194
mod result {
185-
enum Infallible {}
186-
enum Result<O, E> {
195+
use crate::convert::From;
196+
use crate::ops::{Try, FromResidual};
197+
198+
pub enum Infallible {}
199+
pub enum Result<O, E> {
187200
Ok(O),
188201
Err(E)
189202
}
190203
191-
impl<O, E> crate::ops::Try for Result<O, E> {
204+
impl<O, E> Try for Result<O, E> {
192205
type Output = O;
193206
type Error = Result<Infallible, E>;
194207
}
208+
209+
impl<T, E, F: From<E>> FromResidual<Result<Infallible, E>> for Result<T, F> {}
195210
}
196211
"#,
197212
);

0 commit comments

Comments
 (0)