diff --git a/Cargo.toml b/Cargo.toml
index 6895dcc3c8..f7e3ae51df 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ authors = ["rust-analyzer team"]
[profile.dev]
# Disabling debug info speeds up builds a bunch,
# and we don't rely on it for debugging that much.
-debug = 1
+debug = 0
[profile.dev.package]
# These speed up local tests.
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index 17ad85b6c5..2de1aa30c9 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -428,6 +428,17 @@ impl MirEvalError {
}
Ok(())
}
+
+ pub fn is_panic(&self) -> Option<&str> {
+ let mut err = self;
+ while let MirEvalError::InFunction(e, _) = err {
+ err = e;
+ }
+ match err {
+ MirEvalError::Panic(msg) => Some(msg),
+ _ => None,
+ }
+ }
}
impl std::fmt::Debug for MirEvalError {
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs
index e2ff67a092..3438712049 100644
--- a/crates/hir-ty/src/mir/eval/shim.rs
+++ b/crates/hir-ty/src/mir/eval/shim.rs
@@ -360,7 +360,7 @@ impl Evaluator<'_> {
))
};
}
- let size = self.size_of_sized(&ty, locals, "begin panic arg")?;
+ let size = self.size_of_sized(ty, locals, "begin panic arg")?;
let pointee = arg.interval.get(self)?;
arg = IntervalAndTy {
interval: Interval::new(Address::from_bytes(pointee)?, size),
diff --git a/crates/hir-ty/src/mir/eval/tests.rs b/crates/hir-ty/src/mir/eval/tests.rs
index e88fbd19a4..4abbda56cb 100644
--- a/crates/hir-ty/src/mir/eval/tests.rs
+++ b/crates/hir-ty/src/mir/eval/tests.rs
@@ -73,6 +73,13 @@ fn check_pass_and_stdio(ra_fixture: &str, expected_stdout: &str, expected_stderr
}
}
+fn check_panic(ra_fixture: &str, expected_panic: &str) {
+ let (db, file_ids) = TestDB::with_many_files(ra_fixture);
+ let file_id = *file_ids.last().unwrap();
+ let e = eval_main(&db, file_id).unwrap_err();
+ assert_eq!(e.is_panic().unwrap_or_else(|| panic!("unexpected error: {:?}", e)), expected_panic);
+}
+
#[test]
fn function_with_extern_c_abi() {
check_pass(
@@ -96,13 +103,14 @@ fn panic_fmt() {
// -> core::panicking::const_panic_fmt
// -> #[rustc_const_panic_str] core::panicking::panic_display (hooked by CTFE for builtin panic)
// -> Err(ConstEvalError::Panic)
- check_pass(
+ check_panic(
r#"
//- minicore: fmt, panic
fn main() {
panic!("hello, world!");
}
"#,
+ "hello, world!",
);
}
@@ -112,7 +120,7 @@ fn panic_display() {
// -> panic_2021 (builtin macro redirection)
// -> #[rustc_const_panic_str] core::panicking::panic_display (hooked by CTFE for builtin panic)
// -> Err(ConstEvalError::Panic)
- check_pass(
+ check_panic(
r#"
//- minicore: fmt, panic
@@ -120,6 +128,7 @@ fn main() {
panic!("{}", "hello, world!");
}
"#,
+ "hello, world!",
);
}
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index bb5c2b7913..cd5e95cc1e 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -293,6 +293,7 @@ fn minicore_smoke_test() {
// This should be ignored since we conditionally remove code which creates single item use with braces
config.disabled.insert("unused_braces".to_owned());
config.disabled.insert("unused_variables".to_owned());
+ config.disabled.insert("remove-unnecessary-else".to_owned());
check_diagnostics_with_config(config, &source);
}
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 67f10f0374..48a2775ce7 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -7864,8 +7864,8 @@ impl Iterator for S {
file_id: FileId(
1,
),
- full_range: 6290..6498,
- focus_range: 6355..6361,
+ full_range: 7791..7999,
+ focus_range: 7856..7862,
name: "Future",
kind: Trait,
container_name: "future",
@@ -7878,8 +7878,8 @@ impl Iterator for S {
file_id: FileId(
1,
),
- full_range: 7128..7594,
- focus_range: 7172..7180,
+ full_range: 8629..9095,
+ focus_range: 8673..8681,
name: "Iterator",
kind: Trait,
container_name: "iterator",
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html b/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html
index 366895ce7e..893e3c0675 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_default_library.html
@@ -49,5 +49,5 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
fn main() {
let foo = Some(92);
- let nums = iter::repeat(foo.unwrap());
+ let nums = iter::repeat(foo.unwrap());
}
\ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
index 7a07d17b27..22706dea1f 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html
@@ -158,9 +158,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
println!("{ничоси}", ничоси = 92);
println!("{:x?} {} ", thingy, n2);
- panic!("{}", 0);
+ panic!("{}", 0);
panic!("more {}", 1);
- assert!(true, "{}", 1);
+ assert!(true, "{}", 1);
assert!(true, "{} asdasd", 1);
toho!("{}fmt", 0);
let i: u64 = 3;
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index c50a5fa669..0257ed9ab4 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -28,7 +28,7 @@
//! env: option
//! eq: sized
//! error: fmt
-//! fmt: option, result, transmute, coerce_unsized
+//! fmt: option, result, transmute, coerce_unsized, copy, clone, derive
//! fn:
//! from: sized
//! future: pin
@@ -919,6 +919,7 @@ pub mod fmt {
type Opaque;
}
+ #[derive(Copy, Clone)]
#[lang = "format_argument"]
pub struct Argument<'a> {
value: &'a Opaque,
@@ -986,6 +987,7 @@ pub mod fmt {
}
}
+ #[derive(Copy, Clone)]
#[lang = "format_arguments"]
pub struct Arguments<'a> {
pieces: &'a [&'static str],
@@ -1421,6 +1423,7 @@ mod panicking {
}
// endregion:panic
+#[macro_use]
mod macros {
// region:panic
#[macro_export]