@@ -124,7 +124,15 @@ impl Path {
124
124
self . segments . first ( ) . is_some_and ( |segment| segment. ident . name == kw:: PathRoot )
125
125
}
126
126
127
- // FIXME: add docs
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).
128
136
#[ tracing:: instrument( level = "debug" , ret) ]
129
137
pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
130
138
allow_mgca_arg
@@ -1209,13 +1217,18 @@ pub struct Expr {
1209
1217
}
1210
1218
1211
1219
impl Expr {
1212
- // FIXME: update docs
1213
- /// 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`.
1214
1226
///
1215
- /// If this is not the case, name resolution does not resolve `N` when using
1216
- /// `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.
1217
1230
///
1218
- /// 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.
1219
1232
/// This also does not consider macros, so it's only correct after macro-expansion.
1220
1233
pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
1221
1234
let this = self . maybe_unwrap_block ( ) ;
0 commit comments