diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-01-20 07:16:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-20 07:16:09 +0100 |
| commit | a2712cb4b641d408f2f00d418883c159abaee280 (patch) | |
| tree | 85dfdf1e1bc49fa07ac578fa4f58c7b062b7ae76 | |
| parent | 240cc81768f678bb4a6f8369080ef77515971963 (diff) | |
| parent | b7cb77fed9436918e80424a929f8b586d4795a6c (diff) | |
| download | rust-a2712cb4b641d408f2f00d418883c159abaee280.tar.gz rust-a2712cb4b641d408f2f00d418883c159abaee280.zip | |
Rollup merge of #106979 - Nilstrieb:type-of-default-assoc-type, r=petrochenkov
Document how to get the type of a default associated type
| -rw-r--r-- | compiler/rustc_middle/src/ty/assoc.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 859a58c8998..bb7fba3ee71 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -37,6 +37,11 @@ impl AssocItem { Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap()) } + /// Gets the defaultness of the associated item. + /// To get the default associated type, use the [`type_of`] query on the + /// [`DefId`] of the type. + /// + /// [`type_of`]: crate::ty::TyCtxt::type_of pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness { tcx.impl_defaultness(self.def_id) } |
