Rollup merge of #101765 - GuillaumeGomez:tyctxt-visibility-doc, r=jyn514

Add documentation for TyCtxt::visibility

We encountered this issue while working on https://github.com/rust-lang/rust/pull/98450.

cc ``@lqd``
r? ``@cjgillot``
This commit is contained in:
Matthias Krüger 2022-09-13 22:25:38 +02:00 committed by GitHub
commit 68dc6396a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1611,6 +1611,16 @@
desc { "looking up late bound vars" }
}
/// Computes the visibility of the provided `def_id`.
///
/// If the item from the `def_id` doesn't have a visibility, it will panic. For example
/// a generic type parameter will panic if you call this method on it:
///
/// ```
/// pub trait Foo<T: Debug> {}
/// ```
///
/// In here, if you call `visibility` on `T`, it'll panic.
query visibility(def_id: DefId) -> ty::Visibility<DefId> {
desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
separate_provide_extern