@@ -124,10 +124,19 @@ impl Path {
124
124
self . segments . first ( ) . is_some_and ( |segment| segment. ident . name == kw:: PathRoot )
125
125
}
126
126
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 ( ) )
131
140
}
132
141
}
133
142
@@ -417,9 +426,11 @@ impl WhereClause {
417
426
/// A single predicate in a where-clause.
418
427
#[ derive( Clone , Encodable , Decodable , Debug ) ]
419
428
pub struct WherePredicate {
429
+ pub attrs : AttrVec ,
420
430
pub kind : WherePredicateKind ,
421
431
pub id : NodeId ,
422
432
pub span : Span ,
433
+ pub is_placeholder : bool ,
423
434
}
424
435
425
436
/// Predicate kind in where-clause.
@@ -1206,22 +1217,31 @@ pub struct Expr {
1206
1217
}
1207
1218
1208
1219
impl 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`.
1210
1226
///
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.
1213
1230
///
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.
1215
1232
/// 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 {
1217
1234
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 ( ..) )
1223
1237
} 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
+ }
1225
1245
}
1226
1246
}
1227
1247
0 commit comments