@@ -244,7 +244,10 @@ Greater or equal is defined in terms of [caret requirements].
244
244
245
245
## ` #[cfg(accessible($path))] `
246
246
247
- To the ` cfg ` attribute, a ` accessible ` flag is added.
247
+ To the ` cfg ` attribute, an ` accessible ` flag is added.
248
+
249
+ ### Syntactic form
250
+
248
251
This flag requires that a ` path ` fragment be specified in it inside parenthesis
249
252
but not inside a string literal. The ` $path ` must start with leading ` :: `
250
253
and may not refer to any parts of the own crate (e.g. with ` ::crate::foo ` ,
@@ -253,17 +256,40 @@ This restriction exists to ensure that the user does not try to
253
256
conditionally compile against parts of their own crate because that crate
254
257
has not been compiled when the ` accessible ` flag is checked on an item.
255
258
259
+ ### Basic semantics
260
+
256
261
If and only if the path referred to by ` $path ` does exist and is public
257
262
will the ` #[cfg(accessible($path))] ` flag be considered active.
263
+
264
+ ### ` #![feature(..)] ` gating
265
+
258
266
In checking whether the path exists or not, the compiler will consider
259
267
feature gated items to exist if the gate has been enabled.
260
268
269
+ ** NOTE:** In the section on ` #[cfg(nightly)] ` and in the
270
+ [ guide level explanation] [ guide-level-explanation ] we note that there are
271
+ some risks when combining ` cfg(feature = "unstable") ` and ` accessible(..) ` to
272
+ add conditional support for an unstable feature that is expected to stabilize.
273
+ With respect to such usage:
274
+
275
+ 1 . User-facing documentation, regarding ` accessible(..) ` should highlight risky
276
+ scenarios, including with examples, with respect to possible breakage.
277
+
278
+ 2 . Our stability policy is updated to state that breakage caused due to misuse
279
+ of ` accessible(..) ` is _ allowed_ breakage. Consequently, rust teams will not
280
+ delay releases or un-stabilize features because they broke a crate using
281
+ ` accessible(..) ` to gate on those features.
282
+
283
+ ### Inherent implementations
284
+
261
285
If a path refers to an item inside an inherent implementation,
262
286
the path will be considered to exist if any configuration of generic
263
287
parameters can lead to the item. To check whether an item exists for
264
288
an implementation with a specific sequence of concrete types applied to
265
289
a type constructor, it is possible to use the ` ::foo::bar::<T>::item ` syntax.
266
290
291
+ ### Fields
292
+
267
293
It is also possible to refer to fields of ` struct ` s, ` enum ` s, and ` unions ` .
268
294
Assuming that we have the following definitions in the ` foobar ` crate:
269
295
@@ -291,6 +317,8 @@ fn do_stuff() {
291
317
}
292
318
```
293
319
320
+ ### Macros
321
+
294
322
Finally, bang macros, derive macros, attributes of all sorts including
295
323
built-in, user provided, as well as latent derive helper attributes,
296
324
will be considered when determining if a path is accessible.
0 commit comments