diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-08-24 20:20:03 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-09-03 22:11:29 +0200 |
| commit | 6e43ff5ceafb2674af709f09e72c4f1f53eecf22 (patch) | |
| tree | 0a0e7dc5db8bd715afa3737a4a977cb8cb495251 | |
| parent | 6c44bcc4ffeb0ee8059c2c167388c69dedf1ea44 (diff) | |
| download | rust-6e43ff5ceafb2674af709f09e72c4f1f53eecf22.tar.gz rust-6e43ff5ceafb2674af709f09e72c4f1f53eecf22.zip | |
Add check for doc alias on associated const in trait impls
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 832cde86d0b..392070839dc 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -250,13 +250,23 @@ impl CheckAttrVisitor<'tcx> { None } } + Target::AssocConst => { + let parent_hir_id = self.tcx.hir().get_parent_item(hir_id); + let containing_item = self.tcx.hir().expect_item(parent_hir_id); + // We can't link to trait impl's consts. + let err = "associated constant in trait implementation block"; + match containing_item.kind { + ItemKind::Impl { of_trait: Some(_), .. } => Some(err), + _ => None, + } + } _ => None, } { self.tcx .sess .struct_span_err( meta.span(), - &format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err,), + &format!("`#[doc(alias = \"...\")]` isn't allowed on {}", err), ) .emit(); } |
