Skip to content

Commit d028db9

Browse files
committed
ui-fulldeps: adopt to the new rustc lint API
1 parent b307115 commit d028db9

12 files changed

+44
-40
lines changed

Diff for: compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ pub trait LintContext: Sized {
917917
fn lint(
918918
&self,
919919
lint: &'static Lint,
920-
msg: DiagnosticMessage,
920+
msg: impl Into<DiagnosticMessage>,
921921
decorate: impl for<'a, 'b> FnOnce(
922922
&'b mut DiagnosticBuilder<'a, ()>,
923923
) -> &'b mut DiagnosticBuilder<'a, ()>,

Diff for: src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass {
4949

5050
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
5151
if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) {
52-
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
53-
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit();
54-
});
52+
cx.lint(
53+
MISSING_ALLOWED_ATTR,
54+
"Missing 'allowed_attr' attribute",
55+
|lint| lint.set_span(span)
56+
);
5557
}
5658
}
5759
}

Diff for: src/test/ui-fulldeps/auxiliary/lint-for-crate.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
2929
let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
3030
let span = cx.tcx.def_span(CRATE_DEF_ID);
3131
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
32-
cx.lint(CRATE_NOT_OKAY, |lint| {
33-
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit();
34-
});
32+
cx.lint(
33+
CRATE_NOT_OKAY,
34+
"crate is not marked with #![crate_okay]",
35+
|lint| lint.set_span(span)
36+
);
3537
}
3638
}
3739
}

Diff for: src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]);
2222
impl<'tcx> LateLintPass<'tcx> for Pass {
2323
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
2424
match it.ident.as_str() {
25-
"lintme" => cx.lint(TEST_LINT, |lint| {
26-
lint.build("item is named 'lintme'").set_span(it.span).emit();
27-
}),
28-
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
29-
lint.build("item is named 'pleaselintme'").set_span(it.span).emit();
30-
}),
25+
"lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)),
26+
"pleaselintme" => {
27+
cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span))
28+
}
3129
_ => {}
3230
}
3331
}

Diff for: src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
2121
impl EarlyLintPass for Pass {
2222
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
2323
if it.ident.name.as_str() == "lintme" {
24-
cx.lint(TEST_LINT, |lint| {
25-
lint.build("item is named 'lintme'").set_span(it.span).emit();
26-
});
24+
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
2725
}
2826
}
2927
}

Diff for: src/test/ui-fulldeps/auxiliary/lint-tool-test.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
3131
impl EarlyLintPass for Pass {
3232
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
3333
if it.ident.name.as_str() == "lintme" {
34-
cx.lint(TEST_LINT, |lint| {
35-
lint.build("item is named 'lintme'").set_span(it.span).emit();
36-
});
34+
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
3735
}
3836
if it.ident.name.as_str() == "lintmetoo" {
39-
cx.lint(TEST_GROUP, |lint| {
40-
lint.build("item is named 'lintmetoo'").set_span(it.span).emit();
41-
});
37+
cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span));
4238
}
4339
}
4440
}

Diff for: src/test/ui-fulldeps/internal-lints/default_hash_types.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: prefer `FxHashMap` over `HashMap`, it has better performance
44
LL | let _map: HashMap<String, String> = HashMap::default();
55
| ^^^^^^^
66
|
7+
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
78
note: the lint level is defined here
89
--> $DIR/default_hash_types.rs:4:9
910
|
1011
LL | #![deny(rustc::default_hash_types)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
1313

1414
error: prefer `FxHashMap` over `HashMap`, it has better performance
1515
--> $DIR/default_hash_types.rs:16:15

Diff for: src/test/ui-fulldeps/internal-lints/existing_doc_keyword.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: found non-existing keyword `tadam` used in `#[doc(keyword = \"...\")]`
44
LL | #[doc(keyword = "tadam")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7+
= help: only existing keywords are allowed in core/std
78
note: the lint level is defined here
89
--> $DIR/existing_doc_keyword.rs:8:9
910
|
1011
LL | #![deny(rustc::existing_doc_keyword)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= help: only existing keywords are allowed in core/std
1313

1414
error: aborting due to previous error
1515

