File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Expand file tree Collapse file tree 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> {
401401 ) -> ( Ty , Option < TypeNs > ) {
402402 let ty = match resolution {
403403 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) ;
415404 let ty = if remaining_segments. len ( ) == 1 {
405+ let trait_ref =
406+ self . lower_trait_ref_from_resolved_path ( trait_, resolved_segment, None ) ;
416407 let segment = remaining_segments. first ( ) . unwrap ( ) ;
417408 let found = self
418409 . db
@@ -436,6 +427,13 @@ impl<'a> TyLoweringContext<'a> {
436427 // FIXME report error (ambiguous associated type)
437428 TyKind :: Error . intern ( & Interner )
438429 } 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+ } ) ;
439437 let dyn_ty = DynTy {
440438 bounds : crate :: make_only_type_binders (
441439 1 ,
Original file line number Diff line number Diff line change @@ -1077,3 +1077,19 @@ fn test() {
10771077 "# ,
10781078 )
10791079}
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