]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide/src/inlay_hints/binding_mode.rs
Auto merge of #13806 - WaffleLapkin:typed_blÄhaj, r=Veykril
[rust.git] / crates / ide / src / inlay_hints / binding_mode.rs
index f8fe9f5819a58c84b25dc2ed75fd214a10aefb33..846f0a4e0c16d0c794a1d8fc7915a86edd0dbb71 100644 (file)
@@ -1,3 +1,7 @@
+//! Implementation of "binding mode" inlay hints:
+//! ```no_run
+//! let /* & */ (/* ref */ x,) = &(0,);
+//! ```
 use hir::{Mutability, Semantics};
 use ide_db::RootDatabase;
 
@@ -76,3 +80,62 @@ pub(super) fn hints(
 
     Some(())
 }
+
+#[cfg(test)]
+mod tests {
+    use crate::{
+        inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
+        InlayHintsConfig,
+    };
+
+    #[test]
+    fn hints_binding_modes() {
+        check_with_config(
+            InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG },
+            r#"
+fn __(
+    (x,): (u32,),
+    (x,): &(u32,),
+  //^^^^&
+   //^ ref
+    (x,): &mut (u32,)
+  //^^^^&mut
+   //^ ref mut
+) {
+    let (x,) = (0,);
+    let (x,) = &(0,);
+      //^^^^ &
+       //^ ref
+    let (x,) = &mut (0,);
+      //^^^^ &mut
+       //^ ref mut
+    let &mut (x,) = &mut (0,);
+    let (ref mut x,) = &mut (0,);
+      //^^^^^^^^^^^^ &mut
+    let &mut (ref mut x,) = &mut (0,);
+    let (mut x,) = &mut (0,);
+      //^^^^^^^^ &mut
+    match (0,) {
+        (x,) => ()
+    }
+    match &(0,) {
+        (x,) | (x,) => (),
+      //^^^^^^^^^^^&
+       //^ ref
+              //^ ref
+      //^^^^^^^^^^^(
+      //^^^^^^^^^^^)
+        ((x,) | (x,)) => (),
+      //^^^^^^^^^^^^^&
+        //^ ref
+               //^ ref
+    }
+    match &mut (0,) {
+        (x,) => ()
+      //^^^^ &mut
+       //^ ref mut
+    }
+}"#,
+        );
+    }
+}