From 8dc68ecdfcc764c7c0dcf5fcedcb51b092d99620 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Jan 2021 18:25:19 +0300 Subject: Introduce more appropriate assertion mechanism rust-analyzer is a long-running program, so we *should* handle assertion failures. See also https://www.sqlite.org/assert.html. --- crates/completion/src/completions/qualified_path.rs | 3 +-- crates/completion/src/completions/unqualified_path.rs | 6 ++---- crates/completion/src/item.rs | 4 ++++ 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/completion') diff --git a/crates/completion/src/completions/qualified_path.rs b/crates/completion/src/completions/qualified_path.rs index fa9e6e810..33df26761 100644 --- a/crates/completion/src/completions/qualified_path.rs +++ b/crates/completion/src/completions/qualified_path.rs @@ -590,8 +590,7 @@ fn main() { let _ = crate::$0 } "#, expect![[r##" fn main() fn main() - ma foo!(…) #[macro_export] - macro_rules! foo + ma foo!(…) #[macro_export] macro_rules! foo "##]], ); } diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 7ba99447d..53e1391f3 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -540,8 +540,7 @@ mod macros { "#, expect![[r##" fn f() fn f() - ma concat!(…) #[macro_export] - macro_rules! concat + ma concat!(…) #[macro_export] macro_rules! concat md std "##]], ); @@ -597,8 +596,7 @@ fn main() { let v = $0 } "#, expect![[r##" md m1 - ma baz!(…) #[macro_export] - macro_rules! baz + ma baz!(…) #[macro_export] macro_rules! baz fn main() fn main() md m2 ma bar!(…) macro_rules! bar diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index 35af354b0..0134ff219 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs @@ -7,6 +7,7 @@ use ide_db::helpers::{ insert_use::{self, ImportScope, MergeBehavior}, mod_path_to_ast, SnippetCap, }; +use stdx::assert_never; use syntax::{algo, TextRange}; use text_edit::TextEdit; @@ -396,6 +397,9 @@ impl Builder { } pub(crate) fn set_detail(mut self, detail: Option>) -> Builder { self.detail = detail.map(Into::into); + if let Some(detail) = &self.detail { + assert_never!(detail.contains('\n'), "multiline detail: {}", detail); + } self } #[allow(unused)] -- cgit v1.2.3