Skip to content

Commit 99d81d9

Browse files
committed
frequently requested changes: bypassing visibility
1 parent e8256d6 commit 99d81d9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/frequently-requested-changes.md

+23
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,26 @@ Cross-referencing to other discussions:
217217
* <https://github.com/rust-lang/rfcs/issues/1397>
218218
* <https://github.com/rust-lang/rust/issues/17027>
219219
* <https://github.com/rust-lang/unsafe-code-guidelines/issues/176>
220+
221+
## A way to bypass visibility, including an `unsafe` bypass
222+
223+
Items are only accessible if they are marked `pub` or re-exported as such;
224+
they are otherwise private by default. People sometimes wish to break that
225+
rule to access internals of libraries they're using, for example to access
226+
private fields of a type or to call private functions.
227+
228+
This could break invariants assumed by the crate's author, which, if any
229+
unsafe code depends on those, could lead to undefined behavior.
230+
231+
More importantly, allowing people to violate privacy would destroy SemVer.
232+
If people can access and use implementation details of other crates then
233+
that means that almost any change is now a breaking change. This would lead
234+
to widespread fallout across the crate ecosystem.
235+
236+
Making it `unsafe` does nothing to prevent these issues. `unsafe` is
237+
used to deal with memory safety problems and it is not in any way useful to
238+
deal with SemVer concerns.
239+
240+
Forking a crate (to insert the necessary `pub`s) does not have these
241+
problems. As such, a better way to achieve this would be to make patch
242+
dependencies more ergonomic to use and maintain.

0 commit comments

Comments
 (0)