Skip to content

Commit 5b4b21a

Browse files
committed
rfc, cfg-path-version: clarify stability policy re. accessible(..).
1 parent ca5a92b commit 5b4b21a

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

text/0000-cfg-path-version.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ Greater or equal is defined in terms of [caret requirements].
244244

245245
## `#[cfg(accessible($path))]`
246246

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+
248251
This flag requires that a `path` fragment be specified in it inside parenthesis
249252
but not inside a string literal. The `$path` must start with leading `::`
250253
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
253256
conditionally compile against parts of their own crate because that crate
254257
has not been compiled when the `accessible` flag is checked on an item.
255258

259+
### Basic semantics
260+
256261
If and only if the path referred to by `$path` does exist and is public
257262
will the `#[cfg(accessible($path))]` flag be considered active.
263+
264+
### `#![feature(..)]` gating
265+
258266
In checking whether the path exists or not, the compiler will consider
259267
feature gated items to exist if the gate has been enabled.
260268

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+
261285
If a path refers to an item inside an inherent implementation,
262286
the path will be considered to exist if any configuration of generic
263287
parameters can lead to the item. To check whether an item exists for
264288
an implementation with a specific sequence of concrete types applied to
265289
a type constructor, it is possible to use the `::foo::bar::<T>::item` syntax.
266290

291+
### Fields
292+
267293
It is also possible to refer to fields of `struct`s, `enum`s, and `unions`.
268294
Assuming that we have the following definitions in the `foobar` crate:
269295

@@ -291,6 +317,8 @@ fn do_stuff() {
291317
}
292318
```
293319

320+
### Macros
321+
294322
Finally, bang macros, derive macros, attributes of all sorts including
295323
built-in, user provided, as well as latent derive helper attributes,
296324
will be considered when determining if a path is accessible.

text/1105-api-evolution.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,16 @@ type parameter to `foo` can break code, even if a default is provided.
759759
This could be easily addressed by adding a notation like `...` to leave
760760
additional parameters unspecified: `foo::<T, ...>(x, y)`.
761761

762+
## [Amendment] Misuse of `accessible(..)`
763+
764+
[RFC 2523]: https://github.com/rust-lang/rfcs/blob/master/text/2523-cfg-path-version.md
765+
766+
[RFC 2523] introduces `#[cfg(accessible($path)]`. Based on the accessibility of
767+
a to-the-current-crate external `$path`, the flag allows conditional compilation.
768+
When combined with `#[cfg(feature = "unstable")]`, this has certain breakage risks.
769+
Such breakage due to misuse, as outlined in the RFC, is considered acceptable and
770+
not covered by our stability promises. Please see the RFC for more details.
771+
762772
# Drawbacks and Alternatives
763773

764774
The main drawback to the approach laid out here is that it makes the stability

text/1122-language-semver.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ future as well. The `-Z` flags are of course explicitly unstable, but
229229
some of the `-C`, rustdoc, and linker-specific flags are expected to
230230
evolve over time (see e.g. [#24451]).
231231

232+
## [Amendment] Misuse of `accessible(..)`
233+
234+
[RFC 2523]: https://github.com/rust-lang/rfcs/blob/master/text/2523-cfg-path-version.md
235+
236+
[RFC 2523] introduces `#[cfg(accessible($path)]`. Based on the accessibility of
237+
a to-the-current-crate external `$path`, the flag allows conditional compilation.
238+
When combined with `#[cfg(feature = "unstable")]`, this has certain breakage risks.
239+
Such breakage due to misuse, as outlined in the RFC, is considered acceptable and
240+
not covered by our stability promises. Please see the RFC for more details.
241+
232242
# Drawbacks
233243

234244
The primary drawback is that making breaking changes are disruptive,

0 commit comments

Comments
 (0)