Skip to content

Commit 4c02f16

Browse files
committed
Update fulldeps UI tests to the new lint diagnostic API
1 parent 957c07f commit 4c02f16

File tree

4 files changed

+52
-53
lines changed

4 files changed

+52
-53
lines changed

tests/ui-fulldeps/internal-lints/diagnostics.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern crate rustc_span;
1515

1616
use rustc_errors::{
1717
Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, LintDiagnostic,
18-
SubdiagMessageOp, SubdiagMessage, Subdiagnostic,
18+
MultiSpan, SubdiagMessageOp, SubdiagMessage, Subdiagnostic,
1919
};
2020
use rustc_macros::{Diagnostic, Subdiagnostic};
2121
use rustc_span::Span;
@@ -89,6 +89,10 @@ impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic {
8989
fn msg(&self) -> DiagMessage {
9090
unreachable!();
9191
}
92+
93+
fn span(&self) -> Option<MultiSpan> {
94+
None
95+
}
9296
}
9397

9498
pub struct TranslatableInLintDiagnostic;
@@ -101,6 +105,10 @@ impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic {
101105
fn msg(&self) -> DiagMessage {
102106
unreachable!();
103107
}
108+
109+
fn span(&self) -> Option<MultiSpan> {
110+
None
111+
}
104112
}
105113

106114
pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) {

tests/ui-fulldeps/internal-lints/diagnostics.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LL | diag.note("untranslatable diagnostic");
2323
| ^^^^
2424

2525
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
26-
--> $DIR/diagnostics.rs:107:21
26+
--> $DIR/diagnostics.rs:115:21
2727
|
2828
LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example);
2929
| ^^^^^^^^^^
@@ -35,13 +35,13 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)]
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls
38-
--> $DIR/diagnostics.rs:110:21
38+
--> $DIR/diagnostics.rs:118:21
3939
|
4040
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
4141
| ^^^^^^^^^^
4242

4343
error: diagnostics should be created using translatable messages
44-
--> $DIR/diagnostics.rs:110:21
44+
--> $DIR/diagnostics.rs:118:21
4545
|
4646
LL | let _diag = dcx.struct_err("untranslatable diagnostic");
4747
| ^^^^^^^^^^

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ struct LintsGood {}
561561
#[diag(no_crate_example)]
562562
struct PrimarySpanOnLint {
563563
#[primary_span]
564-
//~^ ERROR `#[primary_span]` is not a valid attribute
565564
span: Span,
566565
}
567566

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+40-48
Original file line numberDiff line numberDiff line change
@@ -322,208 +322,200 @@ error: only `no_span` is a valid nested attribute
322322
LL | #[label(no_crate_label, foo("..."))]
323323
| ^^^
324324

325-
error: `#[primary_span]` is not a valid attribute
326-
--> $DIR/diagnostic-derive.rs:563:5
327-
|
328-
LL | #[primary_span]
329-
| ^
330-
|
331-
= help: the `primary_span` field attribute is not valid for lint diagnostics
332-
333325
error: `#[error(...)]` is not a valid attribute
334-
--> $DIR/diagnostic-derive.rs:583:1
326+
--> $DIR/diagnostic-derive.rs:582:1
335327
|
336328
LL | #[error(no_crate_example, code = E0123)]
337329
| ^
338330

339331
error: diagnostic slug not specified
340-
--> $DIR/diagnostic-derive.rs:583:1
332+
--> $DIR/diagnostic-derive.rs:582:1
341333
|
342334
LL | #[error(no_crate_example, code = E0123)]
343335
| ^
344336
|
345337
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
346338

347339
error: `#[warn_(...)]` is not a valid attribute
348-
--> $DIR/diagnostic-derive.rs:590:1
340+
--> $DIR/diagnostic-derive.rs:589:1
349341
|
350342
LL | #[warn_(no_crate_example, code = E0123)]
351343
| ^
352344

