Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't pollute docs/suggestions with libstd deps #73771

Merged
merged 1 commit into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// legal to implement.
let mut candidates = all_traits(self.tcx)
.into_iter()
// Don't issue suggestions for unstable traits since they're
// unlikely to be implementable anyway
.filter(|info| match self.tcx.lookup_stability(info.def_id) {
Some(attr) => attr.level.is_stable(),
None => true,
})
.filter(|info| {
// We approximate the coherence rules to only suggest
// traits that are legal to implement by requiring that
Expand Down
10 changes: 10 additions & 0 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ pub fn build_impl(
return;
}
}

// Skip foreign unstable traits from lists of trait implementations and
// such. This helps prevent dependencies of the standard library, for
// example, from getting documented as "traits `u32` implements" which
// isn't really too helpful.
if let Some(stab) = cx.tcx.lookup_stability(did) {
if stab.level.is_unstable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to filter them out only on non-nightly builds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so because that still creates the same issues seen on #73441 where it causes broken links to appear in libstd's nightly documentation because libstd's internal dependencies aren't documented.

return;
}
}
}

let for_ = if let Some(did) = did.as_local() {
Expand Down