mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
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.
This commit is contained in:
parent
865e05b5b4
commit
8dc68ecdfc
8 changed files with 72 additions and 7 deletions
|
@ -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
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<impl Into<String>>) -> Builder {
|
||||
self.detail = detail.map(Into::into);
|
||||
if let Some(detail) = &self.detail {
|
||||
assert_never!(detail.contains('\n'), "multiline detail: {}", detail);
|
||||
}
|
||||
self
|
||||
}
|
||||
#[allow(unused)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue