aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/traits.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-25 14:02:31 +0100
committerGitHub <[email protected]>2021-05-25 14:02:31 +0100
commitddc2fb392303379316b84da3cdcb281d8413e18a (patch)
treef4056812324bc4c27a188092e280e49bc1fefc1b /crates/hir_ty/src/tests/traits.rs
parent835cf55887527bd1953cb7004259214f7c215095 (diff)
parent3ee4e6c54c0bb9586c607dd8890d58fb21c95259 (diff)
Merge #8989
8989: fix: Fix type inference not working for new Try trait r=Veykril a=Veykril Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8907 bors r+ Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/tests/traits.rs')
-rw-r--r--crates/hir_ty/src/tests/traits.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index a5a2df54c..71905baeb 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -161,6 +161,43 @@ mod result {
161} 161}
162 162
163#[test] 163#[test]
164fn infer_tryv2() {
165 check_types(
166 r#"
167//- /main.rs crate:main deps:core
168fn test() {
169 let r: Result<i32, u64> = Result::Ok(1);
170 let v = r?;
171 v;
172} //^ i32
173
174//- /core.rs crate:core
175#[prelude_import] use ops::*;
176mod ops {
177 trait Try {
178 type Output;
179 type Residual;
180 }
181}
182
183#[prelude_import] use result::*;
184mod result {
185 enum Infallible {}
186 enum Result<O, E> {
187 Ok(O),
188 Err(E)
189 }
190
191 impl<O, E> crate::ops::Try for Result<O, E> {
192 type Output = O;
193 type Error = Result<Infallible, E>;
194 }
195}
196"#,
197 );
198}
199
200#[test]
164fn infer_for_loop() { 201fn infer_for_loop() {
165 check_types( 202 check_types(
166 r#" 203 r#"