From 2025f17ac394fc75528bb61422f15c5861a0fa8b Mon Sep 17 00:00:00 2001 From: Ddystopia Date: Mon, 1 May 2023 10:16:36 +0200 Subject: [PATCH] Workspace without sysroot could be possible --- crates/ide/src/doc_links.rs | 18 ++++++++---------- crates/rust-analyzer/src/handlers/request.rs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index 92021da4c09..597b28d36d7 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -148,17 +148,15 @@ pub(crate) fn external_docs( let node = token.parent()?; let definition = match_ast! { match node { - ast::NameRef(name_ref) => match NameRefClass::classify(sema, &name_ref) { - Some(NameRefClass::Definition(def)) => def, - Some(NameRefClass::FieldShorthand { local_ref: _, field_ref }) => { + ast::NameRef(name_ref) => match NameRefClass::classify(sema, &name_ref)? { + NameRefClass::Definition(def) => def, + NameRefClass::FieldShorthand { local_ref: _, field_ref } => { Definition::Field(field_ref) } - None => return None, }, - ast::Name(name) => match NameClass::classify(sema, &name) { - Some(NameClass::Definition(it) | NameClass::ConstReference(it)) => it, - Some(NameClass::PatFieldShorthand { local_def: _, field_ref }) => Definition::Field(field_ref), - None => return None, + ast::Name(name) => match NameClass::classify(sema, &name)? { + NameClass::Definition(it) | NameClass::ConstReference(it) => it, + NameClass::PatFieldShorthand { local_def: _, field_ref } => Definition::Field(field_ref), }, _ => return None } @@ -347,10 +345,10 @@ fn get_doc_links( web_url.as_mut().map(|url| url.set_fragment(frag.as_deref())); local_url.as_mut().map(|url| url.set_fragment(frag.as_deref())); - return DocumentationLinks { + DocumentationLinks { web_url: web_url.map(|it| it.into()), local_url: local_url.map(|it| it.into()), - }; + } } fn rewrite_intra_doc_link( diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index b8e7c85b043..3a208865a78 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -1546,7 +1546,7 @@ pub(crate) fn handle_open_docs( }); let (cargo, sysroot) = match ws_and_sysroot { - Some((ws, Some(sysroot))) => (Some(ws), Some(sysroot)), + Some((ws, sysroot)) => (Some(ws), sysroot), _ => (None, None), };