diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-24 11:40:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-24 11:40:47 +0100 |
commit | dff62def2ea31e7eb0b010c35d60cd53318eab80 (patch) | |
tree | b38e0574c56bfbad6459a9e1355c89cae7830d11 /crates/ra_hir_ty/src/tests | |
parent | 414b731e7d3ae4d7b939744a83c2530d4836ae05 (diff) | |
parent | 2bd9f0f0205e03f95ab83e8f579742618b97a609 (diff) |
Merge #5023
5023: Fix string literal inference in match r=flodiebold a=lnicola
Fixes #5020
r? @flodiebold
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/patterns.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/ra_hir_ty/src/tests/patterns.rs index 8fa296137..e5ef241ca 100644 --- a/crates/ra_hir_ty/src/tests/patterns.rs +++ b/crates/ra_hir_ty/src/tests/patterns.rs | |||
@@ -271,6 +271,63 @@ fn test() { | |||
271 | } | 271 | } |
272 | 272 | ||
273 | #[test] | 273 | #[test] |
274 | fn infer_pattern_match_string_literal() { | ||
275 | assert_snapshot!( | ||
276 | infer_with_mismatches(r#" | ||
277 | fn test() { | ||
278 | let s: &str = "hello"; | ||
279 | match s { | ||
280 | "hello" => {} | ||
281 | _ => {} | ||
282 | } | ||
283 | } | ||
284 | "#, true), | ||
285 | @r###" | ||
286 | 10..98 '{ ... } }': () | ||
287 | 20..21 's': &str | ||
288 | 30..37 '"hello"': &str | ||
289 | 43..96 'match ... }': () | ||
290 | 49..50 's': &str | ||
291 | 61..68 '"hello"': &str | ||
292 | 61..68 '"hello"': &str | ||
293 | 72..74 '{}': () | ||
294 | 83..84 '_': &str | ||
295 | 88..90 '{}': () | ||
296 | "### | ||
297 | ); | ||
298 | } | ||
299 | |||
300 | #[test] | ||
301 | fn infer_pattern_match_or() { | ||
302 | assert_snapshot!( | ||
303 | infer_with_mismatches(r#" | ||
304 | fn test() { | ||
305 | let s: &str = "hello"; | ||
306 | match s { | ||
307 | "hello" | "world" => {} | ||
308 | _ => {} | ||
309 | } | ||
310 | } | ||
311 | "#, true), | ||
312 | @r###" | ||
313 | 10..108 '{ ... } }': () | ||
314 | 20..21 's': &str | ||
315 | 30..37 '"hello"': &str | ||
316 | 43..106 'match ... }': () | ||
317 | 49..50 's': &str | ||
318 | 61..68 '"hello"': &str | ||
319 | 61..68 '"hello"': &str | ||
320 | 61..78 '"hello...world"': &str | ||
321 | 71..78 '"world"': &str | ||
322 | 71..78 '"world"': &str | ||
323 | 82..84 '{}': () | ||
324 | 93..94 '_': &str | ||
325 | 98..100 '{}': () | ||
326 | "### | ||
327 | ); | ||
328 | } | ||
329 | |||
330 | #[test] | ||
274 | fn infer_pattern_match_arr() { | 331 | fn infer_pattern_match_arr() { |
275 | assert_snapshot!( | 332 | assert_snapshot!( |
276 | infer(r#" | 333 | infer(r#" |