Rollup merge of #104052 - TaKO8Ki:fix-103997, r=notriddle

Fix `resolution_failure` ICE

Fixes #103997
This commit is contained in:
Dylan DPC 2022-11-07 18:35:26 +05:30 committed by GitHub
commit 498efa6273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -402,6 +402,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
})
.and_then(|self_id| match tcx.def_kind(self_id) {
DefKind::Impl => self.def_id_to_res(self_id),
DefKind::Use => None,
def_kind => Some(Res::Def(def_kind, self_id)),
})
}
@ -1772,7 +1773,6 @@ fn resolution_failure(
// Otherwise, it must be an associated item or variant
let res = partial_res.expect("None case was handled by `last_found_module`");
let name = res.name(tcx);
let kind = match res {
Res::Def(kind, _) => Some(kind),
Res::Primitive(_) => None,
@ -1814,6 +1814,7 @@ fn resolution_failure(
} else {
"associated item"
};
let name = res.name(tcx);
let note = format!(
"the {} `{}` has no {} named `{}`",
res.descr(),

View File

@ -0,0 +1,6 @@
// check-pass
pub fn foo() {}
/// [`foo`](Self::foo) //~ WARNING unresolved link to `Self::foo`
pub use foo as bar;

View File

@ -0,0 +1,10 @@
warning: unresolved link to `Self::foo`
--> $DIR/issue-103997.rs:5:13
|
LL | /// [`foo`](Self::foo)
| ^^^^^^^^^ no item named `Self` in scope
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: 1 warning emitted