@@ -2063,8 +2063,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20632063 ty_id : NodeId ,
20642064 span : Span ,
20652065 ) -> & ' hir hir:: ConstArg < ' hir > {
2066+ let tcx = self . tcx ;
2067+
20662068 // FIXME(min_generic_const_args): we only allow one-segment const paths for now
2067- let ct_kind = if path. is_potential_trivial_const_arg ( ) {
2069+ let ct_kind = if path. is_potential_trivial_const_arg ( )
2070+ && ( tcx. features ( ) . min_generic_const_args ( )
2071+ || matches ! ( res, Res :: Def ( DefKind :: ConstParam , _) ) )
2072+ {
20682073 let qpath = self . lower_qpath (
20692074 ty_id,
20702075 & None ,
@@ -2127,6 +2132,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21272132
21282133 #[ instrument( level = "debug" , skip( self ) ) ]
21292134 fn lower_anon_const_to_const_arg_direct ( & mut self , anon : & AnonConst ) -> hir:: ConstArg < ' hir > {
2135+ let tcx = self . tcx ;
21302136 // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
21312137 // currently have to be wrapped in curly brackets, so it's necessary to special-case.
21322138 let expr = if let ExprKind :: Block ( block, _) = & anon. value . kind
@@ -2138,9 +2144,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21382144 } else {
21392145 & anon. value
21402146 } ;
2147+ let maybe_res =
2148+ self . resolver . get_partial_res ( expr. id ) . and_then ( |partial_res| partial_res. full_res ( ) ) ;
21412149 // FIXME(min_generic_const_args): we only allow one-segment const paths for now
21422150 if let ExprKind :: Path ( None , path) = & expr. kind
21432151 && path. is_potential_trivial_const_arg ( )
2152+ && ( tcx. features ( ) . min_generic_const_args ( )
2153+ || matches ! ( maybe_res, Some ( Res :: Def ( DefKind :: ConstParam , _) ) ) )
21442154 {
21452155 let qpath = self . lower_qpath (
21462156 expr. id ,
0 commit comments