diff options
| author | Florian Diebold <flodiebold@gmail.com> | 2020-12-13 14:52:45 +0100 |
|---|---|---|
| committer | Florian Diebold <flodiebold@gmail.com> | 2020-12-13 14:53:04 +0100 |
| commit | 4788aaa5f07da85707b7bf409b5d25df1682a760 (patch) | |
| tree | dbe9c8211ce85e866b0d0658cfb74921f59a70a2 | |
| parent | 48802e54d1669c68fd27b007533dd6aa5221d089 (diff) | |
| download | rust-4788aaa5f07da85707b7bf409b5d25df1682a760.tar.gz rust-4788aaa5f07da85707b7bf409b5d25df1682a760.zip | |
Add test for #6852
| -rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 8cf4e701240..da817041704 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -883,3 +883,40 @@ fn issue_6628() { "#]], ); } + +#[test] +fn issue_6852() { + check_infer( + r#" + #[lang = "deref"] + pub trait Deref { + type Target; + } + + struct BufWriter {} + + struct Mutex<T> {} + struct MutexGuard<'a, T> {} + impl<T> Mutex<T> { + fn lock(&self) -> MutexGuard<'_, T> {} + } + impl<'a, T: 'a> Deref for MutexGuard<'a, T> { + type Target = T; + } + fn flush(&self) { + let w: &Mutex<BufWriter>; + *(w.lock()); + } + "#, + expect![[r#" + 156..160 'self': &Mutex<T> + 183..185 '{}': () + 267..271 'self': &{unknown} + 273..323 '{ ...()); }': () + 283..284 'w': &Mutex<BufWriter> + 309..320 '*(w.lock())': BufWriter + 311..312 'w': &Mutex<BufWriter> + 311..319 'w.lock()': MutexGuard<BufWriter> + "#]], + ); +} |
