@@ -185,7 +185,7 @@ fn fmt_help() {
185
185
#[ derive( Debug , Diagnostic , Error ) ]
186
186
#[ error( "welp" ) ]
187
187
#[ diagnostic( code( foo:: bar:: baz) , help( "{} x {0} x {:?}" , 1 , "2" ) ) ]
188
- struct FooStruct ( String ) ;
188
+ struct FooStruct < ' a > ( & ' a str ) ;
189
189
190
190
assert_eq ! (
191
191
"1 x hello x \" 2\" " . to_string( ) ,
@@ -195,8 +195,8 @@ fn fmt_help() {
195
195
#[ derive( Debug , Diagnostic , Error ) ]
196
196
#[ error( "welp" ) ]
197
197
#[ diagnostic( code( foo:: bar:: baz) , help( "{} x {my_field} x {:?}" , 1 , "2" ) ) ]
198
- struct BarStruct {
199
- my_field : String ,
198
+ struct BarStruct < ' a > {
199
+ my_field : & ' a str ,
200
200
}
201
201
202
202
assert_eq ! (
@@ -211,9 +211,9 @@ fn fmt_help() {
211
211
212
212
#[ derive( Debug , Diagnostic , Error ) ]
213
213
#[ error( "welp" ) ]
214
- enum FooEnum {
214
+ enum FooEnum < ' a > {
215
215
#[ diagnostic( code( foo:: x) , help( "{} x {0} x {:?}" , 1 , "2" ) ) ]
216
- X ( String ) ,
216
+ X ( & ' a str ) ,
217
217
218
218
#[ diagnostic( code( foo:: x) , help( "{} x {len} x {:?}" , 1 , "2" ) ) ]
219
219
Y { len : usize } ,
@@ -243,9 +243,9 @@ fn help_field() {
243
243
#[ derive( Debug , Diagnostic , Error ) ]
244
244
#[ error( "welp" ) ]
245
245
#[ diagnostic( ) ]
246
- struct Foo {
246
+ struct Foo < ' a > {
247
247
#[ help]
248
- do_this : Option < String > ,
248
+ do_this : Option < & ' a str > ,
249
249
}
250
250
251
251
assert_eq ! (
@@ -261,11 +261,11 @@ fn help_field() {
261
261
#[ derive( Debug , Diagnostic , Error ) ]
262
262
#[ error( "welp" ) ]
263
263
#[ diagnostic( ) ]
264
- enum Bar {
265
- A ( #[ help] Option < String > ) ,
264
+ enum Bar < ' a > {
265
+ A ( #[ help] Option < & ' a str > ) ,
266
266
B {
267
267
#[ help]
268
- do_this : Option < String > ,
268
+ do_this : Option < & ' a str > ,
269
269
} ,
270
270
}
271
271
@@ -286,7 +286,7 @@ fn help_field() {
286
286
#[ derive( Debug , Diagnostic , Error ) ]
287
287
#[ error( "welp" ) ]
288
288
#[ diagnostic( ) ]
289
- struct Baz ( #[ help] Option < String > ) ;
289
+ struct Baz < ' a > ( #[ help] Option < & ' a str > ) ;
290
290
291
291
assert_eq ! (
292
292
"x" . to_string( ) ,
@@ -296,7 +296,7 @@ fn help_field() {
296
296
#[ derive( Debug , Diagnostic , Error ) ]
297
297
#[ error( "welp" ) ]
298
298
#[ diagnostic( ) ]
299
- struct Quux ( #[ help] String ) ;
299
+ struct Quux < ' a > ( #[ help] & ' a str ) ;
300
300
301
301
assert_eq ! (
302
302
"x" . to_string( ) ,
@@ -309,9 +309,9 @@ fn test_snippet_named_struct() {
309
309
#[ derive( Debug , Diagnostic , Error ) ]
310
310
#[ error( "welp" ) ]
311
311
#[ diagnostic( code( foo:: bar:: baz) ) ]
312
- struct Foo {
312
+ struct Foo < ' a > {
313
313
#[ source_code]
314
- src : String ,
314
+ src : & ' a str ,
315
315
#[ label( "var 1" ) ]
316
316
var1 : SourceSpan ,
317
317
#[ label = "var 2" ]
@@ -331,8 +331,8 @@ fn test_snippet_unnamed_struct() {
331
331
#[ derive( Debug , Diagnostic , Error ) ]
332
332
#[ error( "welp" ) ]
333
333
#[ diagnostic( code( foo:: bar:: baz) ) ]
334
- struct Foo (
335
- #[ source_code] String ,
334
+ struct Foo < ' a > (
335
+ #[ source_code] & ' a str ,
336
336
#[ label( "{0}" ) ] SourceSpan ,
337
337
#[ label = "idk" ] SourceSpan ,
338
338
#[ label] SourceSpan ,
@@ -346,11 +346,11 @@ fn test_snippet_enum() {
346
346
#[ derive( Debug , Diagnostic , Error ) ]
347
347
#[ error( "welp" ) ]
348
348
#[ allow( dead_code) ]
349
- enum Foo {
349
+ enum Foo < ' a > {
350
350
#[ diagnostic( code( foo:: a) ) ]
351
351
A {
352
352
#[ source_code]
353
- src : String ,
353
+ src : & ' a str ,
354
354
msg : String ,
355
355
#[ label( "hi this is where the thing went wrong ({msg})" ) ]
356
356
var0 : SourceSpan ,
@@ -516,9 +516,9 @@ fn test_forward_struct_named() {
516
516
help( "{help}" ) ,
517
517
forward( span)
518
518
) ]
519
- struct Struct {
519
+ struct Struct < ' a > {
520
520
span : ForwardsTo ,
521
- help : & ' static str ,
521
+ help : & ' a str ,
522
522
}
523
523
// Also check the From impl here
524
524
let diag = Struct {
@@ -535,7 +535,7 @@ fn test_forward_struct_unnamed() {
535
535
#[ derive( Debug , Diagnostic , Error ) ]
536
536
#[ error( "display" ) ]
537
537
#[ diagnostic( code( foo:: bar:: overridden) , url( "{1}" ) , forward( 0 ) ) ]
538
- struct Struct ( ForwardsTo , & ' static str ) ;
538
+ struct Struct < ' a > ( ForwardsTo , & ' a str ) ;
539
539
540
540
// Also check the From impl here
541
541
let diag = Struct ( ForwardsTo :: new ( ) , "url here" ) ;
@@ -546,12 +546,12 @@ fn test_forward_struct_unnamed() {
546
546
#[ test]
547
547
fn test_forward_enum_named ( ) {
548
548
#[ derive( Debug , Diagnostic , Error ) ]
549
- enum Enum {
549
+ enum Enum < ' a > {
550
550
#[ error( "help: {help_text}" ) ]
551
551
#[ diagnostic( code( foo:: bar:: overridden) , help( "{help_text}" ) , forward( span) ) ]
552
552
Variant {
553
553
span : ForwardsTo ,
554
- help_text : & ' static str ,
554
+ help_text : & ' a str ,
555
555
} ,
556
556
}
557
557
// Also check the From impl here
@@ -569,10 +569,10 @@ fn test_forward_enum_named() {
569
569
#[ test]
570
570
fn test_forward_enum_unnamed ( ) {
571
571
#[ derive( Debug , Diagnostic , Error ) ]
572
- enum ForwardEnumUnnamed {
572
+ enum ForwardEnumUnnamed < ' a > {
573
573
#[ error( "help: {1}" ) ]
574
574
#[ diagnostic( code( foo:: bar:: overridden) , help( "{1}" ) , forward( 0 ) ) ]
575
- Variant ( ForwardsTo , & ' static str ) ,
575
+ Variant ( ForwardsTo , & ' a str ) ,
576
576
}
577
577
// Also check the From impl here
578
578
let variant = ForwardEnumUnnamed :: Variant ( ForwardsTo :: new ( ) , "overridden help please" ) ;
0 commit comments