File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
453
453
}
454
454
}
455
455
456
- impl < ' a > chalk_ir:: UnificationDatabase < Interner > for & ' a dyn HirDatabase {
456
+ impl chalk_ir:: UnificationDatabase < Interner > for & dyn HirDatabase {
457
457
fn fn_def_variance (
458
458
& self ,
459
459
fn_def_id : chalk_ir:: FnDefId < Interner > ,
Original file line number Diff line number Diff line change @@ -187,6 +187,15 @@ impl TraitImpls {
187
187
fn collect_def_map ( & mut self , db : & dyn HirDatabase , def_map : & DefMap ) {
188
188
for ( _module_id, module_data) in def_map. modules ( ) {
189
189
for impl_id in module_data. scope . impls ( ) {
190
+ // Reservation impls should be ignored during trait resolution, so we never need
191
+ // them during type analysis. See rust-lang/rust#64631 for details.
192
+ //
193
+ // FIXME: Reservation impls should be considered during coherence checks. If we are
194
+ // (ever) to implement coherence checks, this filtering should be done by the trait
195
+ // solver.
196
+ if db. attrs ( impl_id. into ( ) ) . by_key ( "rustc_reservation_impl" ) . exists ( ) {
197
+ continue ;
198
+ }
190
199
let target_trait = match db. impl_trait ( impl_id) {
191
200
Some ( tr) => tr. skip_binders ( ) . hir_trait_id ( ) ,
192
201
None => continue ,
Original file line number Diff line number Diff line change @@ -483,3 +483,22 @@ fn example() -> bool {
483
483
"# ,
484
484
) ;
485
485
}
486
+
487
+ #[ test]
488
+ fn reservation_impl_should_be_ignored ( ) {
489
+ // See rust-lang/rust#64631.
490
+ check_types (
491
+ r#"
492
+ //- minicore: from
493
+ struct S;
494
+ #[rustc_reservation_impl]
495
+ impl<T> From<!> for T {}
496
+ fn foo<T, U: From<T>>(_: U) -> T { loop {} }
497
+
498
+ fn test() {
499
+ let s = foo(S);
500
+ //^ S
501
+ }
502
+ "# ,
503
+ ) ;
504
+ }
You can’t perform that action at this time.
0 commit comments