Diff for: src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: implementing `LintPass` by hand
44
LL | impl LintPass for Foo {
55
| ^^^^^^^^
66
|
7+
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
78
note: the lint level is defined here
89
--> $DIR/lint_pass_impl_without_macro.rs:4:9
910
|
1011
LL | #![deny(rustc::lint_pass_impl_without_macro)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
1313

1414
error: implementing `LintPass` by hand
1515
--> $DIR/lint_pass_impl_without_macro.rs:30:14

Diff for: src/test/ui-fulldeps/internal-lints/query_stability.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error: using `drain` can result in unstable query results
44
LL | for _ in x.drain() {}
55
| ^^^^^
66
|
7+
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
78
note: the lint level is defined here
89
--> $DIR/query_stability.rs:4:9
910
|
1011
LL | #![deny(rustc::potential_query_instability)]
1112
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
1313

1414
error: using `iter` can result in unstable query results
1515
--> $DIR/query_stability.rs:16:16

Diff for: src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ struct LintAttributeOnSessionDiag {}
585585
#[derive(LintDiagnostic)]
586586
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
587587
//~^ ERROR `#[lint(...)]` is not a valid attribute
588+
//~| ERROR `#[lint(...)]` is not a valid attribute
588589
//~| ERROR diagnostic slug not specified
589590
//~| ERROR cannot find attribute `lint` in this scope
590591
struct LintAttributeOnLintDiag {}

Diff for: src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+21-14
Original file line numberDiff line numberDiff line change
@@ -440,86 +440,93 @@ error: `#[lint(...)]` is not a valid attribute
440440
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
441441
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
442442

443+
error: `#[lint(...)]` is not a valid attribute
444+
--> $DIR/diagnostic-derive.rs:586:1
445+
|
446+
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
447+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
448+
443449
error: diagnostic slug not specified
444450
--> $DIR/diagnostic-derive.rs:586:1
445451
|
446452
LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
447453
LL | |
448454
LL | |
449455
LL | |
456+
LL | |
450457
LL | | struct LintAttributeOnLintDiag {}
451458
| |_________________________________^
452459
|
453460
= help: specify the slug as the first argument to the attribute, such as `#[diag(typeck::example_error)]`
454461

455462
error: specified multiple times
456-
--> $DIR/diagnostic-derive.rs:595:52
463+
--> $DIR/diagnostic-derive.rs:596:52
457464
|
458465
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
459466
| ^^^^^^^^^^^^
460467
|
461468
note: previously specified here
462-
--> $DIR/diagnostic-derive.rs:595:38
469+
--> $DIR/diagnostic-derive.rs:596:38
463470
|
464471
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
465472
| ^^^^^^^^^^^^
466473

467474
error: wrong types for suggestion
468-
--> $DIR/diagnostic-derive.rs:604:24
475+
--> $DIR/diagnostic-derive.rs:605:24
469476
|
470477
LL | suggestion: (Span, usize),
471478
| ^^^^^
472479
|
473480
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
474481

475482
error: wrong types for suggestion
476-
--> $DIR/diagnostic-derive.rs:612:17
483+
--> $DIR/diagnostic-derive.rs:613:17
477484
|
478485
LL | suggestion: (Span,),
479486
| ^^^^^^^
480487
|
481488
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
482489

483490
error: suggestion without `code = "..."`
484-
--> $DIR/diagnostic-derive.rs:619:5
491+
--> $DIR/diagnostic-derive.rs:620:5
485492
|
486493
LL | #[suggestion(typeck::suggestion)]
487494
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
488495

489496
error: `#[multipart_suggestion(...)]` is not a valid attribute
490-
--> $DIR/diagnostic-derive.rs:626:1
497+
--> $DIR/diagnostic-derive.rs:627:1
491498
|
492499
LL | #[multipart_suggestion(typeck::suggestion)]
493500
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
494501
|
495502
= help: consider creating a `Subdiagnostic` instead
496503

497504
error: `#[multipart_suggestion(...)]` is not a valid attribute
498-
--> $DIR/diagnostic-derive.rs:629:1
505+
--> $DIR/diagnostic-derive.rs:630:1
499506
|
500507
LL | #[multipart_suggestion()]
501508
| ^^^^^^^^^^^^^^^^^^^^^^^^^
502509
|
503510
= help: consider creating a `Subdiagnostic` instead
504511

505512
error: `#[multipart_suggestion(...)]` is not a valid attribute
506-
--> $DIR/diagnostic-derive.rs:633:5
513+
--> $DIR/diagnostic-derive.rs:634:5
507514
|
508515
LL | #[multipart_suggestion(typeck::suggestion)]
509516
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
510517
|
511518
= help: consider creating a `Subdiagnostic` instead
512519

513520
error: `#[suggestion(...)]` is not a valid attribute
514-
--> $DIR/diagnostic-derive.rs:641:1
521+
--> $DIR/diagnostic-derive.rs:642:1
515522
|
516523
LL | #[suggestion(typeck::suggestion, code = "...")]
517524
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
518525
|
519526
= help: `#[label]` and `#[suggestion]` can only be applied to fields
520527

521528
error: `#[label]` is not a valid attribute
522-
--> $DIR/diagnostic-derive.rs:650:1
529+
--> $DIR/diagnostic-derive.rs:651:1
523530
|
524531
LL | #[label]
525532
| ^^^^^^^^
@@ -563,19 +570,19 @@ LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
563570
| ^^^^ help: a built-in attribute with a similar name exists: `link`
564571

565572
error: cannot find attribute `multipart_suggestion` in this scope
566-
--> $DIR/diagnostic-derive.rs:626:3
573+
--> $DIR/diagnostic-derive.rs:627:3
567574
|
568575
LL | #[multipart_suggestion(typeck::suggestion)]
569576
| ^^^^^^^^^^^^^^^^^^^^
570577

571578
error: cannot find attribute `multipart_suggestion` in this scope
572-
--> $DIR/diagnostic-derive.rs:629:3
579+
--> $DIR/diagnostic-derive.rs:630:3
573580
|
574581
LL | #[multipart_suggestion()]
575582
| ^^^^^^^^^^^^^^^^^^^^
576583

577584
error: cannot find attribute `multipart_suggestion` in this scope
578-
--> $DIR/diagnostic-derive.rs:633:7
585+
--> $DIR/diagnostic-derive.rs:634:7
579586
|
580587
LL | #[multipart_suggestion(typeck::suggestion)]
581588
| ^^^^^^^^^^^^^^^^^^^^
@@ -600,7 +607,7 @@ LL | arg: impl IntoDiagnosticArg,
600607
| ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
601608
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
602609

603-
error: aborting due to 74 previous errors
610+
error: aborting due to 75 previous errors
604611

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

0 commit comments

Comments
 (0)