@@ -124,10 +124,19 @@ impl Path {
124124 self . segments . first ( ) . is_some_and ( |segment| segment. ident . name == kw:: PathRoot )
125125 }
126126
127- /// If this path is a single identifier with no arguments, does not ensure
128- /// that the path resolves to a const param, the caller should check this.
129- pub fn is_potential_trivial_const_arg ( & self ) -> bool {
130- matches ! ( self . segments[ ..] , [ PathSegment { args: None , .. } ] )
127+ /// Check if this path is potentially a trivial const arg, i.e., one that can _potentially_
128+ /// be represented without an anon const in the HIR.
129+ ///
130+ /// If `allow_mgca_arg` is true (as should be the case in most situations when
131+ /// `#![feature(min_generic_const_args)]` is enabled), then this always returns true
132+ /// because all paths are valid.
133+ ///
134+ /// Otherwise, it returns true iff the path has exactly one segment, and it has no generic args
135+ /// (i.e., it is _potentially_ a const parameter).
136+ #[ tracing:: instrument( level = "debug" , ret) ]
137+ pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
138+ allow_mgca_arg
139+ || self . segments . len ( ) == 1 && self . segments . iter ( ) . all ( |seg| seg. args . is_none ( ) )
131140 }
132141}
133142
@@ -417,9 +426,11 @@ impl WhereClause {
417426/// A single predicate in a where-clause.
418427#[ derive( Clone , Encodable , Decodable , Debug ) ]
419428pub struct WherePredicate {
429+ pub attrs : AttrVec ,
420430 pub kind : WherePredicateKind ,
421431 pub id : NodeId ,
422432 pub span : Span ,
433+ pub is_placeholder : bool ,
423434}
424435
425436/// Predicate kind in where-clause.
@@ -1206,22 +1217,31 @@ pub struct Expr {
12061217}
12071218
12081219impl Expr {
1209- /// Could this expr be either `N`, or `{ N }`, where `N` is a const parameter.
1220+ /// Check if this expression is potentially a trivial const arg, i.e., one that can _potentially_
1221+ /// be represented without an anon const in the HIR.
1222+ ///
1223+ /// This will unwrap at most one block level (curly braces). After that, if the expression
1224+ /// is a path, it mostly dispatches to [`Path::is_potential_trivial_const_arg`].
1225+ /// See there for more info about `allow_mgca_arg`.
12101226 ///
1211- /// If this is not the case, name resolution does not resolve `N` when using
1212- /// `min_const_generics` as more complex expressions are not supported.
1227+ /// The only additional thing to note is that when `allow_mgca_arg` is false, this function
1228+ /// will only allow paths with no qself, before dispatching to the `Path` function of
1229+ /// the same name.
12131230 ///
1214- /// Does not ensure that the path resolves to a const param, the caller should check this.
1231+ /// Does not ensure that the path resolves to a const param/item , the caller should check this.
12151232 /// This also does not consider macros, so it's only correct after macro-expansion.
1216- pub fn is_potential_trivial_const_arg ( & self ) -> bool {
1233+ pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
12171234 let this = self . maybe_unwrap_block ( ) ;
1218-
1219- if let ExprKind :: Path ( None , path) = & this. kind
1220- && path. is_potential_trivial_const_arg ( )
1221- {
1222- true
1235+ if allow_mgca_arg {
1236+ matches ! ( this. kind, ExprKind :: Path ( ..) )
12231237 } else {
1224- false
1238+ if let ExprKind :: Path ( None , path) = & this. kind
1239+ && path. is_potential_trivial_const_arg ( allow_mgca_arg)
1240+ {
1241+ true
1242+ } else {
1243+ false
1244+ }
12251245 }
12261246 }
12271247
0 commit comments