This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
src/tools/rust-analyzer/crates/ide/src/inlay_hints Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ fn variant_hints(
9090 kind : InlayKind :: Discriminant ,
9191 label,
9292 text_edit : d. ok ( ) . map ( |val| {
93- config. lazy_text_edit ( || TextEdit :: insert ( range. start ( ) , format ! ( "{eq_} {val}" ) ) )
93+ config. lazy_text_edit ( || TextEdit :: insert ( range. end ( ) , format ! ( "{eq_} {val}" ) ) )
9494 } ) ,
9595 position : InlayHintPosition :: After ,
9696 pad_left : false ,
@@ -102,8 +102,10 @@ fn variant_hints(
102102}
103103#[ cfg( test) ]
104104mod tests {
105+ use expect_test:: expect;
106+
105107 use crate :: inlay_hints:: {
106- tests:: { check_with_config, DISABLED_CONFIG } ,
108+ tests:: { check_edit , check_with_config, DISABLED_CONFIG } ,
107109 DiscriminantHints , InlayHintsConfig ,
108110 } ;
109111
@@ -210,4 +212,33 @@ enum Enum {
210212"# ,
211213 ) ;
212214 }
215+
216+ #[ test]
217+ fn edit ( ) {
218+ check_edit (
219+ InlayHintsConfig { discriminant_hints : DiscriminantHints :: Always , ..DISABLED_CONFIG } ,
220+ r#"
221+ #[repr(u8)]
222+ enum Enum {
223+ Variant(),
224+ Variant1,
225+ Variant2 {},
226+ Variant3,
227+ Variant5,
228+ Variant6,
229+ }
230+ "# ,
231+ expect ! [ [ r#"
232+ #[repr(u8)]
233+ enum Enum {
234+ Variant() = 0,
235+ Variant1 = 1,
236+ Variant2 {} = 2,
237+ Variant3 = 3,
238+ Variant5 = 4,
239+ Variant6 = 5,
240+ }
241+ "# ] ] ,
242+ ) ;
243+ }
213244}
You can’t perform that action at this time.
0 commit comments