@@ -485,9 +485,23 @@ enum ParamMode {
485485 Optional ,
486486}
487487
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+
488496enum GenericArgsMode {
497+ /// Allow paren sugar, don't allow RTN.
489498 ParenSugar ,
499+ /// Allow RTN, don't allow paren sugar.
500+ ReturnTypeNotation ,
501+ // Error if parenthesized generics or RTN are encountered.
490502 Err ,
503+ /// Silence errors when lowering generics. Only used with `Res::Err`.
504+ Silence ,
491505}
492506
493507impl < ' a , ' hir > LoweringContext < ' a , ' hir > {
@@ -1226,7 +1240,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12261240 }
12271241
12281242 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+ ) ;
12301252 self . ty_path ( id, t. span , qpath)
12311253 }
12321254
@@ -2203,6 +2225,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22032225 & None ,
22042226 & p. path ,
22052227 ParamMode :: Explicit ,
2228+ AllowReturnTypeNotation :: No ,
22062229 itctx,
22072230 Some ( modifiers) ,
22082231 ) {
@@ -2341,6 +2364,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23412364 & None ,
23422365 path,
23432366 ParamMode :: Optional ,
2367+ AllowReturnTypeNotation :: No ,
23442368 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
23452369 None ,
23462370 ) ;
@@ -2419,6 +2443,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24192443 qself,
24202444 path,
24212445 ParamMode :: Optional ,
2446+ AllowReturnTypeNotation :: No ,
24222447 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
24232448 None ,
24242449 ) ;
@@ -2441,7 +2466,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24412466 /// See [`hir::ConstArg`] for when to use this function vs
24422467 /// [`Self::lower_anon_const_to_const_arg`].
24432468 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 ) {
24452470 // HACK(min_generic_const_args): see DefCollector::visit_anon_const
24462471 // Over there, we guess if this is a bare param and only create a def if
24472472 // we think it's not. However we may can guess wrong (see there for example)
0 commit comments