mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
clarify semantics of doc links
This commit is contained in:
parent
f9e06e6524
commit
aa1788dc71
1 changed files with 13 additions and 3 deletions
|
@ -11,7 +11,7 @@ use hir_def::{
|
||||||
};
|
};
|
||||||
use hir_expand::{hygiene::Hygiene, MacroDefId};
|
use hir_expand::{hygiene::Hygiene, MacroDefId};
|
||||||
use hir_ty::db::HirDatabase;
|
use hir_ty::db::HirDatabase;
|
||||||
use syntax::ast;
|
use syntax::{ast, AstNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Adt, AssocItem, Const, ConstParam, Enum, Field, Function, GenericParam, Impl, LifetimeParam,
|
Adt, AssocItem, Const, ConstParam, Enum, Field, Function, GenericParam, Impl, LifetimeParam,
|
||||||
|
@ -147,8 +147,18 @@ fn resolve_doc_path(
|
||||||
// FIXME
|
// FIXME
|
||||||
AttrDefId::MacroDefId(_) => return None,
|
AttrDefId::MacroDefId(_) => return None,
|
||||||
};
|
};
|
||||||
let path = ast::Path::parse(link).ok()?;
|
|
||||||
let modpath = ModPath::from_src(db.upcast(), path, &Hygiene::new_unhygienic())?;
|
let modpath = {
|
||||||
|
let ast_path = ast::SourceFile::parse(&format!("type T = {};", link))
|
||||||
|
.syntax_node()
|
||||||
|
.descendants()
|
||||||
|
.find_map(ast::Path::cast)?;
|
||||||
|
if ast_path.to_string() != link {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
ModPath::from_src(db.upcast(), ast_path, &Hygiene::new_unhygienic())?
|
||||||
|
};
|
||||||
|
|
||||||
let resolved = resolver.resolve_module_path_in_items(db.upcast(), &modpath);
|
let resolved = resolver.resolve_module_path_in_items(db.upcast(), &modpath);
|
||||||
let resolved = if resolved == PerNs::none() {
|
let resolved = if resolved == PerNs::none() {
|
||||||
resolver.resolve_module_path_in_trait_assoc_items(db.upcast(), &modpath)?
|
resolver.resolve_module_path_in_trait_assoc_items(db.upcast(), &modpath)?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue