aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/tests/traits.rs45
1 files changed, 7 insertions, 38 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index dd1ea817f..0b6a3a1e9 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -567,11 +567,11 @@ fn indexing_arrays() {
567fn infer_ops_index() { 567fn infer_ops_index() {
568 check_types( 568 check_types(
569 r#" 569 r#"
570//- /main.rs crate:main deps:std 570//- minicore: index
571struct Bar; 571struct Bar;
572struct Foo; 572struct Foo;
573 573
574impl std::ops::Index<u32> for Bar { 574impl core::ops::Index<u32> for Bar {
575 type Output = Foo; 575 type Output = Foo;
576} 576}
577 577
@@ -580,15 +580,6 @@ fn test() {
580 let b = a[1u32]; 580 let b = a[1u32];
581 b; 581 b;
582} //^ Foo 582} //^ Foo
583
584//- /std.rs crate:std
585#[prelude_import] use ops::*;
586mod ops {
587 #[lang = "index"]
588 pub trait Index<Idx> {
589 type Output;
590 }
591}
592"#, 583"#,
593 ); 584 );
594} 585}
@@ -597,16 +588,16 @@ mod ops {
597fn infer_ops_index_int() { 588fn infer_ops_index_int() {
598 check_types( 589 check_types(
599 r#" 590 r#"
600//- /main.rs crate:main deps:std 591//- minicore: index
601struct Bar; 592struct Bar;
602struct Foo; 593struct Foo;
603 594
604impl std::ops::Index<u32> for Bar { 595impl core::ops::Index<u32> for Bar {
605 type Output = Foo; 596 type Output = Foo;
606} 597}
607 598
608struct Range; 599struct Range;
609impl std::ops::Index<Range> for Bar { 600impl core::ops::Index<Range> for Bar {
610 type Output = Bar; 601 type Output = Bar;
611} 602}
612 603
@@ -616,15 +607,6 @@ fn test() {
616 b; 607 b;
617 //^ Foo 608 //^ Foo
618} 609}
619
620//- /std.rs crate:std
621#[prelude_import] use ops::*;
622mod ops {
623 #[lang = "index"]
624 pub trait Index<Idx> {
625 type Output;
626 }
627}
628"#, 610"#,
629 ); 611 );
630} 612}
@@ -633,25 +615,12 @@ mod ops {
633fn infer_ops_index_autoderef() { 615fn infer_ops_index_autoderef() {
634 check_types( 616 check_types(
635 r#" 617 r#"
636//- /main.rs crate:main deps:std 618//- minicore: index, slice
637fn test() { 619fn test() {
638 let a = &[1u32, 2, 3]; 620 let a = &[1u32, 2, 3];
639 let b = a[1u32]; 621 let b = a[1];
640 b; 622 b;
641} //^ u32 623} //^ u32
642
643//- /std.rs crate:std
644impl<T> ops::Index<u32> for [T] {
645 type Output = T;
646}
647
648#[prelude_import] use ops::*;
649mod ops {
650 #[lang = "index"]
651 pub trait Index<Idx> {
652 type Output;
653 }
654}
655"#, 624"#,
656 ); 625 );
657} 626}