aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/tests/traits.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index c93ff91ee..1879dbc78 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -3469,3 +3469,50 @@ pub trait Deserialize {
3469 "#, 3469 "#,
3470 ); 3470 );
3471} 3471}
3472
3473#[test]
3474fn bin_op_adt_with_rhs_primitive() {
3475 check_infer_with_mismatches(
3476 r#"
3477#[lang = "add"]
3478pub trait Add<Rhs = Self> {
3479 type Output;
3480 fn add(self, rhs: Rhs) -> Self::Output;
3481}
3482
3483struct Wrapper(u32);
3484impl Add<u32> for Wrapper {
3485 type Output = Self;
3486 fn add(self, rhs: u32) -> Wrapper {
3487 Wrapper(rhs)
3488 }
3489}
3490fn main(){
3491 let wrapped = Wrapper(10);
3492 let num: u32 = 2;
3493 let res = wrapped + num;
3494
3495}"#,
3496 expect![[r#"
3497 72..76 'self': Self
3498 78..81 'rhs': Rhs
3499 192..196 'self': Wrapper
3500 198..201 'rhs': u32
3501 219..247 '{ ... }': Wrapper
3502 229..236 'Wrapper': Wrapper(u32) -> Wrapper
3503 229..241 'Wrapper(rhs)': Wrapper
3504 237..240 'rhs': u32
3505 259..345 '{ ...um; }': ()
3506 269..276 'wrapped': Wrapper
3507 279..286 'Wrapper': Wrapper(u32) -> Wrapper
3508 279..290 'Wrapper(10)': Wrapper
3509 287..289 '10': u32
3510 300..303 'num': u32
3511 311..312 '2': u32
3512 322..325 'res': Wrapper
3513 328..335 'wrapped': Wrapper
3514 328..341 'wrapped + num': Wrapper
3515 338..341 'num': u32
3516 "#]],
3517 )
3518}