@@ -485,9 +485,23 @@ enum ParamMode {
485
485
Optional ,
486
486
}
487
487
488
+ #[ derive( Copy , Clone , Debug ) ]
489
+ enum AllowReturnTypeNotation {
490
+ /// Only in types, since RTN is denied later during HIR lowering.
491
+ Yes ,
492
+ /// All other positions (path expr, method, use tree).
493
+ No ,
494
+ }
495
+
488
496
enum GenericArgsMode {
497
+ /// Allow paren sugar, don't allow RTN.
489
498
ParenSugar ,
499
+ /// Allow RTN, don't allow paren sugar.
500
+ ReturnTypeNotation ,
501
+ // Error if parenthesized generics or RTN are encountered.
490
502
Err ,
503
+ /// Silence errors when lowering generics. Only used with `Res::Err`.
504
+ Silence ,
491
505
}
492
506
493
507
impl < ' a , ' hir > LoweringContext < ' a , ' hir > {
@@ -1226,7 +1240,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1226
1240
}
1227
1241
1228
1242
let id = self . lower_node_id ( t. id ) ;
1229
- let qpath = self . lower_qpath ( t. id , qself, path, param_mode, itctx, None ) ;
1243
+ let qpath = self . lower_qpath (
1244
+ t. id ,
1245
+ qself,
1246
+ path,
1247
+ param_mode,
1248
+ AllowReturnTypeNotation :: Yes ,
1249
+ itctx,
1250
+ None ,
1251
+ ) ;
1230
1252
self . ty_path ( id, t. span , qpath)
1231
1253
}
1232
1254
@@ -2203,6 +2225,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2203
2225
& None ,
2204
2226
& p. path ,
2205
2227
ParamMode :: Explicit ,
2228
+ AllowReturnTypeNotation :: No ,
2206
2229
itctx,
2207
2230
Some ( modifiers) ,
2208
2231
) {
@@ -2341,6 +2364,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2341
2364
& None ,
2342
2365
path,
2343
2366
ParamMode :: Optional ,
2367
+ AllowReturnTypeNotation :: No ,
2344
2368
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
2345
2369
None ,
2346
2370
) ;
@@ -2419,6 +2443,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2419
2443
qself,
2420
2444
path,
2421
2445
ParamMode :: Optional ,
2446
+ AllowReturnTypeNotation :: No ,
2422
2447
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
2423
2448
None ,
2424
2449
) ;
@@ -2441,7 +2466,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2441
2466
/// See [`hir::ConstArg`] for when to use this function vs
2442
2467
/// [`Self::lower_anon_const_to_const_arg`].
2443
2468
fn lower_anon_const_to_anon_const ( & mut self , c : & AnonConst ) -> & ' hir hir:: AnonConst {
2444
- if c. value . is_potential_trivial_const_arg ( ) {
2469
+ if c. value . is_potential_trivial_const_arg ( true ) {
2445
2470
// HACK(min_generic_const_args): see DefCollector::visit_anon_const
2446
2471
// Over there, we guess if this is a bare param and only create a def if
2447
2472
// we think it's not. However we may can guess wrong (see there for example)
0 commit comments