File tree 2 files changed +25
-11
lines changed
2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -401,18 +401,9 @@ impl<'a> TyLoweringContext<'a> {
401
401
) -> ( Ty , Option < TypeNs > ) {
402
402
let ty = match resolution {
403
403
TypeNs :: TraitId ( trait_) => {
404
- // if this is a bare dyn Trait, we'll directly put the required ^0 for the self type in there
405
- let self_ty = if remaining_segments. len ( ) == 0 {
406
- Some (
407
- TyKind :: BoundVar ( BoundVar :: new ( DebruijnIndex :: INNERMOST , 0 ) )
408
- . intern ( & Interner ) ,
409
- )
410
- } else {
411
- None
412
- } ;
413
- let trait_ref =
414
- self . lower_trait_ref_from_resolved_path ( trait_, resolved_segment, self_ty) ;
415
404
let ty = if remaining_segments. len ( ) == 1 {
405
+ let trait_ref =
406
+ self . lower_trait_ref_from_resolved_path ( trait_, resolved_segment, None ) ;
416
407
let segment = remaining_segments. first ( ) . unwrap ( ) ;
417
408
let found = self
418
409
. db
@@ -436,6 +427,13 @@ impl<'a> TyLoweringContext<'a> {
436
427
// FIXME report error (ambiguous associated type)
437
428
TyKind :: Error . intern ( & Interner )
438
429
} else {
430
+ let self_ty = Some (
431
+ TyKind :: BoundVar ( BoundVar :: new ( DebruijnIndex :: INNERMOST , 0 ) )
432
+ . intern ( & Interner ) ,
433
+ ) ;
434
+ let trait_ref = self . with_shifted_in ( DebruijnIndex :: ONE , |ctx| {
435
+ ctx. lower_trait_ref_from_resolved_path ( trait_, resolved_segment, self_ty)
436
+ } ) ;
439
437
let dyn_ty = DynTy {
440
438
bounds : crate :: make_only_type_binders (
441
439
1 ,
Original file line number Diff line number Diff line change @@ -1077,3 +1077,19 @@ fn test() {
1077
1077
"# ,
1078
1078
)
1079
1079
}
1080
+
1081
+ #[ test]
1082
+ fn bare_dyn_trait_binders_9639 ( ) {
1083
+ check_no_mismatches (
1084
+ r#"
1085
+ //- minicore: fn, coerce_unsized
1086
+ fn infix_parse<T, S>(_state: S, _level_code: &Fn(S)) -> T {
1087
+ loop {}
1088
+ }
1089
+
1090
+ fn parse_arule() {
1091
+ infix_parse((), &(|_recurse| ()))
1092
+ }
1093
+ "# ,
1094
+ )
1095
+ }
You can’t perform that action at this time.
0 commit comments