Skip to content

Commit 1c8bcf0

Browse files
committed
Move inlay hints tests into implementation modules
1 parent 191cfba commit 1c8bcf0

File tree

9 files changed

+1844
-1777
lines changed

9 files changed

+1844
-1777
lines changed

crates/ide/src/inlay_hints.rs

Lines changed: 6 additions & 1777 deletions
Large diffs are not rendered by default.

crates/ide/src/inlay_hints/adjustment.rs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,112 @@ pub(super) fn hints(
100100
}
101101
Some(())
102102
}
103+
104+
#[cfg(test)]
105+
mod tests {
106+
use crate::{
107+
inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
108+
AdjustmentHints, InlayHintsConfig,
109+
};
110+
111+
#[test]
112+
fn adjustment_hints() {
113+
check_with_config(
114+
InlayHintsConfig { adjustment_hints: AdjustmentHints::Always, ..DISABLED_CONFIG },
115+
r#"
116+
//- minicore: coerce_unsized
117+
fn main() {
118+
let _: u32 = loop {};
119+
//^^^^^^^<never-to-any>
120+
let _: &u32 = &mut 0;
121+
//^^^^^^&
122+
//^^^^^^*
123+
let _: &mut u32 = &mut 0;
124+
//^^^^^^&mut $
125+
//^^^^^^*
126+
let _: *const u32 = &mut 0;
127+
//^^^^^^&raw const $
128+
//^^^^^^*
129+
let _: *mut u32 = &mut 0;
130+
//^^^^^^&raw mut $
131+
//^^^^^^*
132+
let _: fn() = main;
133+
//^^^^<fn-item-to-fn-pointer>
134+
let _: unsafe fn() = main;
135+
//^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
136+
//^^^^<fn-item-to-fn-pointer>
137+
let _: unsafe fn() = main as fn();
138+
//^^^^^^^^^^^^<safe-fn-pointer-to-unsafe-fn-pointer>
139+
let _: fn() = || {};
140+
//^^^^^<closure-to-fn-pointer>
141+
let _: unsafe fn() = || {};
142+
//^^^^^<closure-to-unsafe-fn-pointer>
143+
let _: *const u32 = &mut 0u32 as *mut u32;
144+
//^^^^^^^^^^^^^^^^^^^^^<mut-ptr-to-const-ptr>
145+
let _: &mut [_] = &mut [0; 0];
146+
//^^^^^^^^^^^<unsize>
147+
//^^^^^^^^^^^&mut $
148+
//^^^^^^^^^^^*
149+
150+
Struct.consume();
151+
Struct.by_ref();
152+
//^^^^^^(
153+
//^^^^^^&
154+
//^^^^^^)
155+
Struct.by_ref_mut();
156+
//^^^^^^(
157+
//^^^^^^&mut $
158+
//^^^^^^)
159+
160+
(&Struct).consume();
161+
//^^^^^^^*
162+
(&Struct).by_ref();
163+
164+
(&mut Struct).consume();
165+
//^^^^^^^^^^^*
166+
(&mut Struct).by_ref();
167+
//^^^^^^^^^^^&
168+
//^^^^^^^^^^^*
169+
(&mut Struct).by_ref_mut();
170+
171+
// Check that block-like expressions don't duplicate hints
172+
let _: &mut [u32] = (&mut []);
173+
//^^^^^^^<unsize>
174+
//^^^^^^^&mut $
175+
//^^^^^^^*
176+
let _: &mut [u32] = { &mut [] };
177+
//^^^^^^^<unsize>
178+
//^^^^^^^&mut $
179+
//^^^^^^^*
180+
let _: &mut [u32] = unsafe { &mut [] };
181+
//^^^^^^^<unsize>
182+
//^^^^^^^&mut $
183+
//^^^^^^^*
184+
let _: &mut [u32] = if true {
185+
&mut []
186+
//^^^^^^^<unsize>
187+
//^^^^^^^&mut $
188+
//^^^^^^^*
189+
} else {
190+
loop {}
191+
//^^^^^^^<never-to-any>
192+
};
193+
let _: &mut [u32] = match () { () => &mut [] }
194+
//^^^^^^^<unsize>
195+
//^^^^^^^&mut $
196+
//^^^^^^^*
197+
}
198+
199+
#[derive(Copy, Clone)]
200+
struct Struct;
201+
impl Struct {
202+
fn consume(self) {}
203+
fn by_ref(&self) {}
204+
fn by_ref_mut(&mut self) {}
205+
}
206+
trait Trait {}
207+
impl Trait for Struct {}
208+
"#,
209+
)
210+
}
211+
}

0 commit comments

Comments
 (0)