@@ -124,7 +124,15 @@ impl Path {
124124 self . segments . first ( ) . is_some_and ( |segment| segment. ident . name == kw:: PathRoot )
125125 }
126126
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).
128136 #[ tracing:: instrument( level = "debug" , ret) ]
129137 pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
130138 allow_mgca_arg
@@ -1209,13 +1217,18 @@ pub struct Expr {
12091217}
12101218
12111219impl 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`.
12141226 ///
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.
12171230 ///
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.
12191232 /// This also does not consider macros, so it's only correct after macro-expansion.
12201233 pub fn is_potential_trivial_const_arg ( & self , allow_mgca_arg : bool ) -> bool {
12211234 let this = self . maybe_unwrap_block ( ) ;
0 commit comments