aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r--crates/hir_ty/src/tests/macros.rs46
-rw-r--r--crates/hir_ty/src/tests/regression.rs18
-rw-r--r--crates/hir_ty/src/tests/simple.rs16
3 files changed, 80 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index a7656b864..1953da7be 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -540,6 +540,52 @@ fn bar() -> u32 {0}
540} 540}
541 541
542#[test] 542#[test]
543fn infer_builtin_macros_include_str() {
544 check_types(
545 r#"
546//- /main.rs
547#[rustc_builtin_macro]
548macro_rules! include_str {() => {}}
549
550fn main() {
551 let a = include_str!("foo.rs");
552 a;
553} //^ &str
554
555//- /foo.rs
556hello
557"#,
558 );
559}
560
561#[test]
562fn infer_builtin_macros_include_str_with_lazy_nested() {
563 check_types(
564 r#"
565//- /main.rs
566#[rustc_builtin_macro]
567macro_rules! concat {() => {}}
568#[rustc_builtin_macro]
569macro_rules! include_str {() => {}}
570
571macro_rules! m {
572 ($x:expr) => {
573 concat!("foo", $x)
574 };
575}
576
577fn main() {
578 let a = include_str!(m!(".rs"));
579 a;
580} //^ &str
581
582//- /foo.rs
583hello
584"#,
585 );
586}
587
588#[test]
543#[ignore] 589#[ignore]
544fn include_accidentally_quadratic() { 590fn include_accidentally_quadratic() {
545 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); 591 let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic");
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index 307a257b1..cffe8630b 100644
--- a/crates/hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
@@ -326,6 +326,24 @@ fn infer_paren_macro_call() {
326} 326}
327 327
328#[test] 328#[test]
329fn infer_array_macro_call() {
330 check_infer(
331 r#"
332 macro_rules! bar { () => {0u32} }
333 fn test() {
334 let a = [bar!()];
335 }
336 "#,
337 expect![[r#"
338 !0..4 '0u32': u32
339 44..69 '{ ...()]; }': ()
340 54..55 'a': [u32; _]
341 58..66 '[bar!()]': [u32; _]
342 "#]],
343 );
344}
345
346#[test]
329fn bug_1030() { 347fn bug_1030() {
330 check_infer( 348 check_infer(
331 r#" 349 r#"
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index a61282d5a..8d431b920 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -2375,3 +2375,19 @@ fn infer_operator_overload() {
2375 "#]], 2375 "#]],
2376 ); 2376 );
2377} 2377}
2378
2379#[test]
2380fn infer_const_params() {
2381 check_infer(
2382 r#"
2383 fn foo<const FOO: usize>() {
2384 let bar = FOO;
2385 }
2386 "#,
2387 expect![[r#"
2388 27..49 '{ ...FOO; }': ()
2389 37..40 'bar': usize
2390 43..46 'FOO': usize
2391 "#]],
2392 );
2393}