Test for Builtin Type

This commit is contained in:
Ddystopia 2023-04-26 19:55:17 +02:00
parent b74b9797bc
commit 8317c8db1a
No known key found for this signature in database
GPG Key ID: 109875EC11535212
2 changed files with 14 additions and 1 deletions

View File

@ -473,7 +473,7 @@ fn get_doc_base_urls(
// https://github.com/rust-lang/rust-analyzer/issues/12250 // https://github.com/rust-lang/rust-analyzer/issues/12250
if let Definition::BuiltinType(..) = def { if let Definition::BuiltinType(..) = def {
let weblink = Url::parse("https://doc.rust-lang.org/nightly/core/").ok(); let weblink = Url::parse("https://doc.rust-lang.org/nightly/core/").ok();
return (weblink, local_doc_path); return (weblink, None);
}; };
let Some(krate) = def.krate(db) else { return Default::default() }; let Some(krate) = def.krate(db) else { return Default::default() };

View File

@ -119,6 +119,19 @@ fn node_to_def(
}) })
} }
#[test]
fn external_docs_doc_builtin_type() {
check_external_docs(
r#"
//- /main.rs crate:foo
let x: u3$02 = 0;
"#,
Some(&OsStr::new("/home/user/project")),
Some(expect![[r#"https://doc.rust-lang.org/nightly/core/primitive.u32.html"#]]),
None,
);
}
#[test] #[test]
fn external_docs_doc_url_crate() { fn external_docs_doc_url_crate() {
check_external_docs( check_external_docs(