File tree 2 files changed +32
-0
lines changed
hir-def/src/expr_store/lower
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,14 @@ pub(super) fn lower_path(
232
232
. with_borrow_mut ( |map| map. extend ( ast_segments. into_iter ( ) . zip ( ast_segments_offset..) ) ) ;
233
233
}
234
234
235
+ if let Some ( last_segment_args @ Some ( GenericArgs { has_self_type : true , .. } ) ) =
236
+ generic_args. last_mut ( )
237
+ {
238
+ // Well-formed code cannot have `<T as Trait>` without an associated item after,
239
+ // and this causes panics in hir-ty lowering.
240
+ * last_segment_args = None ;
241
+ }
242
+
235
243
let mod_path = Interned :: new ( ModPath :: from_segments ( kind, segments) ) ;
236
244
if type_anchor. is_none ( ) && generic_args. is_empty ( ) {
237
245
return Some ( Path :: BarePath ( mod_path) ) ;
Original file line number Diff line number Diff line change @@ -3902,3 +3902,27 @@ fn main() {
3902
3902
"# ] ] ,
3903
3903
) ;
3904
3904
}
3905
+
3906
+ #[ test]
3907
+ fn regression_19734 ( ) {
3908
+ check_infer (
3909
+ r#"
3910
+ trait Foo {
3911
+ type Gat<'o>;
3912
+ }
3913
+
3914
+ trait Bar {
3915
+ fn baz() -> <Self::Xyz as Foo::Gat<'_>>;
3916
+ }
3917
+
3918
+ fn foo<T: Bar>() {
3919
+ T::baz();
3920
+ }
3921
+ "# ,
3922
+ expect ! [ [ r#"
3923
+ 110..127 '{ ...z(); }': ()
3924
+ 116..122 'T::baz': fn baz<T>() -> <{unknown} as Foo>::Gat<'?>
3925
+ 116..124 'T::baz()': Foo::Gat<'?, {unknown}>
3926
+ "# ] ] ,
3927
+ ) ;
3928
+ }
You can’t perform that action at this time.
0 commit comments