aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-23 15:55:03 +0100
committerGitHub <[email protected]>2020-06-23 15:55:03 +0100
commitc0b9ae55034fd29a86f52822634fcb1c1303e7f9 (patch)
tree4a97c8939ae27fa3c3f30fa46729383a71b810e7 /crates/ra_assists
parent3e09dbba94de103d4d7a211ec578b049d0adc3c7 (diff)
parent76ddface089886c88b8b29e3893119f38ef26aab (diff)
Merge #5004
5004: Fix panic in split/merge import assists r=matklad a=lnicola Fixes #4368 #4905 Not sure if this is the best solution here. Maybe the `make` functions should be fallible? We generally seem to be playing whack-a-mole with panics in assists, although most of them are `unwrap`s in the assist code. Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs12
-rw-r--r--crates/ra_assists/src/handlers/split_import.rs10
2 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs
index 972d16241..ac0b3035c 100644
--- a/crates/ra_assists/src/handlers/merge_imports.rs
+++ b/crates/ra_assists/src/handlers/merge_imports.rs
@@ -127,7 +127,7 @@ fn first_path(path: &ast::Path) -> ast::Path {
127 127
128#[cfg(test)] 128#[cfg(test)]
129mod tests { 129mod tests {
130 use crate::tests::check_assist; 130 use crate::tests::{check_assist, check_assist_not_applicable};
131 131
132 use super::*; 132 use super::*;
133 133
@@ -276,4 +276,14 @@ bar::baz};
276", 276",
277 ) 277 )
278 } 278 }
279
280 #[test]
281 fn test_empty_use() {
282 check_assist_not_applicable(
283 merge_imports,
284 r"
285use std::<|>
286fn main() {}",
287 );
288 }
279} 289}
diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs
index c7a874480..38aa199a0 100644
--- a/crates/ra_assists/src/handlers/split_import.rs
+++ b/crates/ra_assists/src/handlers/split_import.rs
@@ -66,4 +66,14 @@ mod tests {
66 fn issue4044() { 66 fn issue4044() {
67 check_assist_not_applicable(split_import, "use crate::<|>:::self;") 67 check_assist_not_applicable(split_import, "use crate::<|>:::self;")
68 } 68 }
69
70 #[test]
71 fn test_empty_use() {
72 check_assist_not_applicable(
73 split_import,
74 r"
75use std::<|>
76fn main() {}",
77 );
78 }
69} 79}