353345
error: diagnostic slug not specified
354-
--> $DIR/diagnostic-derive.rs:590:1
346+
--> $DIR/diagnostic-derive.rs:589:1
355347
|
356348
LL | #[warn_(no_crate_example, code = E0123)]
357349
| ^
358350
|
359351
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
360352

361353
error: `#[lint(...)]` is not a valid attribute
362-
--> $DIR/diagnostic-derive.rs:597:1
354+
--> $DIR/diagnostic-derive.rs:596:1
363355
|
364356
LL | #[lint(no_crate_example, code = E0123)]
365357
| ^
366358

367359
error: diagnostic slug not specified
368-
--> $DIR/diagnostic-derive.rs:597:1
360+
--> $DIR/diagnostic-derive.rs:596:1
369361
|
370362
LL | #[lint(no_crate_example, code = E0123)]
371363
| ^
372364
|
373365
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
374366

375367
error: `#[lint(...)]` is not a valid attribute
376-
--> $DIR/diagnostic-derive.rs:604:1
368+
--> $DIR/diagnostic-derive.rs:603:1
377369
|
378370
LL | #[lint(no_crate_example, code = E0123)]
379371
| ^
380372

381373
error: `#[lint(...)]` is not a valid attribute
382-
--> $DIR/diagnostic-derive.rs:604:1
374+
--> $DIR/diagnostic-derive.rs:603:1
383375
|
384376
LL | #[lint(no_crate_example, code = E0123)]
385377
| ^
386378
|
387379
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
388380

389381
error: diagnostic slug not specified
390-
--> $DIR/diagnostic-derive.rs:604:1
382+
--> $DIR/diagnostic-derive.rs:603:1
391383
|
392384
LL | #[lint(no_crate_example, code = E0123)]
393385
| ^
394386
|
395387
= help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]`
396388

397389
error: specified multiple times
398-
--> $DIR/diagnostic-derive.rs:614:53
390+
--> $DIR/diagnostic-derive.rs:613:53
399391
|
400392
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
401393
| ^^^^
402394
|
403395
note: previously specified here
404-
--> $DIR/diagnostic-derive.rs:614:39
396+
--> $DIR/diagnostic-derive.rs:613:39
405397
|
406398
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
407399
| ^^^^
408400

409401
error: wrong types for suggestion
410-
--> $DIR/diagnostic-derive.rs:623:24
402+
--> $DIR/diagnostic-derive.rs:622:24
411403
|
412404
LL | suggestion: (Span, usize),
413405
| ^^^^^
414406
|
415407
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
416408

417409
error: wrong types for suggestion
418-
--> $DIR/diagnostic-derive.rs:631:17
410+
--> $DIR/diagnostic-derive.rs:630:17
419411
|
420412
LL | suggestion: (Span,),
421413
| ^^^^^^^
422414
|
423415
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
424416

425417
error: suggestion without `code = "..."`
426-
--> $DIR/diagnostic-derive.rs:638:5
418+
--> $DIR/diagnostic-derive.rs:637:5
427419
|
428420
LL | #[suggestion(no_crate_suggestion)]
429421
| ^
430422

431423
error: `#[multipart_suggestion(...)]` is not a valid attribute
432-
--> $DIR/diagnostic-derive.rs:645:1
424+
--> $DIR/diagnostic-derive.rs:644:1
433425
|
434426
LL | #[multipart_suggestion(no_crate_suggestion)]
435427
| ^
436428
|
437429
= help: consider creating a `Subdiagnostic` instead
438430

439431
error: `#[multipart_suggestion(...)]` is not a valid attribute
440-
--> $DIR/diagnostic-derive.rs:648:1
432+
--> $DIR/diagnostic-derive.rs:647:1
441433
|
442434
LL | #[multipart_suggestion()]
443435
| ^
444436
|
445437
= help: consider creating a `Subdiagnostic` instead
446438

