File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -949,7 +949,8 @@ impl<'db> ExprCollector<'db> {
949949 node : ast:: TypeBound ,
950950 impl_trait_lower_fn : ImplTraitLowerFn < ' _ > ,
951951 ) -> TypeBound {
952- match node. kind ( ) {
952+ let Some ( kind) = node. kind ( ) else { return TypeBound :: Error } ;
953+ match kind {
953954 ast:: TypeBoundKind :: PathType ( binder, path_type) => {
954955 let binder = match binder. and_then ( |it| it. generic_param_list ( ) ) {
955956 Some ( gpl) => gpl
Original file line number Diff line number Diff line change @@ -197,3 +197,15 @@ fn allowed3(baz: impl Baz<Assoc = Qux<impl Foo>>) {}
197197 "# ] ] ,
198198 ) ;
199199}
200+
201+ #[ test]
202+ fn regression_21138 ( ) {
203+ lower_and_print (
204+ r#"
205+ fn foo(v: for<'a> Trait1 + Trait2) {}
206+ "# ,
207+ expect ! [ [ r#"
208+ fn foo(dyn for<'a> Trait1 + Trait2) {...}
209+ "# ] ] ,
210+ ) ;
211+ }
Original file line number Diff line number Diff line change @@ -813,13 +813,16 @@ pub enum TypeBoundKind {
813813}
814814
815815impl ast:: TypeBound {
816- pub fn kind ( & self ) -> TypeBoundKind {
816+ pub fn kind ( & self ) -> Option < TypeBoundKind > {
817817 if let Some ( path_type) = support:: children ( self . syntax ( ) ) . next ( ) {
818- TypeBoundKind :: PathType ( self . for_binder ( ) , path_type)
818+ Some ( TypeBoundKind :: PathType ( self . for_binder ( ) , path_type) )
819+ } else if let Some ( for_binder) = support:: children :: < ast:: ForType > ( & self . syntax ) . next ( ) {
820+ let Some ( ast:: Type :: PathType ( path_type) ) = for_binder. ty ( ) else { return None } ;
821+ Some ( TypeBoundKind :: PathType ( for_binder. for_binder ( ) , path_type) )
819822 } else if let Some ( args) = self . use_bound_generic_args ( ) {
820- TypeBoundKind :: Use ( args)
823+ Some ( TypeBoundKind :: Use ( args) )
821824 } else if let Some ( lifetime) = self . lifetime ( ) {
822- TypeBoundKind :: Lifetime ( lifetime)
825+ Some ( TypeBoundKind :: Lifetime ( lifetime) )
823826 } else {
824827 unreachable ! ( )
825828 }
You can’t perform that action at this time.
0 commit comments