Skip to content

Commit

Permalink
[intra-doc links] Don't check feature gates of items re-exported acro…
Browse files Browse the repository at this point in the history
…ss crates

It should be never break another crate to re-export a public item.

Note that this doesn't check the feature gate at
*all* for other crates:

- Feature-gates aren't currently serialized, so the only way to check
  the gate is with ad-hoc attribute checking.
- Checking the feature gate twice (once when documenting the original
  crate and one when documenting the current crate) seems not great.

This should still catch using the feature most of the time though, since
people tend to document their own crates.
  • Loading branch information
jyn514 committed Feb 19, 2021
1 parent 8599bff commit fdb32e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,10 @@ impl LinkCollector<'_, '_> {
// for discussion on the matter.
verify(kind, id)?;

// FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether.
// However I'm not sure how to check that across crates.
if prim == PrimitiveType::RawPointer
&& item.def_id.is_local()
&& !self.cx.tcx.features().intra_doc_pointers
{
let span = super::source_span_for_markdown_range(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(intra_doc_pointers)]
#![crate_name = "inner"]
/// Link to [some pointer](*const::to_raw_parts)
pub fn foo() {}
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// aux-build:pointer-reexports-allowed.rs
// check-pass
extern crate inner;
pub use inner::foo;

0 comments on commit fdb32e9

Please sign in to comment.