447439
error: `#[multipart_suggestion(...)]` is not a valid attribute
448-
--> $DIR/diagnostic-derive.rs:652:5
440+
--> $DIR/diagnostic-derive.rs:651:5
449441
|
450442
LL | #[multipart_suggestion(no_crate_suggestion)]
451443
| ^
452444
|
453445
= help: consider creating a `Subdiagnostic` instead
454446

455447
error: `#[suggestion(...)]` is not a valid attribute
456-
--> $DIR/diagnostic-derive.rs:660:1
448+
--> $DIR/diagnostic-derive.rs:659:1
457449
|
458450
LL | #[suggestion(no_crate_suggestion, code = "...")]
459451
| ^
460452
|
461453
= help: `#[label]` and `#[suggestion]` can only be applied to fields
462454

463455
error: `#[label]` is not a valid attribute
464-
--> $DIR/diagnostic-derive.rs:669:1
456+
--> $DIR/diagnostic-derive.rs:668:1
465457
|
466458
LL | #[label]
467459
| ^
468460
|
469461
= help: `#[label]` and `#[suggestion]` can only be applied to fields
470462

471463
error: `#[subdiagnostic(...)]` is not a valid attribute
472-
--> $DIR/diagnostic-derive.rs:703:5
464+
--> $DIR/diagnostic-derive.rs:702:5
473465
|
474466
LL | #[subdiagnostic(bad)]
475467
| ^
476468

477469
error: `#[subdiagnostic = ...]` is not a valid attribute
478-
--> $DIR/diagnostic-derive.rs:711:5
470+
--> $DIR/diagnostic-derive.rs:710:5
479471
|
480472
LL | #[subdiagnostic = "bad"]
481473
| ^
482474

483475
error: `#[subdiagnostic(...)]` is not a valid attribute
484-
--> $DIR/diagnostic-derive.rs:719:5
476+
--> $DIR/diagnostic-derive.rs:718:5
485477
|
486478
LL | #[subdiagnostic(bad, bad)]
487479
| ^
488480

489481
error: `#[subdiagnostic(...)]` is not a valid attribute
490-
--> $DIR/diagnostic-derive.rs:727:5
482+
--> $DIR/diagnostic-derive.rs:726:5
491483
|
492484
LL | #[subdiagnostic("bad")]
493485
| ^
494486

495487
error: `#[subdiagnostic(...)]` is not a valid attribute
496-
--> $DIR/diagnostic-derive.rs:735:5
488+
--> $DIR/diagnostic-derive.rs:734:5
497489
|
498490
LL | #[subdiagnostic(eager)]
499491
| ^
500492

501493
error: `#[subdiagnostic(...)]` is not a valid attribute
502-
--> $DIR/diagnostic-derive.rs:743:5
494+
--> $DIR/diagnostic-derive.rs:742:5
503495
|
504496
LL | #[subdiagnostic(eager)]
505497
| ^
506498

507499
error: `#[subdiagnostic(...)]` is not a valid attribute
508-
--> $DIR/diagnostic-derive.rs:764:5
500+
--> $DIR/diagnostic-derive.rs:763:5
509501
|
510502
LL | #[subdiagnostic(eager)]
511503
| ^
512504

513505
error: expected at least one string literal for `code(...)`
514-
--> $DIR/diagnostic-derive.rs:795:23
506+
--> $DIR/diagnostic-derive.rs:794:23
515507
|
516508
LL | #[suggestion(code())]
517509
| ^
518510

519511
error: `code(...)` must contain only string literals
520-
--> $DIR/diagnostic-derive.rs:803:23
512+
--> $DIR/diagnostic-derive.rs:802:23
521513
|
522514
LL | #[suggestion(code(foo))]
523515
| ^^^
524516

525517
error: `#[suggestion(...)]` is not a valid attribute
526-
--> $DIR/diagnostic-derive.rs:827:5
518+
--> $DIR/diagnostic-derive.rs:826:5
527519
|
528520
LL | #[suggestion(no_crate_suggestion, code = "")]
529521
| ^
@@ -539,13 +531,13 @@ LL | #[diag = "E0123"]
539531
| ^ maybe a missing crate `core`?
540532

