@@ -260,6 +260,34 @@ fn foo2() {
260
260
}
261
261
```
262
262
263
+ ### Cross-crate re-exports
264
+
265
+ If an item is re-exported from an inner crate to an outer crate,
266
+ its documentation will be resolved the same in both crates, as if it were in
267
+ the original scope. For example, this function will link to ` f ` in both crates,
268
+ even though ` f ` is not in scope in the outer crate:
269
+
270
+ ``` rust
271
+ // inner-crate
272
+
273
+ pub fn f () {}
274
+ /// This links to [f].
275
+ pub fn g () {}
276
+ ```
277
+
278
+ ``` rust
279
+ // outer-crate
280
+ pub use inner_crate :: g;
281
+ ```
282
+
283
+ ### Links to private items
284
+
285
+ If a public item links to a private one, and ` --document-private-items ` is not passed,
286
+ rustdoc should give a warning. If a private item links to another private
287
+ item, no warning should be emitted. If a public item links to another private
288
+ item and ` --document-private-items ` is passed, rustdoc should emit the link,
289
+ but it is up to the implementation whether to give a warning.
290
+
263
291
## Path Ambiguities
264
292
[ path-ambiguities ] : #path-ambiguities
265
293
@@ -287,7 +315,7 @@ Our proposal is this:
287
315
- In unambiguous cases paths can be written as described earlier,
288
316
with no pre- or suffix, e.g., ` Look at the [FOO] trait ` . This also
289
317
applies to modules and tuple structs which exist in both namespaces.
290
- Rustdoc will throw an error if you use a non-disambiguated path in
318
+ Rustdoc will throw a warning if you use a non-disambiguated path in
291
319
the case of there being a value in both the type and value namespace.
292
320
- Links to types can be disambiguated by prefixing them with the concrete
293
321
item type:
@@ -326,18 +354,9 @@ Our proposal is this:
326
354
- It is possible that disambiguators for one kind of type-namespace object
327
355
will work for the other (i.e. you can use ` static@ ` to refer to a const),
328
356
329
- For disambiguation markers using an ` @ ` , in implied shortcut links
330
- you can use a space instead of the ` @ ` . In other words, ` [struct Foo] `
331
- is fine (and preferred).
332
-
333
- It should be noted that in the RFC discussion it was determined
334
- that exact knowledge of the item type
335
- should not be necessary; only knowing the namespace should suffice.
336
- It is acceptable that the tool resolving the links
337
- allows (and successfully resolves) a link
338
- with the wrong prefix that is in the same namespace.
339
- E.g., given an ` struct Foo ` , it may be possible to link to it using ` [enum Foo] ` ,
340
- or, given a ` mod bar ` , it may be possible to link to that using ` [struct bar] ` .
357
+ If a disambiguator for a type does not match, rustdoc should issue a warning.
358
+ For example, given ` struct@Foo ` , attempting to link to it using ` [enum@Foo] `
359
+ should not be allowed.
341
360
342
361
## Errors
343
362
[ errors ] : #errors
@@ -452,6 +471,29 @@ like `See the [<Foo as Bar>::bar()] method`.
452
471
We have yet to analyze in which cases this is necessary,
453
472
and what syntax should be used.
454
473
474
+ ### Traits in scope
475
+
476
+ If linking to an associated item that comes from a trait,
477
+ the link should only be resolved in the trait is in scope.
478
+ This prevents ambiguities if multiple traits are available with the associated item.
479
+ For example, this should issue a warning:
480
+
481
+ ``` rust
482
+ #[derive(Debug )]
483
+ /// Link to [S::fmt]
484
+ struct S ;`
485
+ ```
486
+
487
+ but this should link to the implementation of ` Debug::fmt ` for ` S ` :
488
+
489
+ ``` rust
490
+ use std :: fmt :: Debug ;
491
+
492
+ #[derive(Debug )]
493
+ /// Link to [S::fmt]
494
+ struct S ;`
495
+ ```
496
+
455
497
[ ref-ufcs ] : https://github.com/rust-lang-nursery/reference/blob/96e976d32a0a6927dd26c2ee805aaf44ef3bef2d/src/expressions.md#disambiguating-function-calls
456
498
457
499
## Linking to External Documentation
0 commit comments