@@ -404,6 +404,8 @@ pub(crate) enum PathSource<'a> {
404
404
Delegation ,
405
405
/// An arg in a `use<'a, N>` precise-capturing bound.
406
406
PreciseCapturingArg ( Namespace ) ,
407
+ // Paths that end with `(..)`, for return type notation.
408
+ ReturnTypeNotation ,
407
409
}
408
410
409
411
impl < ' a > PathSource < ' a > {
@@ -413,7 +415,8 @@ impl<'a> PathSource<'a> {
413
415
PathSource :: Expr ( ..)
414
416
| PathSource :: Pat
415
417
| PathSource :: TupleStruct ( ..)
416
- | PathSource :: Delegation => ValueNS ,
418
+ | PathSource :: Delegation
419
+ | PathSource :: ReturnTypeNotation => ValueNS ,
417
420
PathSource :: TraitItem ( ns) => ns,
418
421
PathSource :: PreciseCapturingArg ( ns) => ns,
419
422
}
@@ -425,7 +428,8 @@ impl<'a> PathSource<'a> {
425
428
| PathSource :: Expr ( ..)
426
429
| PathSource :: Pat
427
430
| PathSource :: Struct
428
- | PathSource :: TupleStruct ( ..) => true ,
431
+ | PathSource :: TupleStruct ( ..)
432
+ | PathSource :: ReturnTypeNotation => true ,
429
433
PathSource :: Trait ( _)
430
434
| PathSource :: TraitItem ( ..)
431
435
| PathSource :: Delegation
@@ -471,7 +475,7 @@ impl<'a> PathSource<'a> {
471
475
} ,
472
476
_ => "value" ,
473
477
} ,
474
- PathSource :: Delegation => "function" ,
478
+ PathSource :: ReturnTypeNotation | PathSource :: Delegation => "function" ,
475
479
PathSource :: PreciseCapturingArg ( ..) => "type or const parameter" ,
476
480
}
477
481
}
@@ -540,6 +544,10 @@ impl<'a> PathSource<'a> {
540
544
Res :: Def ( DefKind :: AssocTy , _) if ns == TypeNS => true ,
541
545
_ => false ,
542
546
} ,
547
+ PathSource :: ReturnTypeNotation => match res {
548
+ Res :: Def ( DefKind :: AssocFn , _) => true ,
549
+ _ => false ,
550
+ } ,
543
551
PathSource :: Delegation => matches ! ( res, Res :: Def ( DefKind :: Fn | DefKind :: AssocFn , _) ) ,
544
552
PathSource :: PreciseCapturingArg ( ValueNS ) => {
545
553
matches ! ( res, Res :: Def ( DefKind :: ConstParam , _) )
@@ -565,8 +573,8 @@ impl<'a> PathSource<'a> {
565
573
( PathSource :: Expr ( ..) , false ) | ( PathSource :: Delegation , false ) => E0425 ,
566
574
( PathSource :: Pat | PathSource :: TupleStruct ( ..) , true ) => E0532 ,
567
575
( PathSource :: Pat | PathSource :: TupleStruct ( ..) , false ) => E0531 ,
568
- ( PathSource :: TraitItem ( ..) , true ) => E0575 ,
569
- ( PathSource :: TraitItem ( ..) , false ) => E0576 ,
576
+ ( PathSource :: TraitItem ( ..) , true ) | ( PathSource :: ReturnTypeNotation , true ) => E0575 ,
577
+ ( PathSource :: TraitItem ( ..) , false ) | ( PathSource :: ReturnTypeNotation , false ) => E0576 ,
570
578
( PathSource :: PreciseCapturingArg ( ..) , true ) => E0799 ,
571
579
( PathSource :: PreciseCapturingArg ( ..) , false ) => E0800 ,
572
580
}
@@ -781,7 +789,17 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
781
789
}
782
790
TyKind :: Path ( qself, path) => {
783
791
self . diag_metadata . current_type_path = Some ( ty) ;
784
- self . smart_resolve_path ( ty. id , qself, path, PathSource :: Type ) ;
792
+
793
+ let source = if let Some ( seg) = path. segments . last ( )
794
+ && let Some ( args) = & seg. args
795
+ && matches ! ( * * args, GenericArgs :: ParenthesizedElided ( ..) )
796
+ {
797
+ PathSource :: ReturnTypeNotation
798
+ } else {
799
+ PathSource :: Type
800
+ } ;
801
+
802
+ self . smart_resolve_path ( ty. id , qself, path, source) ;
785
803
786
804
// Check whether we should interpret this as a bare trait object.
787
805
if qself. is_none ( )
@@ -1920,7 +1938,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
1920
1938
PathSource :: Trait ( ..)
1921
1939
| PathSource :: TraitItem ( ..)
1922
1940
| PathSource :: Type
1923
- | PathSource :: PreciseCapturingArg ( ..) => false ,
1941
+ | PathSource :: PreciseCapturingArg ( ..)
1942
+ | PathSource :: ReturnTypeNotation => false ,
1924
1943
PathSource :: Expr ( ..)
1925
1944
| PathSource :: Pat
1926
1945
| PathSource :: Struct
0 commit comments