541533
error[E0433]: failed to resolve: maybe a missing crate `core`?
542-
--> $DIR/diagnostic-derive.rs:803:23
534+
--> $DIR/diagnostic-derive.rs:802:23
543535
|
544536
LL | #[suggestion(code(foo))]
545537
| ^^^ maybe a missing crate `core`?
546538

547539
error[E0433]: failed to resolve: maybe a missing crate `core`?
548-
--> $DIR/diagnostic-derive.rs:812:25
540+
--> $DIR/diagnostic-derive.rs:811:25
549541
|
550542
LL | #[suggestion(code = 3)]
551543
| ^ maybe a missing crate `core`?
@@ -563,43 +555,43 @@ LL | #[nonsense]
563555
| ^^^^^^^^
564556

565557
error: cannot find attribute `error` in this scope
566-
--> $DIR/diagnostic-derive.rs:583:3
558+
--> $DIR/diagnostic-derive.rs:582:3
567559
|
568560
LL | #[error(no_crate_example, code = E0123)]
569561
| ^^^^^
570562

571563
error: cannot find attribute `warn_` in this scope
572-
--> $DIR/diagnostic-derive.rs:590:3
564+
--> $DIR/diagnostic-derive.rs:589:3
573565
|
574566
LL | #[warn_(no_crate_example, code = E0123)]
575567
| ^^^^^ help: a built-in attribute with a similar name exists: `warn`
576568

577569
error: cannot find attribute `lint` in this scope
578-
--> $DIR/diagnostic-derive.rs:597:3
570+
--> $DIR/diagnostic-derive.rs:596:3
579571
|
580572
LL | #[lint(no_crate_example, code = E0123)]
581573
| ^^^^ help: a built-in attribute with a similar name exists: `link`
582574

583575
error: cannot find attribute `lint` in this scope
584-
--> $DIR/diagnostic-derive.rs:604:3
576+
--> $DIR/diagnostic-derive.rs:603:3
585577
|
586578
LL | #[lint(no_crate_example, code = E0123)]
587579
| ^^^^ help: a built-in attribute with a similar name exists: `link`
588580

589581
error: cannot find attribute `multipart_suggestion` in this scope
590-
--> $DIR/diagnostic-derive.rs:645:3
582+
--> $DIR/diagnostic-derive.rs:644:3
591583
|
592584
LL | #[multipart_suggestion(no_crate_suggestion)]
593585
| ^^^^^^^^^^^^^^^^^^^^
594586

595587
error: cannot find attribute `multipart_suggestion` in this scope
596-
--> $DIR/diagnostic-derive.rs:648:3
588+
--> $DIR/diagnostic-derive.rs:647:3
597589
|
598590
LL | #[multipart_suggestion()]
599591
| ^^^^^^^^^^^^^^^^^^^^
600592

601593
error: cannot find attribute `multipart_suggestion` in this scope
602-
--> $DIR/diagnostic-derive.rs:652:7
594+
--> $DIR/diagnostic-derive.rs:651:7
603595
|
604596
LL | #[multipart_suggestion(no_crate_suggestion)]
605597
| ^^^^^^^^^^^^^^^^^^^^
@@ -611,7 +603,7 @@ LL | #[diag(nonsense, code = E0123)]
611603
| ^^^^^^^^ not found in `crate::fluent_generated`
612604

613605
error[E0425]: cannot find value `__code_34` in this scope
614-
--> $DIR/diagnostic-derive.rs:809:10
606+
--> $DIR/diagnostic-derive.rs:808:10
615607
|
616608
LL | #[derive(Diagnostic)]
617609
| ^^^^^^^^^^ not found in this scope
@@ -632,7 +624,7 @@ note: required by a bound in `Diag::<'a, G>::arg`
632624
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
633625
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
634626

635-
error: aborting due to 86 previous errors
627+
error: aborting due to 85 previous errors
636628

637629
Some errors have detailed explanations: E0277, E0425, E0433.
638630
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)